From 8a22e502bdd7e4181b1b2d66b1a1da9c29a287c8 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Thu, 11 Aug 2016 00:19:51 +0000 Subject: [PATCH] [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. llvm-svn: 278306 --- clang/tools/driver/CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt index e03b3fa..0d9a55b 100644 --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -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() -- 2.7.4