Skip to content

Commit 13d2364

Browse files
authored
Rollup merge of rust-lang#61497 - Mark-Simulacrum:codegen-units-std-num-cpus, r=alexcrichton
Treat 0 as special value for codegen-units-std Fixes rust-lang#57669
2 parents 994ddbd + 5ce3c81 commit 13d2364

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Diff for: src/bootstrap/config.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use std::process;
1111
use std::cmp;
1212

1313
use build_helper::t;
14-
use num_cpus;
1514
use toml;
1615
use serde::Deserialize;
1716
use crate::cache::{INTERNER, Interned};
@@ -401,7 +400,7 @@ impl Config {
401400
config.rustc_error_format = flags.rustc_error_format;
402401
config.on_fail = flags.on_fail;
403402
config.stage = flags.stage;
404-
config.jobs = flags.jobs;
403+
config.jobs = flags.jobs.map(threads_from_config);
405404
config.cmd = flags.cmd;
406405
config.incremental = flags.incremental;
407406
config.dry_run = flags.dry_run;
@@ -583,13 +582,8 @@ impl Config {
583582

584583
set(&mut config.rust_codegen_backends_dir, rust.codegen_backends_dir.clone());
585584

586-
match rust.codegen_units {
587-
Some(0) => config.rust_codegen_units = Some(num_cpus::get() as u32),
588-
Some(n) => config.rust_codegen_units = Some(n),
589-
None => {}
590-
}
591-
592-
config.rust_codegen_units_std = rust.codegen_units_std;
585+
config.rust_codegen_units = rust.codegen_units.map(threads_from_config);
586+
config.rust_codegen_units_std = rust.codegen_units_std.map(threads_from_config);
593587
}
594588

595589
if let Some(ref t) = toml.target {
@@ -688,3 +682,10 @@ fn set<T>(field: &mut T, val: Option<T>) {
688682
*field = v;
689683
}
690684
}
685+
686+
fn threads_from_config(v: u32) -> u32 {
687+
match v {
688+
0 => num_cpus::get() as u32,
689+
n => n,
690+
}
691+
}

0 commit comments

Comments
 (0)