[PATCH] D16999: [CMake] Improve the clang order-file generation workflow
Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 12 13:41:19 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL260742: [CMake] Improve the clang order-file generation workflow (authored by cbieneman).
Changed prior to commit:
http://reviews.llvm.org/D16999?vs=47241&id=47852#toc
Repository:
rL LLVM
http://reviews.llvm.org/D16999
Files:
cfe/trunk/CMakeLists.txt
cfe/trunk/tools/driver/CMakeLists.txt
cfe/trunk/utils/perf-training/CMakeLists.txt
Index: cfe/trunk/tools/driver/CMakeLists.txt
===================================================================
--- cfe/trunk/tools/driver/CMakeLists.txt
+++ cfe/trunk/tools/driver/CMakeLists.txt
@@ -87,8 +87,24 @@
set(TOOL_INFO_BUILD_VERSION)
endif()
-if(CLANG_ORDER_FILE AND EXISTS CLANG_ORDER_FILE)
- target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}")
+if(CLANG_ORDER_FILE)
+ include(CMakePushCheckState)
+
+ function(check_linker_flag flag out_var)
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}")
+ check_cxx_compiler_flag("" ${out_var})
+ cmake_pop_check_state()
+ endfunction()
+
+ # This is a test to ensure the actual order file works with the linker.
+ check_linker_flag("-Wl,-order_file,${CLANG_ORDER_FILE}"
+ LINKER_ORDER_FILE_WORKS)
+
+ if(LINKER_ORDER_FILE_WORKS)
+ target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}")
+ set_target_properties(clang PROPERTIES LINK_DEPENDS ${CLANG_ORDER_FILE})
+ endif()
endif()
if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
Index: cfe/trunk/utils/perf-training/CMakeLists.txt
===================================================================
--- cfe/trunk/utils/perf-training/CMakeLists.txt
+++ cfe/trunk/utils/perf-training/CMakeLists.txt
@@ -55,9 +55,8 @@
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR} dtrace
COMMENT "Clearing old dtrace data")
-
add_custom_target(generate-order-file
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py gen-order-file --binary $<TARGET_FILE:clang> --output ${CMAKE_CURRENT_BINARY_DIR}/clang.order ${CMAKE_CURRENT_BINARY_DIR}
+ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py gen-order-file --binary $<TARGET_FILE:clang> --output ${CLANG_ORDER_FILE} ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating order file"
DEPENDS generate-dtrace-logs)
endif()
Index: cfe/trunk/CMakeLists.txt
===================================================================
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -595,18 +595,24 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16999.47852.patch
Type: text/x-patch
Size: 3322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160212/0951aa5f/attachment.bin>
More information about the cfe-commits
mailing list