[flang-commits] [flang] 2e5ec1c - [flang] Add FLANG_PARALLEL_COMPILE_JOBS option (#127364)
via flang-commits
flang-commits at lists.llvm.org
Thu Feb 20 11:29:58 PST 2025
Author: Tom Stellard
Date: 2025-02-20T11:29:54-08:00
New Revision: 2e5ec1cc5b8ef30f04f53d927860184acf7150b3
URL: https://github.com/llvm/llvm-project/commit/2e5ec1cc5b8ef30f04f53d927860184acf7150b3
DIFF: https://github.com/llvm/llvm-project/commit/2e5ec1cc5b8ef30f04f53d927860184acf7150b3.diff
LOG: [flang] Add FLANG_PARALLEL_COMPILE_JOBS option (#127364)
This is a re-apply of 083c683969b2436afdc45becadc955841f5f4d31 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 <github at npopov.com>
Co-authored-by: Michael Kruse <github at meinersbur.de>
Added:
Modified:
flang/CMakeLists.txt
flang/cmake/modules/AddFlang.cmake
Removed:
################################################################################
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index ac8f784fd811e..4b703b456cae2 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -467,6 +467,17 @@ if (APPLE)
endif()
endif()
+# Set up job pools for flang. Some of the flang sources take a lot of memory to
+# compile, so allow users to limit the number of parallel flang jobs. This is
+# useful for building flang alongside several other projects since you can use
+# the maximum number of build jobs for the other projects while limiting the
+# number of flang compile jobs.
+set(FLANG_PARALLEL_COMPILE_JOBS CACHE STRING
+ "The maximum number of concurrent compilation jobs for Flang (Ninja only)")
+if (FLANG_PARALLEL_COMPILE_JOBS)
+ set_property(GLOBAL APPEND PROPERTY JOB_POOLS flang_compile_job_pool=${FLANG_PARALLEL_COMPILE_JOBS})
+endif()
+
include(AddFlang)
include(FlangCommon)
diff --git a/flang/cmake/modules/AddFlang.cmake b/flang/cmake/modules/AddFlang.cmake
index badbd4e7b964b..ca233103ccdbe 100644
--- a/flang/cmake/modules/AddFlang.cmake
+++ b/flang/cmake/modules/AddFlang.cmake
@@ -94,6 +94,9 @@ function(add_flang_library name)
set_property(GLOBAL APPEND PROPERTY FLANG_LIBS ${name})
endif()
set_property(GLOBAL APPEND PROPERTY FLANG_EXPORTS ${name})
+ if (FLANG_PARALLEL_COMPILE_JOBS)
+ set_property(TARGET ${name} PROPERTY JOB_POOL_COMPILE flang_compile_job_pool)
+ endif()
else()
# Add empty "phony" target
add_custom_target(${name})
More information about the flang-commits
mailing list