Skip to content

Commit 2e5ec1c

Browse files
tstellarnikicMeinersbur
authored
[flang] Add FLANG_PARALLEL_COMPILE_JOBS option (#127364)
This is a re-apply of 083c683 with a fix for the flang runtime build. 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. Update flang/CMakeLists.txt --------- Co-authored-by: Nikita Popov <[email protected]> Co-authored-by: Michael Kruse <[email protected]>
1 parent 0ba391a commit 2e5ec1c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

flang/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,17 @@ if (APPLE)
467467
endif()
468468
endif()
469469

470+
# Set up job pools for flang. Some of the flang sources take a lot of memory to
471+
# compile, so allow users to limit the number of parallel flang jobs. This is
472+
# useful for building flang alongside several other projects since you can use
473+
# the maximum number of build jobs for the other projects while limiting the
474+
# number of flang compile jobs.
475+
set(FLANG_PARALLEL_COMPILE_JOBS CACHE STRING
476+
"The maximum number of concurrent compilation jobs for Flang (Ninja only)")
477+
if (FLANG_PARALLEL_COMPILE_JOBS)
478+
set_property(GLOBAL APPEND PROPERTY JOB_POOLS flang_compile_job_pool=${FLANG_PARALLEL_COMPILE_JOBS})
479+
endif()
480+
470481
include(AddFlang)
471482
include(FlangCommon)
472483

flang/cmake/modules/AddFlang.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ function(add_flang_library name)
9494
set_property(GLOBAL APPEND PROPERTY FLANG_LIBS ${name})
9595
endif()
9696
set_property(GLOBAL APPEND PROPERTY FLANG_EXPORTS ${name})
97+
if (FLANG_PARALLEL_COMPILE_JOBS)
98+
set_property(TARGET ${name} PROPERTY JOB_POOL_COMPILE flang_compile_job_pool)
99+
endif()
97100
else()
98101
# Add empty "phony" target
99102
add_custom_target(${name})

0 commit comments

Comments
 (0)