commit: 0cf9b38183d6704a78598d06b3eb6ffac99539bb Author: Itai Ferber <itai <AT> itaiferber <DOT> net> AuthorDate: Wed Mar 26 17:10:40 2025 +0000 Commit: David Roman <davidroman96 <AT> gmail <DOT> com> CommitDate: Wed Mar 26 19:46:02 2025 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=0cf9b381
dev-lang/swift: respect MAKEOPTS -j The Swift build system takes a '-j'/'--jobs' flag, but the value from MAKEOPTS needs to be manually exposed to it for it to be respected. Closes: https://bugs.gentoo.org/951202 Signed-off-by: Itai Ferber <itai <AT> itaiferber.net> dev-lang/swift/swift-5.10.1-r4.ebuild | 23 +++++++++++++++++++++++ dev-lang/swift/swift-6.0.3-r1.ebuild | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/dev-lang/swift/swift-5.10.1-r4.ebuild b/dev-lang/swift/swift-5.10.1-r4.ebuild index 560efa3cf..9884caaf1 100644 --- a/dev-lang/swift/swift-5.10.1-r4.ebuild +++ b/dev-lang/swift/swift-5.10.1-r4.ebuild @@ -202,6 +202,26 @@ src_compile() { # contents are irrelevant. addpredict /var/lib/portage/home/.swiftpm + # Setting `-j<n>`/`--jobs=<n>` in MAKEOPTS needs to be manually exposed to + # the Swift build system. + local jobs_flag + if [[ -n "${MAKEOPTS}" ]]; then + local num_jobs make_opts=( $(getopt -qu -o 'j:' -l 'jobs:' -- ${MAKEOPTS}) ) + while [[ "${#make_opts[@]}" -gt 1 ]]; do + case "${make_opts[0]}" in + -j | --jobs ) + num_jobs="${make_opts[1]}" + make_opts=("${make_opts[@]:2}") ;; + -- ) break ;; + * ) make_opts=("${make_opts[@]:1}") ;; + esac + done + + if [[ -n "${num_jobs}" ]]; then + jobs_flag="--jobs=${num_jobs}" + fi + fi + local _extra_cmake_options=( # BFD doesn't link Swift symbols properly, so we have to ensure Swift is # built with LLD. @@ -243,6 +263,7 @@ src_compile() { --no-assertions \ --build-subdir="Ninja-Release" \ --install-destdir="${S}/stage0" \ + "${jobs_flag}" \ --extra-cmake-options="${extra_cmake_options}" \ --bootstrapping=off \ --llvm-install-components='llvm-ar;llvm-cov;llvm-profdata;IndexStore;clang;clang-resource-headers;compiler-rt;clangd;lld;LTO;clang-features-file' \ @@ -267,6 +288,7 @@ src_compile() { --no-assertions \ --build-subdir="Ninja-Release" \ --install-destdir="${S}/stage1" \ + "${jobs_flag}" \ --extra-cmake-options="${extra_cmake_options}" \ --cmark --skip-test-cmark \ --foundation --skip-test-foundation \ @@ -290,6 +312,7 @@ src_compile() { --no-assertions \ --build-subdir="Ninja-Release" \ --install-destdir="${S}/stage2" \ + "${jobs_flag}" \ --extra-cmake-options="${extra_cmake_options}" \ --foundation --skip-test-foundation \ --indexstore-db --skip-test-indexstore-db \ diff --git a/dev-lang/swift/swift-6.0.3-r1.ebuild b/dev-lang/swift/swift-6.0.3-r1.ebuild index 09b9b0d65..bfbea3442 100644 --- a/dev-lang/swift/swift-6.0.3-r1.ebuild +++ b/dev-lang/swift/swift-6.0.3-r1.ebuild @@ -182,6 +182,25 @@ src_configure() { cp "${FILESDIR}/${PF}/gentoo.ini" "${SWIFT_BUILD_PRESETS_INI_PATH}" local extra_build_flags=() + # Setting `-j<n>`/`--jobs=<n>` in MAKEOPTS needs to be manually exposed to + # the Swift build system. + if [[ -n "${MAKEOPTS}" ]]; then + local num_jobs make_opts=( $(getopt -qu -o 'j:' -l 'jobs:' -- ${MAKEOPTS}) ) + while [[ "${#make_opts[@]}" -gt 1 ]]; do + case "${make_opts[0]}" in + -j | --jobs ) + num_jobs="${make_opts[1]}" + make_opts=("${make_opts[@]:2}") ;; + -- ) break ;; + * ) make_opts=("${make_opts[@]:1}") ;; + esac + done + + if [[ -n "${num_jobs}" ]]; then + extra_build_flags+=(--jobs="${num_jobs}") + fi + fi + if [[ "$(tc-get-cxx-stdlib)" = 'libc++' ]]; then # On systems which use libc++ as their default C++ stdlib (e.g. systems # with the LLVM profile), we want to build the internal libc++ and
