internal/rosa: respect preferred job count
All checks were successful
Test / Create distribution (push) Successful in 3m52s
Test / Sandbox (push) Successful in 9m15s
Test / ShareFS (push) Successful in 14m28s
Test / Sandbox (race detector) (push) Successful in 5m18s
Test / Hakurei (push) Successful in 8m11s
Test / Hakurei (race detector) (push) Successful in 9m23s
Test / Flake checks (push) Successful in 3m23s

This discontinues use of nproc, and also overrides detection behaviour in ninja.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-04-15 16:18:02 +09:00
parent 3352bb975b
commit 520c36db6d
11 changed files with 28 additions and 19 deletions

View File

@@ -91,7 +91,7 @@ index 2ead810437..f85cbb8b1c 100644
ConfigureName: "/usr/src/cmake/bootstrap", ConfigureName: "/usr/src/cmake/bootstrap",
Configure: []KV{ Configure: []KV{
{"prefix", "/system"}, {"prefix", "/system"},
{"parallel", `"$(nproc)"`}, {"parallel", jobsE},
{"--"}, {"--"},
{"-DCMAKE_USE_OPENSSL", "OFF"}, {"-DCMAKE_USE_OPENSSL", "OFF"},
{"-DCMake_TEST_NO_NETWORK", "ON"}, {"-DCMake_TEST_NO_NETWORK", "ON"},
@@ -170,10 +170,8 @@ func (attr *CMakeHelper) script(name string) string {
} }
generate := "Ninja" generate := "Ninja"
jobs := ""
if attr.Make { if attr.Make {
generate = "'Unix Makefiles'" generate = "'Unix Makefiles'"
jobs += ` "--parallel=$(nproc)"`
} }
return ` return `
@@ -191,7 +189,7 @@ cmake -G ` + generate + ` \
}), " \\\n\t") + ` \ }), " \\\n\t") + ` \
-DCMAKE_INSTALL_PREFIX=/system \ -DCMAKE_INSTALL_PREFIX=/system \
'/usr/src/` + name + `/` + filepath.Join(attr.Append...) + `' '/usr/src/` + name + `/` + filepath.Join(attr.Append...) + `'
cmake --build .` + jobs + ` cmake --build . --parallel=` + jobsE + `
cmake --install . --prefix=/work/system cmake --install . --prefix=/work/system
` + attr.Script ` + attr.Script
} }

View File

@@ -15,7 +15,7 @@ func (t Toolchain) newCurl() (pkg.Artifact, string) {
// remove broken test // remove broken test
Writable: true, Writable: true,
ScriptEarly: ` ScriptEarly: `
chmod +w tests/data && rm tests/data/test459 chmod +w tests/data && rm -f tests/data/test459
`, `,
}, &MakeHelper{ }, &MakeHelper{
Configure: []KV{ Configure: []KV{
@@ -25,7 +25,7 @@ chmod +w tests/data && rm tests/data/test459
{"disable-smb"}, {"disable-smb"},
}, },
Check: []string{ Check: []string{
`TFLAGS="-j$(expr "$(nproc)" '*' 2)"`, "TFLAGS=" + jobsLFlagE,
"test-nonflaky", "test-nonflaky",
}, },
}, },

View File

@@ -58,7 +58,7 @@ disable_test t2200-add-update
"prove", "prove",
}, },
Install: `make \ Install: `make \
"-j$(nproc)" \ ` + jobsFlagE + ` \
DESTDIR=/work \ DESTDIR=/work \
NO_INSTALL_HARDLINKS=1 \ NO_INSTALL_HARDLINKS=1 \
install`, install`,

View File

@@ -103,7 +103,7 @@ func (t Toolchain) newAutoconf() (pkg.Artifact, string) {
Flag: TExclusive, Flag: TExclusive,
}, &MakeHelper{ }, &MakeHelper{
Check: []string{ Check: []string{
`TESTSUITEFLAGS="-j$(nproc)"`, "TESTSUITEFLAGS=" + jobsFlagE,
"check", "check",
}, },
}, },
@@ -185,7 +185,7 @@ func (t Toolchain) newLibtool() (pkg.Artifact, string) {
pkg.TarGzip, pkg.TarGzip,
), nil, &MakeHelper{ ), nil, &MakeHelper{
Check: []string{ Check: []string{
`TESTSUITEFLAGS="-j$(nproc)"`, "TESTSUITEFLAGS=" + jobsFlagE,
"check", "check",
}, },
}, },
@@ -732,7 +732,7 @@ func (t Toolchain) newTar() (pkg.Artifact, string) {
// very expensive // very expensive
"TARTEST_SKIP_LARGE_FILES=1", "TARTEST_SKIP_LARGE_FILES=1",
`TESTSUITEFLAGS="-j$(nproc)"`, "TESTSUITEFLAGS=" + jobsFlagE,
"check", "check",
}, },
}, },

View File

@@ -1221,7 +1221,7 @@ install -Dm0500 \
/sbin/depmod /sbin/depmod
make \ make \
"-j$(nproc)" \ ` + jobsFlagE + ` \
-f /usr/src/kernel/Makefile \ -f /usr/src/kernel/Makefile \
O=/tmp/kbuild \ O=/tmp/kbuild \
LLVM=1 \ LLVM=1 \
@@ -1309,7 +1309,7 @@ func (t Toolchain) newFirmware() (pkg.Artifact, string) {
"install-zst", "install-zst",
}, },
SkipCheck: true, // requires pre-commit SkipCheck: true, // requires pre-commit
Install: `make "-j$(nproc)" DESTDIR=/work/system dedup`, Install: "make " + jobsFlagE + " DESTDIR=/work/system dedup",
}, },
Parallel, Parallel,
Rdfind, Rdfind,

View File

@@ -190,7 +190,7 @@ ln -s ld.lld /work/system/bin/ld
ln -s clang /work/system/bin/cc ln -s clang /work/system/bin/cc
ln -s clang++ /work/system/bin/c++ ln -s clang++ /work/system/bin/c++
ninja check-all ninja ` + jobsFlagE + ` check-all
`, `,
}, },
Python, Python,
@@ -230,7 +230,7 @@ func (t Toolchain) newLibclc() (pkg.Artifact, string) {
{"LIBCLC_TARGETS_TO_BUILD", "all"}, {"LIBCLC_TARGETS_TO_BUILD", "all"},
}, },
Script: "ninja test", Script: "ninja " + jobsFlagE + " test",
}), llvmVersion }), llvmVersion
} }
func init() { func init() {

View File

@@ -185,7 +185,7 @@ func (attr *MakeHelper) script(name string) string {
scriptMake := ` scriptMake := `
make \ make \
"-j$(nproc)"` ` + jobsFlagE
if len(attr.Make) > 0 { if len(attr.Make) > 0 {
scriptMake += " \\\n\t" + strings.Join(attr.Make, " \\\n\t") scriptMake += " \\\n\t" + strings.Join(attr.Make, " \\\n\t")
} }
@@ -193,7 +193,7 @@ make \
if !attr.SkipCheck { if !attr.SkipCheck {
scriptMake += attr.ScriptCheckEarly + `make \ scriptMake += attr.ScriptCheckEarly + `make \
"-j$(nproc)" \ ` + jobsFlagE + ` \
` `
if len(attr.Check) > 0 { if len(attr.Check) > 0 {
scriptMake += strings.Join(attr.Check, " \\\n\t") scriptMake += strings.Join(attr.Check, " \\\n\t")

View File

@@ -15,7 +15,7 @@ cd "$(mktemp -d)"
python3 /usr/src/ninja/configure.py \ python3 /usr/src/ninja/configure.py \
--bootstrap \ --bootstrap \
--gtest-source-dir=/usr/src/googletest --gtest-source-dir=/usr/src/googletest
./ninja all ./ninja `+jobsFlagE+` all
./ninja_test ./ninja_test
mkdir -p /work/system/bin/ mkdir -p /work/system/bin/

View File

@@ -27,7 +27,7 @@ func (t Toolchain) newOpenSSL() (pkg.Artifact, string) {
{"openssldir", "etc/ssl"}, {"openssldir", "etc/ssl"},
}, },
Check: []string{ Check: []string{
`HARNESS_JOBS="$(expr "$(nproc)" '*' 2)"`, "HARNESS_JOBS=" + jobsLE,
"test", "test",
}, },
}, },

View File

@@ -43,7 +43,7 @@ rm -f /system/bin/ps # perl does not like toybox ps
{"Duseshrplib"}, {"Duseshrplib"},
}, },
Check: []string{ Check: []string{
"TEST_JOBS=256", "TEST_JOBS=" + jobsLE,
"test_harness", "test_harness",
}, },
Install: `LD_LIBRARY_PATH="$PWD" ./perl -Ilib -I. installperl --destdir=/work`, Install: `LD_LIBRARY_PATH="$PWD" ./perl -Ilib -I. installperl --destdir=/work`,

View File

@@ -602,6 +602,17 @@ cd '/usr/src/` + name + `/'
) )
} }
const (
// jobsE is expression for preferred job count set by [pkg].
jobsE = `"$` + pkg.EnvJobs + `"`
// jobsE is expression for flag with preferred job count.
jobsFlagE = `"-j$` + pkg.EnvJobs + `"`
// jobsLE is expression for twice of preferred job count set by [pkg].
jobsLE = `"$(expr ` + jobsE + ` '*' 2)"`
// jobsE is expression for flag with double of preferred job count.
jobsLFlagE = `"-j$(expr ` + jobsE + ` '*' 2)"`
)
// newTar wraps [pkg.NewHTTPGetTar] with a simpler function signature. // newTar wraps [pkg.NewHTTPGetTar] with a simpler function signature.
func newTar(url, checksum string, compression uint32) pkg.Artifact { func newTar(url, checksum string, compression uint32) pkg.Artifact {
return pkg.NewHTTPGetTar(nil, url, mustDecode(checksum), compression) return pkg.NewHTTPGetTar(nil, url, mustDecode(checksum), compression)