about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-03-04 17:31:05 +0100
committerGitHub <noreply@github.com>2022-03-04 17:31:05 +0100
commit5115bdc2e2829e9c9a7ce10516bd26469049e0a9 (patch)
tree87a1138d9a25eeb5eae806a30ecff0287051c6d9 /src/bootstrap
parent904c6ca95c65b71715491b9e32f634734661db94 (diff)
parent2d854f9c340df887e30896f49270ae81feb3e227 (diff)
Rollup merge of #94524 - bjorn3:remove_num_cpus, r=Mark-Simulacrum
Remove num_cpus dependency from bootstrap, build-manifest and rustc_s…

…ession

`std::threads::available_parallelism` was stabilized in rust 1.59.

r? ```````````````````````````@Mark-Simulacrum```````````````````````````
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/Cargo.toml1
-rw-r--r--src/bootstrap/config.rs2
-rw-r--r--src/bootstrap/flags.rs2
-rw-r--r--src/bootstrap/lib.rs4
4 files changed, 5 insertions, 4 deletions
diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml
index 592a137e379..02efc08cc79 100644
--- a/src/bootstrap/Cargo.toml
+++ b/src/bootstrap/Cargo.toml
@@ -37,7 +37,6 @@ test = false
 build_helper = { path = "../build_helper" }
 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 d6f77fe6cd6..ce76ccd5755 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -1187,7 +1187,7 @@ fn set<T>(field: &mut T, val: Option<T>) {
 
 fn threads_from_config(v: u32) -> u32 {
     match v {
-        0 => num_cpus::get() as u32,
+        0 => std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32,
         n => n,
     }
 }
diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs
index 9180c5f03af..74528f2752f 100644
--- a/src/bootstrap/flags.rs
+++ b/src/bootstrap/flags.rs
@@ -208,7 +208,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)",
-            num_cpus::get()
+            std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::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 abfac2a5897..a1f0bfd8f26 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -922,7 +922,9 @@ 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(|| num_cpus::get() as u32)
+        self.config.jobs.unwrap_or_else(|| {
+            std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32
+        })
     }
 
     fn debuginfo_map_to(&self, which: GitRepo) -> Option<String> {