[llvm] e765324 - [CMake] Don't optimize tests so much under ThinLTO
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 22 15:14:09 PST 2021
Author: Arthur Eubanks
Date: 2021-02-22T15:13:49-08:00
New Revision: e765324d89ef702ec287966f5132527d8de67b22
URL: https://github.com/llvm/llvm-project/commit/e765324d89ef702ec287966f5132527d8de67b22
DIFF: https://github.com/llvm/llvm-project/commit/e765324d89ef702ec287966f5132527d8de67b22.diff
LOG: [CMake] Don't optimize tests so much under ThinLTO
This drops check-llvm under -DLLVM_ENABLE_LTO=Thin from 13m to 10m20s on Windows and 20m to 15m35s on Linux.
Reviewed By: hans
Differential Revision: https://reviews.llvm.org/D96618
Added:
Modified:
llvm/cmake/modules/AddLLVM.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index f276d57ca9fe..da1b78b4f530 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1451,6 +1451,18 @@ function(add_unittest test_suite test_name)
list(APPEND LLVM_LINK_COMPONENTS Support) # gtest needs it for raw_ostream
add_llvm_executable(${test_name} IGNORE_EXTERNALIZE_DEBUGINFO NO_INSTALL_RPATH ${ARGN})
+
+ # The runtime benefits of ThinLTO don't outweight the compile time costs for tests.
+ if(uppercase_LLVM_ENABLE_LTO STREQUAL "THIN")
+ if((UNIX OR MINGW) AND LLVM_USE_LINKER STREQUAL "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")
+ endif()
+ endif()
+
set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
set_output_directory(${test_name} BINARY_DIR ${outdir} LIBRARY_DIR ${outdir})
# libpthreads overrides some standard library symbols, so main
More information about the llvm-commits
mailing list