From e765324d89ef702ec287966f5132527d8de67b22 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Fri, 12 Feb 2021 01:55:26 -0800 Subject: [PATCH] [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 --- llvm/cmake/modules/AddLLVM.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index f276d57..da1b78b 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 -- 2.7.4