diff options
Diffstat (limited to 'src/bootstrap/builder.rs')
| -rw-r--r-- | src/bootstrap/builder.rs | 128 |
1 files changed, 43 insertions, 85 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index bd0462fca6d..a2dca66697d 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -24,7 +24,7 @@ use crate::native; use crate::test; use crate::tool; use crate::util::{self, add_lib_path, exe, libdir}; -use crate::{Build, DocTests, Mode, GitRepo}; +use crate::{Build, DocTests, GitRepo, Mode}; pub use crate::Compiler; @@ -122,11 +122,7 @@ impl PathSet { fn path(&self, builder: &Builder<'_>) -> PathBuf { match self { - PathSet::Set(set) => set - .iter() - .next() - .unwrap_or(&builder.build.src) - .to_path_buf(), + PathSet::Set(set) => set.iter().next().unwrap_or(&builder.build.src).to_path_buf(), PathSet::Suite(path) => PathBuf::from(path), } } @@ -180,10 +176,8 @@ impl StepDescription { } fn run(v: &[StepDescription], builder: &Builder<'_>, paths: &[PathBuf]) { - let should_runs = v - .iter() - .map(|desc| (desc.should_run)(ShouldRun::new(builder))) - .collect::<Vec<_>>(); + let should_runs = + v.iter().map(|desc| (desc.should_run)(ShouldRun::new(builder))).collect::<Vec<_>>(); // sanity checks on rules for (desc, should_run) in v.iter().zip(&should_runs) { @@ -280,8 +274,7 @@ impl<'a> ShouldRun<'a> { // multiple aliases for the same job pub fn paths(mut self, paths: &[&str]) -> Self { - self.paths - .insert(PathSet::Set(paths.iter().map(PathBuf::from).collect())); + self.paths.insert(PathSet::Set(paths.iter().map(PathBuf::from).collect())); self } @@ -354,11 +347,9 @@ impl<'a> Builder<'a> { tool::Miri, native::Lld ), - Kind::Check | Kind::Clippy | Kind::Fix | Kind::Format => describe!( - check::Std, - check::Rustc, - check::Rustdoc - ), + Kind::Check | Kind::Clippy | Kind::Fix | Kind::Format => { + describe!(check::Std, check::Rustc, check::Rustdoc) + } Kind::Test => describe!( crate::toolstate::ToolStateCheck, test::Tidy, @@ -549,9 +540,7 @@ impl<'a> Builder<'a> { /// obtained through this function, since it ensures that they are valid /// (i.e., built and assembled). pub fn compiler(&self, stage: u32, host: Interned<String>) -> Compiler { - self.ensure(compile::Assemble { - target_compiler: Compiler { stage, host }, - }) + self.ensure(compile::Assemble { target_compiler: Compiler { stage, host } }) } /// Similar to `compiler`, except handles the full-bootstrap option to @@ -627,9 +616,10 @@ impl<'a> Builder<'a> { self.rustc_snapshot_libdir() } else { match self.config.libdir_relative() { - Some(relative_libdir) if compiler.stage >= 1 - => self.sysroot(compiler).join(relative_libdir), - _ => self.sysroot(compiler).join(libdir(&compiler.host)) + Some(relative_libdir) if compiler.stage >= 1 => { + self.sysroot(compiler).join(relative_libdir) + } + _ => self.sysroot(compiler).join(libdir(&compiler.host)), } } } @@ -644,9 +634,8 @@ impl<'a> Builder<'a> { libdir(&self.config.build).as_ref() } else { match self.config.libdir_relative() { - Some(relative_libdir) if compiler.stage >= 1 - => relative_libdir, - _ => libdir(&compiler.host).as_ref() + Some(relative_libdir) if compiler.stage >= 1 => relative_libdir, + _ => libdir(&compiler.host).as_ref(), } } } @@ -657,9 +646,8 @@ impl<'a> Builder<'a> { /// For example this returns `lib` on Unix and Windows. pub fn sysroot_libdir_relative(&self, compiler: Compiler) -> &Path { match self.config.libdir_relative() { - Some(relative_libdir) if compiler.stage >= 1 - => relative_libdir, - _ => Path::new("lib") + Some(relative_libdir) if compiler.stage >= 1 => relative_libdir, + _ => Path::new("lib"), } } @@ -681,9 +669,7 @@ impl<'a> Builder<'a> { if compiler.is_snapshot(self) { self.initial_rustc.clone() } else { - self.sysroot(compiler) - .join("bin") - .join(exe("rustc", &compiler.host)) + self.sysroot(compiler).join("bin").join(exe("rustc", &compiler.host)) } } @@ -740,17 +726,10 @@ impl<'a> Builder<'a> { self.clear_if_dirty(&my_out, &rustdoc); } - cargo - .env("CARGO_TARGET_DIR", out_dir) - .arg(cmd) - .arg("-Zconfig-profile"); + cargo.env("CARGO_TARGET_DIR", out_dir).arg(cmd).arg("-Zconfig-profile"); let profile_var = |name: &str| { - let profile = if self.config.rust_optimize { - "RELEASE" - } else { - "DEV" - }; + let profile = if self.config.rust_optimize { "RELEASE" } else { "DEV" }; format!("CARGO_PROFILE_{}_{}", profile, name) }; @@ -762,8 +741,7 @@ impl<'a> Builder<'a> { } if cmd != "install" { - cargo.arg("--target") - .arg(target); + cargo.arg("--target").arg(target); } else { assert_eq!(target, compiler.host); } @@ -801,14 +779,14 @@ impl<'a> Builder<'a> { } match mode { - Mode::Std | Mode::ToolBootstrap | Mode::ToolStd => {}, + Mode::Std | Mode::ToolBootstrap | Mode::ToolStd => {} Mode::Rustc | Mode::Codegen | Mode::ToolRustc => { // Build proc macros both for the host and the target if target != compiler.host && cmd != "check" { cargo.arg("-Zdual-proc-macros"); rustflags.arg("-Zdual-proc-macros"); } - }, + } } // This tells Cargo (and in turn, rustc) to output more complete @@ -884,11 +862,7 @@ impl<'a> Builder<'a> { assert!(!use_snapshot || stage == 0 || self.local_rebuild); let maybe_sysroot = self.sysroot(compiler); - let sysroot = if use_snapshot { - self.rustc_snapshot_sysroot() - } else { - &maybe_sysroot - }; + let sysroot = if use_snapshot { self.rustc_snapshot_sysroot() } else { &maybe_sysroot }; let libdir = self.rustc_libdir(compiler); // Customize the compiler we're running. Specify the compiler to cargo @@ -902,10 +876,7 @@ impl<'a> Builder<'a> { .env("RUSTC", self.out.join("bootstrap/debug/rustc")) .env("RUSTC_REAL", self.rustc(compiler)) .env("RUSTC_STAGE", stage.to_string()) - .env( - "RUSTC_DEBUG_ASSERTIONS", - self.config.rust_debug_assertions.to_string(), - ) + .env("RUSTC_DEBUG_ASSERTIONS", self.config.rust_debug_assertions.to_string()) .env("RUSTC_SYSROOT", &sysroot) .env("RUSTC_LIBDIR", &libdir) .env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc")) @@ -948,7 +919,6 @@ impl<'a> Builder<'a> { // to change a flag in a binary? if self.config.rust_rpath && util::use_host_linker(&target) { let rpath = if target.contains("apple") { - // Note that we need to take one extra step on macOS to also pass // `-Wl,-instal_name,@rpath/...` to get things to work right. To // do that we pass a weird flag to the compiler to get it to do @@ -980,8 +950,9 @@ impl<'a> Builder<'a> { let debuginfo_level = match mode { Mode::Rustc | Mode::Codegen => self.config.rust_debuginfo_level_rustc, Mode::Std => self.config.rust_debuginfo_level_std, - Mode::ToolBootstrap | Mode::ToolStd | - Mode::ToolRustc => self.config.rust_debuginfo_level_tools, + Mode::ToolBootstrap | Mode::ToolStd | Mode::ToolRustc => { + self.config.rust_debuginfo_level_tools + } }; cargo.env(profile_var("DEBUG"), debuginfo_level.to_string()); @@ -1102,14 +1073,11 @@ impl<'a> Builder<'a> { cargo.env(format!("CC_{}", target), &cc); let cflags = self.cflags(target, GitRepo::Rustc).join(" "); - cargo - .env(format!("CFLAGS_{}", target), cflags.clone()); + cargo.env(format!("CFLAGS_{}", target), cflags.clone()); if let Some(ar) = self.ar(target) { let ranlib = format!("{} s", ar.display()); - cargo - .env(format!("AR_{}", target), ar) - .env(format!("RANLIB_{}", target), ranlib); + cargo.env(format!("AR_{}", target), ar).env(format!("RANLIB_{}", target), ranlib); } if let Ok(cxx) = self.cxx(target) { @@ -1120,15 +1088,14 @@ impl<'a> Builder<'a> { } } - if mode == Mode::Std - && self.config.extended - && compiler.is_final_stage(self) - { + if mode == Mode::Std && self.config.extended && compiler.is_final_stage(self) { rustflags.arg("-Zsave-analysis"); - cargo.env("RUST_SAVE_ANALYSIS_CONFIG", - "{\"output_file\": null,\"full_docs\": false,\ + cargo.env( + "RUST_SAVE_ANALYSIS_CONFIG", + "{\"output_file\": null,\"full_docs\": false,\ \"pub_only\": true,\"reachable_only\": false,\ - \"distro_crate\": true,\"signatures\": false,\"borrow_data\": false}"); + \"distro_crate\": true,\"signatures\": false,\"borrow_data\": false}", + ); } // For `cargo doc` invocations, make rustdoc print the Rust version into the docs @@ -1182,8 +1149,7 @@ impl<'a> Builder<'a> { } match (mode, self.config.rust_codegen_units_std, self.config.rust_codegen_units) { - (Mode::Std, Some(n), _) | - (_, _, Some(n)) => { + (Mode::Std, Some(n), _) | (_, _, Some(n)) => { cargo.env(profile_var("CODEGEN_UNITS"), n.to_string()); } _ => { @@ -1217,10 +1183,7 @@ impl<'a> Builder<'a> { rustflags.arg("-Cprefer-dynamic"); } - Cargo { - command: cargo, - rustflags, - } + Cargo { command: cargo, rustflags } } /// Ensure that a given step is built, returning its output. This will @@ -1231,10 +1194,7 @@ impl<'a> Builder<'a> { let mut stack = self.stack.borrow_mut(); for stack_step in stack.iter() { // should skip - if stack_step - .downcast_ref::<S>() - .map_or(true, |stack_step| *stack_step != step) - { + if stack_step.downcast_ref::<S>().map_or(true, |stack_step| *stack_step != step) { continue; } let mut out = String::new(); @@ -1277,11 +1237,7 @@ impl<'a> Builder<'a> { let cur_step = stack.pop().expect("step stack empty"); assert_eq!(cur_step.downcast_ref(), Some(&step)); } - self.verbose(&format!( - "{}< {:?}", - " ".repeat(self.stack.borrow().len()), - step - )); + self.verbose(&format!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step)); self.cache.put(step, out.clone()); out } @@ -1344,7 +1300,9 @@ impl Cargo { } pub fn args<I, S>(&mut self, args: I) -> &mut Cargo - where I: IntoIterator<Item=S>, S: AsRef<OsStr> + where + I: IntoIterator<Item = S>, + S: AsRef<OsStr>, { for arg in args { self.arg(arg.as_ref()); |
