Meta: Add a link job pool with a configurable size

Parallel linking (esp. with bfd) uses a huge chunk of memory, make it
possible for users to limit the number of link jobs to at least
limit the pain.
This commit is contained in:
Ali Mohammad Pur 2025-04-06 19:50:28 +02:00
parent 408f9f3dde
commit ac5c9632b0
3 changed files with 17 additions and 0 deletions

View file

@ -279,6 +279,17 @@ cmake --build --preset default MyBuildDir
ninja -C MyBuildDir run-ladybird
```
### Building with limited system memory
The default build mode will run as many build steps in parallel as possible, which includes link steps;
this may be an issue for users with limited system memory (or users building with fat LTO in general).
If you wish to reduce the number of parallel link jobs, you may use the LAGOM_LINK_POOL_SIZE cmake option
to set a maximum limit for the number of parallel link jobs.
```
cmake --preset default -B MyBuildDir -DLAGOM_LINK_POOL_SIZE=2
```
### Running manually
The Meta/ladybird.sh script will execute the `run-ladybird` and `debug-ladybird` custom targets.

View file

@ -13,6 +13,7 @@ serenity_option(ENABLE_FUZZERS_OSSFUZZ OFF CACHE BOOL "Build OSS-Fuzz compatible
serenity_option(LAGOM_TOOLS_ONLY OFF CACHE BOOL "Don't build libraries, utilities and tests, only host build tools")
serenity_option(ENABLE_LAGOM_CCACHE ON CACHE BOOL "Enable ccache for Lagom builds")
serenity_option(LAGOM_USE_LINKER "" CACHE STRING "The linker to use (e.g. lld, mold) instead of the system default")
serenity_option(LAGOM_LINK_POOL_SIZE "" CACHE STRING "The maximum number of parallel jobs to use for linking")
serenity_option(ENABLE_LAGOM_COVERAGE_COLLECTION OFF CACHE STRING "Enable code coverage instrumentation for lagom binaries in clang")
if (ANDROID OR APPLE)

View file

@ -30,3 +30,8 @@ if (LAGOM_USE_LINKER)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LINKER_FLAG}")
endif()
endif()
if (LAGOM_LINK_POOL_SIZE)
set_property(GLOBAL PROPERTY JOB_POOLS link_pool=${LAGOM_LINK_POOL_SIZE})
set(CMAKE_JOB_POOL_LINK link_pool CACHE STRING "Linking job pool")
endif()