diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index d0d995d704e..60f4b98d9d8 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -184,15 +184,6 @@ fn main() { cmd.arg("-C").arg(format!("codegen-units={}", s)); } - // Emit save-analysis info. - if env::var("RUSTC_SAVE_ANALYSIS") == Ok("api".to_string()) { - cmd.arg("-Zsave-analysis"); - cmd.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}"); - } - // Dealing with rpath here is a little special, so let's go into some // detail. First off, `-rpath` is a linker option on Unix platforms // which adds to the runtime dynamic loader path when looking for diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index a7e9b9aaf64..3995ab170d1 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -796,6 +796,21 @@ impl<'a> Builder<'a> { cargo.env("RUST_CHECK", "1"); } + let stage; + if compiler.stage == 0 && self.local_rebuild { + // Assume the local-rebuild rustc already has stage1 features. + stage = 1; + } else { + stage = compiler.stage; + } + + let mut rustflags = Rustflags::new(); + if stage != 0 { + rustflags.env("RUSTFLAGS_NOT_BOOTSTRAP"); + } else { + rustflags.env("RUSTFLAGS_BOOTSTRAP"); + } + match mode { Mode::Std | Mode::ToolBootstrap | Mode::ToolStd => {}, Mode::Rustc | Mode::Codegen | Mode::ToolRustc => { @@ -852,22 +867,6 @@ impl<'a> Builder<'a> { } cargo.env("__CARGO_DEFAULT_LIB_METADATA", &metadata); - let stage; - if compiler.stage == 0 && self.local_rebuild { - // Assume the local-rebuild rustc already has stage1 features. - stage = 1; - } else { - stage = compiler.stage; - } - - let mut rustflags = Rustflags::new(); - rustflags.env(&format!("RUSTFLAGS_STAGE_{}", stage)); - if stage != 0 { - rustflags.env("RUSTFLAGS_NOT_BOOTSTRAP"); - } else { - rustflags.env("RUSTFLAGS_BOOTSTRAP"); - } - if cmd == "clippy" { rustflags.arg("-Zforce-unstable-if-unmarked"); } @@ -1064,7 +1063,11 @@ impl<'a> Builder<'a> { && self.config.extended && compiler.is_final_stage(self) { - cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string()); + rustflags.arg("-Zsave-analysis"); + 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}"); } // For `cargo doc` invocations, make rustdoc print the Rust version into the docs