[llvm] aac4de9 - [CMake] Don't LTO optimize targets on Darwin either
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 24 10:02:27 PDT 2021
Author: Petr Hosek
Date: 2021-06-24T10:02:03-07:00
New Revision: aac4de989ee98605f1ce918c8e541c9be0f52324
URL: https://github.com/llvm/llvm-project/commit/aac4de989ee98605f1ce918c8e541c9be0f52324
DIFF: https://github.com/llvm/llvm-project/commit/aac4de989ee98605f1ce918c8e541c9be0f52324.diff
LOG: [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
Added:
Modified:
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/HandleLLVMOptions.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 689cac474c1ab..7e91b77adcab2 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -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()
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 8f6625ea85e10..75a8fec29671d 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -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()
More information about the llvm-commits
mailing list