Limit parallel link jobs only if ThinLTO *is* enabled

Before it checks only ENABLE_THINLTO flag, which enables ThinLTO only
for RelWithDebInfo.
This commit is contained in:
Azat Khuzhin 2020-12-24 22:51:34 +03:00
parent a16535687e
commit 4c69612fa7
1 changed files with 3 additions and 1 deletions

View File

@ -36,10 +36,12 @@ if (NOT PARALLEL_LINK_JOBS AND AVAILABLE_PHYSICAL_MEMORY AND MAX_LINKER_MEMORY)
endif ()
# ThinLTO provides its own parallel linking
# (which is enabled only for RELWITHDEBINFO)
#
# But use 2 parallel jobs, since:
# - this is what llvm does
# - and I've verfied that lld-11 does not use all available CPU time (in peak) while linking one binary
if (ENABLE_THINLTO AND PARALLEL_LINK_JOBS GREATER 2)
if (CMAKE_BUILD_TYPE_UC STREQUAL "RELWITHDEBINFO" AND ENABLE_THINLTO AND PARALLEL_LINK_JOBS GREATER 2)
message(STATUS "ThinLTO provides its own parallel linking - limiting parallel link jobs to 2.")
set (PARALLEL_LINK_JOBS 2)
endif()