Repository navigation
fix(cmake): cap BoringSSL parallel build jobs - #2000
AustinBenoit wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the BoringSSL build process in cmake/external_rules.cmake to cap parallel build jobs using the CMAKE_BUILD_PARALLEL_LEVEL environment variable or the number of logical cores, avoiding process exhaustion. The review feedback suggests a more robust validation of the core count using a regular expression match instead of the LESS operator to prevent potential CMake configure-time errors if the host system information query fails.
| if(NOT boringssl_build_jobs OR boringssl_build_jobs LESS 1) | ||
| set(boringssl_build_jobs 1) | ||
| endif() |
There was a problem hiding this comment.
Using LESS on a potentially empty or non-numeric string (e.g., if cmake_host_system_information fails or returns an unexpected string) can cause CMake configure-time errors. A more robust approach is to use a regular expression match to verify that boringssl_build_jobs is a valid positive integer, falling back to 1 otherwise.
if(NOT boringssl_build_jobs MATCHES "^[1-9][0-9]*$")
set(boringssl_build_jobs 1)
endif()
Summary
Replace the unbounded
make -jinvocation when building BoringSSL incmake/external_rules.cmakewith a boundedcmake --build ... --parallel <N>.Why
When
firebase-unity-sdkbuilds macOS multi-arch (x86_64andarm64concurrently viabuild_zips.py), both CMake configures invokebuild_external_dependencies()at the same time. WithCMAKE_GENERATOR="Unix Makefiles", passing bare-j(unlimited jobs) to GNUmakecauses both BoringSSLcryptobuilds to spawn hundreds of concurrentcc/clangprocesses simultaneously, intermittently exhausting macOSRLIMIT_NPROC:Example failure: https://github.com/firebase/firebase-unity-sdk/actions/runs/47056656196/job/144081787558
Changes
cmake/external_rules.cmake(build_external_dependencies), determineboringssl_build_jobsfrom:ENV{CMAKE_BUILD_PARALLEL_LEVEL}if set to a positive integer (preserved beforeenv -istrips the child environment), otherwisecmake_host_system_information(RESULT boringssl_build_jobs QUERY NUMBER_OF_LOGICAL_CORES)(falling back to1if unavailable).--parallel ${boringssl_build_jobs}directly tocmake --build(supported across Makefiles, Ninja, Xcode, and MSBuild in CMake 3.12+; project requires 3.22+) instead of forwarding bare-jtoUnix Makefiles.Verification
cmake/external_rules.cmakeparsing andCMAKE_BUILD_PARALLEL_LEVELoverride / fallback logic locally withcmake -P.firebase-cpp-sdkPR CI (Desktop Builds,Android Builds,iOS Builds,Lint): https://github.com/firebase/firebase-cpp-sdk/actions/runs/47152418165firebase-unity-sdkmacOS multi-arch build (build_starter.yml,platforms=macOS,firebase_cpp_sdk_version=fix/boringssl-parallel-cap): https://github.com/firebase/firebase-unity-sdk/actions/runs/47152601720