]> granicus.if.org Git - clang/commitdiff
[Order Files] Don't use empty order files
authorChris Bieneman <beanz@apple.com>
Thu, 11 Aug 2016 00:19:51 +0000 (00:19 +0000)
committerChris Bieneman <beanz@apple.com>
Thu, 11 Aug 2016 00:19:51 +0000 (00:19 +0000)
LD64 does optimization on symbol layouts that gets disabled whenever an order file is passed (even if it is empty). This change prevents disabling that optimization, and still enables iterative generation and usage of order files.

If the order file is empty it does not setup the order file flags, instead it sets the empty order file as a configuration dependency. When the order file changes it will then trigger a re-configuration that adds the linker flag.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@278306 91177308-0d34-0410-b5e6-96231b3b80d8

tools/driver/CMakeLists.txt

index e03b3fa3951ef78a6b907ba8f894b986e9dd8307..0d9a55b2b4462a7173be990dcbec26a33e993f06 100644 (file)
@@ -101,8 +101,15 @@ if(LD64_EXECUTABLE AND CLANG_ORDER_FILE)
   # 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)
+
+  # Passing an empty order file disables some linker layout optimizations.
+  # To work around this and enable workflows for re-linking when the order file
+  # changes we check during configuration if the file is empty, and make it a
+  # configuration dependency.
+  file(READ ${CLANG_ORDER_FILE} ORDER_FILE LIMIT 20)
+  if("${ORDER_FILE}" STREQUAL "\n")
+    set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CLANG_ORDER_FILE})
+  elseif(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()