Skip to content

Commit b67b8bf

Browse files
committed
runtime: force runtime.nr_jobs() to return 1, while V is bootstrapping itself, from vc/ source, that was compiled with -os cross (fix #22991)
1 parent aeaf607 commit b67b8bf

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

vlib/runtime/runtime.v

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ import os
1111
// then `nr_jobs` will return that number instead.
1212
// This is useful for runtime tweaking of e.g. threaded or concurrent code.
1313
pub fn nr_jobs() int {
14+
$if cross ? {
15+
// A single thread is *more likely* to work consistently everywhere during bootstrapping.
16+
// NB: the compiler itself uses runtime.nr_jobs() and sync.pool to process things in parallel
17+
// in its cgen stage. Returning 1 here, increases the chances of it working on non linux systems.
18+
return 1
19+
}
1420
mut cpus := nr_cpus() - 1
1521
// allow for overrides, for example using `VJOBS=32 ./v test .`
1622
vjobs := os.getenv('VJOBS').int()

0 commit comments

Comments
 (0)