forked from OSchip/llvm-project
[CMake] Don't LTO optimize targets on Darwin either
This is a follow up to D102732 which also expands the logic to Darwin. Differential Revision: https://reviews.llvm.org/D104764
This commit is contained in:
parent
631362665c
commit
aac4de989e
|
@ -225,12 +225,15 @@ function(add_link_opts target_name)
|
|||
# We may consider avoiding LTO altogether by using -fembed-bitcode
|
||||
# and teaching the linker to select machine code from .o files, see
|
||||
# https://lists.llvm.org/pipermail/llvm-dev/2021-April/149843.html
|
||||
if((UNIX OR MINGW) AND LLVM_USE_LINKER STREQUAL "lld")
|
||||
if((UNIX OR MINGW) AND LINKER_IS_LLD)
|
||||
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
|
||||
LINK_FLAGS " -Wl,--lto-O0")
|
||||
elseif(LINKER_IS_LLD_LINK)
|
||||
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
|
||||
LINK_FLAGS " /opt:lldlto=0")
|
||||
elseif(APPLE)
|
||||
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
|
||||
LINK_FLAGS " -Wl,-mllvm,-O0")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
@ -1458,12 +1461,15 @@ function(add_unittest test_suite test_name)
|
|||
|
||||
# The runtime benefits of LTO don't outweight the compile time costs for tests.
|
||||
if(LLVM_ENABLE_LTO)
|
||||
if((UNIX OR MINGW) AND LLVM_USE_LINKER STREQUAL "lld")
|
||||
if((UNIX OR MINGW) AND LINKER_IS_LLD)
|
||||
set_property(TARGET ${test_name} APPEND_STRING PROPERTY
|
||||
LINK_FLAGS " -Wl,--lto-O0")
|
||||
elseif(LINKER_IS_LLD_LINK)
|
||||
set_property(TARGET ${test_name} APPEND_STRING PROPERTY
|
||||
LINK_FLAGS " /opt:lldlto=0")
|
||||
elseif(APPLE)
|
||||
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
|
||||
LINK_FLAGS " -Wl,-mllvm,-O0")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -14,6 +14,12 @@ include(CheckSymbolExists)
|
|||
include(CMakeDependentOption)
|
||||
include(LLVMProcessSources)
|
||||
|
||||
if(CMAKE_LINKER MATCHES ".*lld" OR (LLVM_USE_LINKER STREQUAL "lld" OR LLVM_ENABLE_LLD))
|
||||
set(LINKER_IS_LLD TRUE)
|
||||
else()
|
||||
set(LINKER_IS_LLD FALSE)
|
||||
endif()
|
||||
|
||||
if(CMAKE_LINKER MATCHES "lld-link" OR (MSVC AND (LLVM_USE_LINKER STREQUAL "lld" OR LLVM_ENABLE_LLD)))
|
||||
set(LINKER_IS_LLD_LINK TRUE)
|
||||
else()
|
||||
|
|
Loading…
Reference in New Issue