Skip to content

Commit e765324

Browse files
committed
[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
1 parent 3231607 commit e765324

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,18 @@ function(add_unittest test_suite test_name)
14511451
14521452
list(APPEND LLVM_LINK_COMPONENTS Support) # gtest needs it for raw_ostream
14531453
add_llvm_executable(${test_name} IGNORE_EXTERNALIZE_DEBUGINFO NO_INSTALL_RPATH ${ARGN})
1454+
1455+
# The runtime benefits of ThinLTO don't outweight the compile time costs for tests.
1456+
if(uppercase_LLVM_ENABLE_LTO STREQUAL "THIN")
1457+
if((UNIX OR MINGW) AND LLVM_USE_LINKER STREQUAL "lld")
1458+
set_property(TARGET ${test_name} APPEND_STRING PROPERTY
1459+
LINK_FLAGS " -Wl,--lto-O0")
1460+
elseif(LINKER_IS_LLD_LINK)
1461+
set_property(TARGET ${test_name} APPEND_STRING PROPERTY
1462+
LINK_FLAGS " /opt:lldlto=0")
1463+
endif()
1464+
endif()
1465+
14541466
set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
14551467
set_output_directory(${test_name} BINARY_DIR ${outdir} LIBRARY_DIR ${outdir})
14561468
# libpthreads overrides some standard library symbols, so main

0 commit comments

Comments
 (0)