diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index be28975c3ea..92a57630ca5 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -170,6 +170,11 @@ pub struct Build { fail_fast: bool, verbosity: usize, + // Targets for which to build. + build: String, + hosts: Vec, + targets: Vec, + // Stage 0 (downloaded) compiler and cargo or their local rust equivalents. initial_rustc: PathBuf, initial_cargo: PathBuf, @@ -243,6 +248,27 @@ impl Build { let cargo_info = channel::GitInfo::new(&src.join("src/tools/cargo")); let rls_info = channel::GitInfo::new(&src.join("src/tools/rls")); + let hosts = if !flags.host.is_empty() { + for host in flags.host.iter() { + if !config.host.contains(host) { + panic!("specified host `{}` is not in configuration", host); + } + } + flags.host.clone() + } else { + config.host.clone() + }; + let targets = if !flags.target.is_empty() { + for target in flags.target.iter() { + if !config.target.contains(target) { + panic!("specified target `{}` is not in configuration", target); + } + } + flags.target.clone() + } else { + config.target.clone() + }; + Build { initial_rustc: config.initial_rustc.clone(), initial_cargo: config.initial_cargo.clone(), @@ -250,6 +276,10 @@ impl Build { fail_fast: flags.cmd.fail_fast(), verbosity: cmp::max(flags.verbose, config.verbose), + build: config.host[0].clone(), + hosts: hosts, + targets: targets, + flags: flags, config: config, src: src, @@ -269,6 +299,12 @@ impl Build { } } + fn build_slice(&self) -> &[String] { + unsafe { + std::slice::from_raw_parts(&self.build, 1) + } + } + /// Executes the entire build, as configured by the flags and configuration. pub fn build(&mut self) { unsafe { @@ -798,7 +834,7 @@ impl Build { /// Returns the number of parallel jobs that have been configured for this /// build. fn jobs(&self) -> u32 { - self.flags.jobs.unwrap_or(num_cpus::get() as u32) + self.flags.jobs.unwrap_or_else(|| num_cpus::get() as u32) } /// Returns the path to the C compiler for the target specified. diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs index 433ac3dedfd..e2c955c4f4f 100644 --- a/src/bootstrap/sanity.rs +++ b/src/bootstrap/sanity.rs @@ -194,17 +194,6 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake } } - for host in build.flags.host.iter() { - if !build.config.host.contains(host) { - panic!("specified host `{}` is not in configuration", host); - } - } - for target in build.flags.target.iter() { - if !build.config.target.contains(target) { - panic!("specified target `{}` is not in configuration", target); - } - } - let run = |cmd: &mut Command| { cmd.output().map(|output| { String::from_utf8_lossy(&output.stdout) diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs index 61e9a0d16da..bcfa004ac3c 100644 --- a/src/bootstrap/step.rs +++ b/src/bootstrap/step.rs @@ -1218,16 +1218,9 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd? rules.into_iter().flat_map(|(rule, _)| { let hosts = if rule.only_host_build || rule.only_build { - &self.build.config.host[..1] - } else if self.build.flags.host.len() > 0 { - &self.build.flags.host + self.build.build_slice() } else { - &self.build.config.host - }; - let targets = if self.build.flags.target.len() > 0 { - &self.build.flags.target - } else { - &self.build.config.target + &self.build.hosts }; // Determine the actual targets participating in this rule. // NOTE: We should keep the full projection from build triple to @@ -1236,19 +1229,18 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd? // the original non-shadowed hosts array is used below. let arr = if rule.host { // If --target was specified but --host wasn't specified, - // don't run any host-only tests. Also, respect any `--host` - // overrides as done for `hosts`. + // don't run any host-only tests. if self.build.flags.host.len() > 0 { - &self.build.flags.host[..] + &self.build.hosts } else if self.build.flags.target.len() > 0 { &[] } else if rule.only_build { - &self.build.config.host[..1] + self.build.build_slice() } else { - &self.build.config.host[..] + &self.build.hosts } } else { - targets + &self.build.targets }; hosts.iter().flat_map(move |host| {