diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-06-04 04:48:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-04 04:48:29 +0200 |
| commit | 5deaa0af41c33563a55a76abc5f2a1c84556bbd0 (patch) | |
| tree | 853379d18fb3b95cc08c365b0eda32430c1cea4d | |
| parent | 6ad6ef235581e9db4fd5160880b98eedbdc2d488 (diff) | |
| parent | 5ce3c8137b4d29481038d4b322f6db28d946d648 (diff) | |
| download | rust-5deaa0af41c33563a55a76abc5f2a1c84556bbd0.tar.gz rust-5deaa0af41c33563a55a76abc5f2a1c84556bbd0.zip | |
Rollup merge of #61497 - Mark-Simulacrum:codegen-units-std-num-cpus, r=alexcrichton
Treat 0 as special value for codegen-units-std Fixes #57669
| -rw-r--r-- | src/bootstrap/config.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index d618654b129..edeb07fda1d 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -11,7 +11,6 @@ use std::process; use std::cmp; use build_helper::t; -use num_cpus; use toml; use serde::Deserialize; use crate::cache::{INTERNER, Interned}; @@ -401,7 +400,7 @@ impl Config { config.rustc_error_format = flags.rustc_error_format; config.on_fail = flags.on_fail; config.stage = flags.stage; - config.jobs = flags.jobs; + config.jobs = flags.jobs.map(threads_from_config); config.cmd = flags.cmd; config.incremental = flags.incremental; config.dry_run = flags.dry_run; @@ -583,13 +582,8 @@ impl Config { set(&mut config.rust_codegen_backends_dir, rust.codegen_backends_dir.clone()); - match rust.codegen_units { - Some(0) => config.rust_codegen_units = Some(num_cpus::get() as u32), - Some(n) => config.rust_codegen_units = Some(n), - None => {} - } - - config.rust_codegen_units_std = rust.codegen_units_std; + config.rust_codegen_units = rust.codegen_units.map(threads_from_config); + config.rust_codegen_units_std = rust.codegen_units_std.map(threads_from_config); } if let Some(ref t) = toml.target { @@ -688,3 +682,10 @@ fn set<T>(field: &mut T, val: Option<T>) { *field = v; } } + +fn threads_from_config(v: u32) -> u32 { + match v { + 0 => num_cpus::get() as u32, + n => n, + } +} |
