From: Rafael Espindola Date: Sun, 19 Oct 2014 23:24:46 +0000 (+0000) Subject: Always use -Wl,-gc-sections on our build. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=0ea9c06fe0673875fbbe4d3639e53171fea02978 Always use -Wl,-gc-sections on our build. Both bfd ld and gold correctly handle --export-dynamic, so gc-sections is safe even for binaries that support plugins. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220174 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index 284912c19c1..2e6b8247b05 100644 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -141,15 +141,18 @@ function(add_llvm_symbol_exports target_name export_file) endfunction(add_llvm_symbol_exports) function(add_dead_strip target_name) - if(NOT LLVM_NO_DEAD_STRIP) - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + # ld64's implementation of -dead_strip breaks tools that use plugins. + if(NOT LLVM_NO_DEAD_STRIP) set_property(TARGET ${target_name} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-dead_strip") - elseif(NOT WIN32) - # Object files are compiled with -ffunction-data-sections. - set_property(TARGET ${target_name} APPEND_STRING PROPERTY - LINK_FLAGS " -Wl,--gc-sections") endif() + elseif(NOT WIN32) + # Object files are compiled with -ffunction-data-sections. + # On ELF --gc-sections handles --export-dynamic correctly, so we can always + # use it. + set_property(TARGET ${target_name} APPEND_STRING PROPERTY + LINK_FLAGS " -Wl,--gc-sections") endif() endfunction(add_dead_strip)