Skip to content

Commit 083c683

Browse files
tstellarnikic
andauthored
[flang] Add FLANG_PARALLEL_COMPILE_JOBS option (#95672)
This works the same way as LLVM_PARALLEL_COMPILE_JOBS except that it is specific to the flang source rather than for the whole project. Configuring with -DFLANG_PARALLEL_COMPILE_JOBS=1 would mean that there would only ever be one flang source being compiled at a time. Some of the flang sources require large amounts of memory to compile, so this option can be used to avoid OOM erros when compiling those files while still allowing the rest of the project to compile using the maximum number of jobs. --------- Co-authored-by: Nikita Popov <[email protected]>
1 parent 4b9112e commit 083c683

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

flang/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,18 @@ if (APPLE)
445445
endif()
446446
endif()
447447

448+
# Set up job pools for flang. Some of the flang sources take a lot of memory to
449+
# compile, so allow users to limit the number of parallel flang jobs. This is
450+
# useful for building flang alongside several other projects since you can use
451+
# the maximum number of build jobs for the other projects while limiting the
452+
# number of flang compile jobs.
453+
#
454+
# We want this set to infinity by default
455+
set(FLANG_PARALLEL_COMPILE_JOBS 0 CACHE STRING
456+
"The maximum number of concurrent compilation jobs (Ninja only)")
457+
458+
set_property(GLOBAL APPEND PROPERTY JOB_POOLS flang_compile_job_pool=${FLANG_PARALLEL_COMPILE_JOBS})
459+
448460
include(CMakeParseArguments)
449461
include(AddFlang)
450462

flang/cmake/modules/AddFlang.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ function(add_flang_library name)
8989
set_property(GLOBAL APPEND PROPERTY FLANG_LIBS ${name})
9090
endif()
9191
set_property(GLOBAL APPEND PROPERTY FLANG_EXPORTS ${name})
92+
set_property(TARGET obj.${name} PROPERTY JOB_POOL_COMPILE flang_compile_job_pool)
9293
else()
9394
# Add empty "phony" target
9495
add_custom_target(${name})

0 commit comments

Comments
 (0)