From ac5c9632b0f8255ad3f1584a31bc7a0ce9b7457b Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sun, 6 Apr 2025 19:50:28 +0200 Subject: [PATCH] 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. --- Documentation/BuildInstructionsLadybird.md | 11 +++++++++++ Meta/CMake/lagom_options.cmake | 1 + Meta/CMake/use_linker.cmake | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/Documentation/BuildInstructionsLadybird.md b/Documentation/BuildInstructionsLadybird.md index 624280b8b97..97d8e679a95 100644 --- a/Documentation/BuildInstructionsLadybird.md +++ b/Documentation/BuildInstructionsLadybird.md @@ -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. diff --git a/Meta/CMake/lagom_options.cmake b/Meta/CMake/lagom_options.cmake index c7ad2d30337..aaeded5d60c 100644 --- a/Meta/CMake/lagom_options.cmake +++ b/Meta/CMake/lagom_options.cmake @@ -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) diff --git a/Meta/CMake/use_linker.cmake b/Meta/CMake/use_linker.cmake index 8909c57c6a3..904fbe169c7 100644 --- a/Meta/CMake/use_linker.cmake +++ b/Meta/CMake/use_linker.cmake @@ -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()