From a16535687e088cf71727bc263a561d70f7022bb8 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 24 Dec 2020 22:52:39 +0300 Subject: [PATCH 1/2] Fix typo for parallel link jobs condition --- cmake/limit_jobs.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/limit_jobs.cmake b/cmake/limit_jobs.cmake index 241fa509477..701f34f8dbd 100644 --- a/cmake/limit_jobs.cmake +++ b/cmake/limit_jobs.cmake @@ -44,7 +44,7 @@ if (ENABLE_THINLTO AND PARALLEL_LINK_JOBS GREATER 2) set (PARALLEL_LINK_JOBS 2) endif() -if (PARALLEL_LINK_JOBS AND (NOT NUMBER_OF_LOGICAL_CORES OR PARALLEL_COMPILE_JOBS LESS NUMBER_OF_LOGICAL_CORES)) +if (PARALLEL_LINK_JOBS AND (NOT NUMBER_OF_LOGICAL_CORES OR PARALLEL_LINK_JOBS LESS NUMBER_OF_LOGICAL_CORES)) set(CMAKE_JOB_POOL_LINK link_job_pool${CMAKE_CURRENT_SOURCE_DIR}) string (REGEX REPLACE "[^a-zA-Z0-9]+" "_" CMAKE_JOB_POOL_LINK ${CMAKE_JOB_POOL_LINK}) set_property(GLOBAL APPEND PROPERTY JOB_POOLS ${CMAKE_JOB_POOL_LINK}=${PARALLEL_LINK_JOBS}) From 4c69612fa7c24b01bda3a81edfce186114d20ad9 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 24 Dec 2020 22:51:34 +0300 Subject: [PATCH 2/2] Limit parallel link jobs only if ThinLTO *is* enabled Before it checks only ENABLE_THINLTO flag, which enables ThinLTO only for RelWithDebInfo. --- cmake/limit_jobs.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/limit_jobs.cmake b/cmake/limit_jobs.cmake index 701f34f8dbd..b85260e6c76 100644 --- a/cmake/limit_jobs.cmake +++ b/cmake/limit_jobs.cmake @@ -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()