diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/Cargo.toml | 1 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/flags.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/lib.rs | 4 | ||||
| -rw-r--r-- | src/tools/build-manifest/Cargo.toml | 1 | ||||
| -rw-r--r-- | src/tools/build-manifest/src/main.rs | 2 | ||||
| m--------- | src/tools/cargo | 0 |
7 files changed, 6 insertions, 6 deletions
diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index 0e54837610a..f5d9e46f9e2 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -37,6 +37,7 @@ test = false [dependencies] cmake = "0.1.38" filetime = "0.2" +num_cpus = "1.0" getopts = "0.2.19" cc = "1.0.69" libc = "0.2" diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 99b69ee9a4f..28663af135c 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -1418,7 +1418,7 @@ fn set<T>(field: &mut T, val: Option<T>) { fn threads_from_config(v: u32) -> u32 { match v { - 0 => std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32, + 0 => num_cpus::get() as u32, n => n, } } diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index f692ff72d4e..9d4bb978bdc 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -210,7 +210,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`", let j_msg = format!( "number of jobs to run in parallel; \ defaults to {} (this host's logical CPU count)", - std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) + num_cpus::get() ); opts.optopt("j", "jobs", &j_msg, "JOBS"); opts.optflag("h", "help", "print this help message"); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 022f2e0fc13..b4333566f07 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -1032,9 +1032,7 @@ impl Build { /// Returns the number of parallel jobs that have been configured for this /// build. fn jobs(&self) -> u32 { - self.config.jobs.unwrap_or_else(|| { - std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32 - }) + self.config.jobs.unwrap_or_else(|| num_cpus::get() as u32) } fn debuginfo_map_to(&self, which: GitRepo) -> Option<String> { diff --git a/src/tools/build-manifest/Cargo.toml b/src/tools/build-manifest/Cargo.toml index c437bde5ae6..c022d3aa0ac 100644 --- a/src/tools/build-manifest/Cargo.toml +++ b/src/tools/build-manifest/Cargo.toml @@ -13,3 +13,4 @@ tar = "0.4.29" sha2 = "0.10.1" rayon = "1.5.1" hex = "0.4.2" +num_cpus = "1.13.0" diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index a1dfbef0601..6338e467055 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -210,7 +210,7 @@ fn main() { let num_threads = if let Some(num) = env::var_os("BUILD_MANIFEST_NUM_THREADS") { num.to_str().unwrap().parse().expect("invalid number for BUILD_MANIFEST_NUM_THREADS") } else { - std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) + num_cpus::get() }; rayon::ThreadPoolBuilder::new() .num_threads(num_threads) diff --git a/src/tools/cargo b/src/tools/cargo -Subproject 85e457e158db216a2938d51bc3b617a5a7fe601 +Subproject 4d92f07f34ba7fb7d7f207564942508f46c225d |
