[PATCH] D16896: [CMake] Improve the clang order-file generation workflow

Chris Bieneman via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 4 15:00:51 PST 2016


beanz updated this revision to Diff 46966.
beanz added a comment.

Gate adding the -order_file linker option on whether the linker supports it.


http://reviews.llvm.org/D16896

Files:
  CMakeLists.txt
  tools/driver/CMakeLists.txt
  utils/perf-training/CMakeLists.txt

Index: utils/perf-training/CMakeLists.txt
===================================================================
--- utils/perf-training/CMakeLists.txt
+++ 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: tools/driver/CMakeLists.txt
===================================================================
--- tools/driver/CMakeLists.txt
+++ tools/driver/CMakeLists.txt
@@ -87,8 +87,12 @@
   set(TOOL_INFO_BUILD_VERSION)
 endif()
 
-if(CLANG_ORDER_FILE)
+check_cxx_compiler_flag("-Wl,-order_file,${CLANG_ORDER_FILE}"
+  LINKER_HAS_ORDER_FILE_FLAG)
+
+if(LINKER_HAS_ORDER_FILE_FLAG)
   target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}")
+  set_target_properties(clang PROPERTIES LINK_DEPENDS ${CLANG_ORDER_FILE})
 endif()
 
 if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -586,9 +586,19 @@
   add_subdirectory(docs)
 endif()
 
-set(CLANG_ORDER_FILE "" CACHE FILEPATH
+# 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)
+endif()
+
+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(NOT EXISTS ${CLANG_ORDER_FILE})
+  execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${CLANG_ORDER_FILE})
+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: D16896.46966.patch
Type: text/x-patch
Size: 2340 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160204/5edfbc0b/attachment.bin>


More information about the cfe-commits mailing list