Skip to content

Commit

Permalink
runtime: force runtime.nr_jobs() to return 1, while V is bootstrappin…
Browse files Browse the repository at this point in the history
…g itself, from vc/ source, that was compiled with `-os cross` (fix #22991)
  • Loading branch information
spytheman committed Nov 27, 2024
1 parent aeaf607 commit b67b8bf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions vlib/runtime/runtime.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import os
// then `nr_jobs` will return that number instead.
// This is useful for runtime tweaking of e.g. threaded or concurrent code.
pub fn nr_jobs() int {
$if cross ? {
// A single thread is *more likely* to work consistently everywhere during bootstrapping.
// NB: the compiler itself uses runtime.nr_jobs() and sync.pool to process things in parallel
// in its cgen stage. Returning 1 here, increases the chances of it working on non linux systems.
return 1
}
mut cpus := nr_cpus() - 1
// allow for overrides, for example using `VJOBS=32 ./v test .`
vjobs := os.getenv('VJOBS').int()
Expand Down

0 comments on commit b67b8bf

Please sign in to comment.