summaryrefslogtreecommitdiffstats
path: root/llvm/cmake
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2019-10-01 13:39:43 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2019-10-01 13:39:43 +0000
commit9eb2bd6b8d6d31cee53f4f89dd9189da721ed4a8 (patch)
treea822243583ece7fc0348c7bb75066dd685d2c234 /llvm/cmake
parente4e305e5eea536fb9d9dc64f612b164822d4bf34 (diff)
downloadbcm5719-llvm-9eb2bd6b8d6d31cee53f4f89dd9189da721ed4a8.tar.gz
bcm5719-llvm-9eb2bd6b8d6d31cee53f4f89dd9189da721ed4a8.zip
Revert rL349624 : Let TableGen write output only if it changed, instead of doing so in cmake, attempt 2
Differential Revision: https://reviews.llvm.org/D55842 ----------------- As discussed on PR43385 this is causing Visual Studio msbuilds to perpetually rebuild all tablegen generated files llvm-svn: 373338
Diffstat (limited to 'llvm/cmake')
-rw-r--r--llvm/cmake/modules/TableGen.cmake20
1 files changed, 16 insertions, 4 deletions
diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake
index ca9357e295e..71dfebb12b4 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -23,7 +23,7 @@ function(tablegen project ofn)
file(RELATIVE_PATH ofn_rel
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${ofn})
set(additional_cmdline
- -o ${ofn_rel}
+ -o ${ofn_rel}.tmp
-d ${ofn_rel}.d
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.d
@@ -34,7 +34,7 @@ function(tablegen project ofn)
file(GLOB local_tds "*.td")
file(GLOB_RECURSE global_tds "${LLVM_MAIN_INCLUDE_DIR}/llvm/*.td")
set(additional_cmdline
- -o ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
+ -o ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
)
endif()
@@ -67,7 +67,8 @@ function(tablegen project ofn)
# dependency twice in the result file when
# ("${${project}_TABLEGEN_TARGET}" STREQUAL "${${project}_TABLEGEN_EXE}")
# but lets us having smaller and cleaner code here.
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
+ # Generate tablegen output in a temporary file.
COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
${LLVM_TABLEGEN_FLAGS}
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
@@ -80,9 +81,20 @@ function(tablegen project ofn)
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
COMMENT "Building ${ofn}..."
)
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
+ # Only update the real output file if there are any differences.
+ # This prevents recompilation of all the files depending on it if there
+ # aren't any.
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
+ ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
+ COMMENT "Updating ${ofn}..."
+ )
# `make clean' must remove all those generated files:
- set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${ofn})
+ set_property(DIRECTORY APPEND
+ PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${ofn}.tmp ${ofn})
set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn} PARENT_SCOPE)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${ofn} PROPERTIES
OpenPOWER on IntegriCloud