[PATCH] D104764: [CMake] Don't LTO optimize targets on Darwin either
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 23 00:52:06 PDT 2021
phosek created this revision.
phosek added a reviewer: smeenai.
Herald added subscribers: mstorsjo, inglorion, mgorny.
phosek requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This is a follow up to D102732 <https://reviews.llvm.org/D102732> which also expands the logic to Darwin.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D104764
Files:
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/HandleLLVMOptions.cmake
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -14,6 +14,12 @@
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()
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -225,12 +225,15 @@
# 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 AND NOT LINKER_IS_LLD)
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " -Wl,-mllvm,-O0")
endif()
endif()
endif()
@@ -1458,12 +1461,15 @@
# 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 AND NOT LINKER_IS_LLD)
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " -Wl,-mllvm,-O0")
endif()
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104764.353867.patch
Type: text/x-patch
Size: 2281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210623/dc461527/attachment.bin>
More information about the llvm-commits
mailing list