about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-08-15 18:27:37 +0000
committerbors <bors@rust-lang.org>2022-08-15 18:27:37 +0000
commit40336865fe7d4a01139a3336639c6971647e885c (patch)
treec4a707523bfd7a0b4c4cc5f9da41862e2a885975 /src/bootstrap
parent9b4ea391a132ec5f5de40079597ab7ff2fd691ad (diff)
parente65de39763cc516a92c768c5644d7f86e973fb24 (diff)
Auto merge of #100595 - matthiaskrgr:rollup-f1zur58, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #100031 (improve "try ignoring the field" diagnostic)
 - #100325 (Rustdoc-Json: Don't remove impls for items imported from private modules)
 - #100377 (Replace - with _ in fluent slugs to improve developer workflows)
 - #100458 (Adjust span of fn argument declaration)
 - #100514 (Delay span bug when failing to normalize negative coherence impl subject due to other malformed impls)
 - #100528 (Support 1st group of RISC-V Bitmanip backend target features)
 - #100559 (Parser simplifications)
 - #100568 (Fix STD build for ESP-IDF)
 - #100582 ([rustdoc] Fix handling of stripped enum variant in JSON output format)
 - #100586 (Reland changes replacing num_cpus with available_parallelism )

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/Cargo.lock1
-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
5 files changed, 5 insertions, 5 deletions
diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock
index 664ffa1ddd2..84c06fdce70 100644
--- a/src/bootstrap/Cargo.lock
+++ b/src/bootstrap/Cargo.lock
@@ -53,7 +53,6 @@ dependencies = [
  "hex",
  "ignore",
  "libc",
- "num_cpus",
  "once_cell",
  "opener",
  "pretty_assertions",
diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml
index 84f6aaf99c1..2dad41bb18f 100644
--- a/src/bootstrap/Cargo.toml
+++ b/src/bootstrap/Cargo.toml
@@ -38,7 +38,6 @@ test = false
 cmake = "0.1.38"
 fd-lock = "3.0.6"
 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 c4983accc68..203db2d3876 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -1465,7 +1465,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 1edb513f0b6..789da748100 100644
--- a/src/bootstrap/flags.rs
+++ b/src/bootstrap/flags.rs
@@ -220,7 +220,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 a242243aaaf..dcfa92d1004 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -1008,7 +1008,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> {