r278306 - [Order Files] Don't use empty order files

Chris Bieneman via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 10 17:19:51 PDT 2016


Author: cbieneman
Date: Wed Aug 10 19:19:51 2016
New Revision: 278306

URL: http://llvm.org/viewvc/llvm-project?rev=278306&view=rev
Log:
[Order Files] Don't use empty order files

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.

Modified:
    cfe/trunk/tools/driver/CMakeLists.txt

Modified: cfe/trunk/tools/driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=278306&r1=278305&r2=278306&view=diff
==============================================================================
--- cfe/trunk/tools/driver/CMakeLists.txt (original)
+++ cfe/trunk/tools/driver/CMakeLists.txt Wed Aug 10 19:19:51 2016
@@ -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()




More information about the cfe-commits mailing list