Skip to content

Commit

Permalink
Rollup merge of rust-lang#61497 - Mark-Simulacrum:codegen-units-std-n…
Browse files Browse the repository at this point in the history
…um-cpus, r=alexcrichton

Treat 0 as special value for codegen-units-std

Fixes rust-lang#57669
  • Loading branch information
Centril committed Jun 4, 2019
2 parents 994ddbd + 5ce3c81 commit 13d2364
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
}
}

0 comments on commit 13d2364

Please sign in to comment.