summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2018-05-07 23:41:48 +0000
committerChandler Carruth <chandlerc@gmail.com>2018-05-07 23:41:48 +0000
commit5d61ed94175695af323eff94ca92de6944bc94a0 (patch)
treec6c7b0bfa29d0a9d2495751c4d7ee196218e1939 /cmake
parent07e155ea6abdf3dde90b0521aff942a335517f23 (diff)
Revert r330742: Let TableGen write output only if it changed, instead of doing so in cmake.
This change causes us to re-run tablegen for every single target on every single build. This is much, much worse than the problem being fixed AFAICT. On my system, it makes a clean rebuild of `llc` with nothing changed go from .5s to over 8s. On systems with less parallelism, slower file systems, or high process startup overhead this will be even more extreme. The only way I see this could be a win is in clean builds where we churn the filesystem. But I think incremental rebuild is more important, and so if we want to re-instate this, it needs to be done in a way that doesn't trigger constant re-runs of tablegen. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331702 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/TableGen.cmake20
1 files changed, 16 insertions, 4 deletions
diff --git a/cmake/modules/TableGen.cmake b/cmake/modules/TableGen.cmake
index ee1840da6c5..d1afcb42f9d 100644
--- a/cmake/modules/TableGen.cmake
+++ b/cmake/modules/TableGen.cmake
@@ -25,7 +25,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
@@ -36,7 +36,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()
@@ -69,7 +69,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}
@@ -82,9 +83,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