summaryrefslogtreecommitdiffstats
path: root/llvm/cmake/modules/AddLLVM.cmake
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-04-06 15:04:31 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-04-06 15:04:31 +0000
commit24766f909feab25ad770d35ec2aeb93e8e64d1cf (patch)
treebc31e3e80f5c7de021c8a55f73ca89ff1bb8c3ff /llvm/cmake/modules/AddLLVM.cmake
parent1c7fc3e3aee6f1f71065ce516a85bdeed71d5565 (diff)
downloadbcm5719-llvm-24766f909feab25ad770d35ec2aeb93e8e64d1cf.tar.gz
bcm5719-llvm-24766f909feab25ad770d35ec2aeb93e8e64d1cf.zip
Disable all link optimizations in a debug build.
This taking linking clang on my machine with gold from 16.980257914 to 15.933037649 seconds. llvm-svn: 234161
Diffstat (limited to 'llvm/cmake/modules/AddLLVM.cmake')
-rw-r--r--llvm/cmake/modules/AddLLVM.cmake53
1 files changed, 28 insertions, 25 deletions
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index af51f731cee..98db042d564 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -158,35 +158,38 @@ if(NOT WIN32 AND NOT APPLE)
endif()
function(add_link_opts target_name)
- # Pass -O3 to the linker. This enabled different optimizations on different
- # linkers. Don't do it in debug builds since it slows down the linker
- # in a context where the optimizations are not important.
- if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32) AND
- NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
- set_property(TARGET ${target_name} APPEND_STRING PROPERTY
- LINK_FLAGS " -Wl,-O3")
- endif()
-
- if(LLVM_LINKER_IS_GOLD)
- # With gold gc-sections is always safe.
- set_property(TARGET ${target_name} APPEND_STRING PROPERTY
- LINK_FLAGS " -Wl,--gc-sections")
- # Note that there is a bug with -Wl,--icf=safe so it is not safe
- # to enable. See https://sourceware.org/bugzilla/show_bug.cgi?id=17704.
- endif()
+ # Don't use linker optimizations in debug builds since it slows down the
+ # linker in a context where the optimizations are not important.
+ if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
- if(NOT LLVM_NO_DEAD_STRIP)
- if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
- # ld64's implementation of -dead_strip breaks tools that use plugins.
+ # Pass -O3 to the linker. This enabled different optimizations on different
+ # linkers.
+ if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32))
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
- LINK_FLAGS " -Wl,-dead_strip")
- elseif(NOT WIN32 AND NOT LLVM_LINKER_IS_GOLD)
- # Object files are compiled with -ffunction-data-sections.
- # Versions of bfd ld < 2.23.1 have a bug in --gc-sections that breaks
- # tools that use plugins. Always pass --gc-sections once we require
- # a newer linker.
+ LINK_FLAGS " -Wl,-O3")
+ endif()
+
+ if(LLVM_LINKER_IS_GOLD)
+ # With gold gc-sections is always safe.
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--gc-sections")
+ # Note that there is a bug with -Wl,--icf=safe so it is not safe
+ # to enable. See https://sourceware.org/bugzilla/show_bug.cgi?id=17704.
+ endif()
+
+ if(NOT LLVM_NO_DEAD_STRIP)
+ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ # ld64's implementation of -dead_strip breaks tools that use plugins.
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " -Wl,-dead_strip")
+ elseif(NOT WIN32 AND NOT LLVM_LINKER_IS_GOLD)
+ # Object files are compiled with -ffunction-data-sections.
+ # Versions of bfd ld < 2.23.1 have a bug in --gc-sections that breaks
+ # tools that use plugins. Always pass --gc-sections once we require
+ # a newer linker.
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " -Wl,--gc-sections")
+ endif()
endif()
endif()
endfunction(add_link_opts)
OpenPOWER on IntegriCloud