diff options
author | Chris Bieneman <beanz@apple.com> | 2016-02-12 21:36:55 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2016-02-12 21:36:55 +0000 |
commit | 3878bc4a33fd4461c8e2b3d80259a6b9a3b3277d (patch) | |
tree | fa0ff5f27dc41658aacbe0f4d40a40c364c85889 /clang/CMakeLists.txt | |
parent | bb49490de1dea43b036ecb9db09b4e6cce0b04b6 (diff) |
[CMake] Improve the clang order-file generation workflow
Summary:
This commit re-lands r259862. The underlying cause of the build breakage was an incorrectly written capabilities test. In tools/Driver/CMakeLists.txt I was attempting to check if a linker flag worked, the test was passing it to the compiler, not the linker. CMake doesn't have a linker test, so we have a hand-rolled one.
Original Patch Review: http://reviews.llvm.org/D16896
Original Summary:
With this change generating clang order files using dtrace uses the following workflow:
cmake <whatever options you want>
ninja generate-order-file
ninja clang
This patch works by setting a default path to the order file (which can be overridden by the user). If the order file doesn't exist during configuration CMake will create an empty one.
CMake then ties up the dependencies between the clang link job and the order file, and generate-order-file overwrites CLANG_ORDER_FILE with the new order file.
Reviewers: bogner
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D16999
llvm-svn: 260742
Diffstat (limited to 'clang/CMakeLists.txt')
-rw-r--r-- | clang/CMakeLists.txt | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index be8a7aa522d3..2fd98cfe90ec 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -595,18 +595,24 @@ if( CLANG_INCLUDE_DOCS ) add_subdirectory(docs) endif() -if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/clang.order") - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/clang.order") -endif() - -if(CLANG_ORDER_FILE STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/clang.order") +# this line is needed as a cleanup to ensure that any CMakeCaches with the old +# default value get updated to the new default. +if(CLANG_ORDER_FILE STREQUAL "") unset(CLANG_ORDER_FILE CACHE) - unset(CLANG_ORDER_FILE) endif() -set(CLANG_ORDER_FILE "" CACHE FILEPATH +set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH "Order file to use when compiling clang in order to improve startup time.") +if(CLANG_ORDER_FILE AND NOT EXISTS ${CLANG_ORDER_FILE}) + string(FIND CLANG_ORDER_FILE "${CMAKE_CURRENT_BINARY_DIR}" PATH_START) + if(PATH_START EQUAL 0) + file(WRITE ${CLANG_ORDER_FILE} "\n") + else() + message(FATAL_ERROR "Specified order file '${CLANG_ORDER_FILE}' does not exist.") + endif() +endif() + if (CLANG_BUILT_STANDALONE OR CMAKE_VERSION VERSION_EQUAL 3 OR CMAKE_VERSION VERSION_GREATER 3) # Generate a list of CMake library targets so that other CMake projects can |