[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
This commit is contained in:
Arthur Eubanks 2021-02-12 01:55:26 -08:00
parent 3231607ce9
commit e765324d89
1 changed files with 12 additions and 0 deletions

View File

@ -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