[PATCH] D104764: [CMake] Don't LTO optimize targets on Darwin either
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 24 10:02:29 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaac4de989ee9: [CMake] Don't LTO optimize targets on Darwin either (authored by phosek).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104764/new/
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)
+ 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)
+ 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.354287.patch
Type: text/x-patch
Size: 2237 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210624/73e0e550/attachment.bin>
More information about the llvm-commits
mailing list