X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fbootstrap%2Fbuilder.rs;h=e13a5f2465336fbea5d44ab4c4bd3a87e13556d0;hb=594f81a2b4dae23827271ea3a4bbb21c1a0004e1;hp=c1e56347ab1e0111ed0ff5d0bd71f1c88aead816;hpb=2bf54990a45dcf85626f2a2ab609770558107884;p=rust.git diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index c1e56347ab1..e13a5f24653 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -232,7 +232,7 @@ fn run(v: &[StepDescription], builder: &Builder<'_>, paths: &[PathBuf]) { } if !attempted_run { - panic!("Error: no rules matched {}.", path.display()); + panic!("error: no rules matched {}", path.display()); } } } @@ -501,16 +501,7 @@ pub fn get_help(build: &Build, subcommand: &str) -> Option { _ => return None, }; - let builder = Builder { - build, - top_stage: build.config.stage.unwrap_or(2), - kind, - cache: Cache::new(), - stack: RefCell::new(Vec::new()), - time_spent_on_dependencies: Cell::new(Duration::new(0, 0)), - paths: vec![], - }; - + let builder = Self::new_internal(build, kind, vec![]); let builder = &builder; let mut should_run = ShouldRun::new(builder); for desc in Builder::get_step_descriptions(builder.kind) { @@ -535,6 +526,32 @@ pub fn get_help(build: &Build, subcommand: &str) -> Option { Some(help) } + fn new_internal(build: &Build, kind: Kind, paths: Vec) -> Builder<'_> { + let top_stage = if let Some(explicit_stage) = build.config.stage { + explicit_stage + } else { + // See https://github.com/rust-lang/compiler-team/issues/326 + match kind { + Kind::Doc => 0, + Kind::Build | Kind::Test => 1, + Kind::Bench | Kind::Dist | Kind::Install => 2, + // These are all bootstrap tools, which don't depend on the compiler. + // The stage we pass shouldn't matter, but use 0 just in case. + Kind::Check | Kind::Clippy | Kind::Fix | Kind::Run | Kind::Format => 0, + } + }; + + Builder { + build, + top_stage, + kind, + cache: Cache::new(), + stack: RefCell::new(Vec::new()), + time_spent_on_dependencies: Cell::new(Duration::new(0, 0)), + paths, + } + } + pub fn new(build: &Build) -> Builder<'_> { let (kind, paths) = match build.config.cmd { Subcommand::Build { ref paths } => (Kind::Build, &paths[..]), @@ -550,15 +567,20 @@ pub fn new(build: &Build) -> Builder<'_> { Subcommand::Format { .. } | Subcommand::Clean { .. } => panic!(), }; - Builder { - build, - top_stage: build.config.stage.unwrap_or(2), - kind, - cache: Cache::new(), - stack: RefCell::new(Vec::new()), - time_spent_on_dependencies: Cell::new(Duration::new(0, 0)), - paths: paths.to_owned(), + let this = Self::new_internal(build, kind, paths.to_owned()); + + // CI should always run stage 2 builds, unless it specifically states otherwise + #[cfg(not(test))] + if build.config.stage.is_none() && build.ci_env != crate::CiEnv::None { + match kind { + Kind::Test | Kind::Doc | Kind::Build | Kind::Bench | Kind::Dist | Kind::Install => { + assert_eq!(this.top_stage, 2) + } + Kind::Check | Kind::Clippy | Kind::Fix | Kind::Run | Kind::Format => {} + } } + + this } pub fn execute_cli(&self) { @@ -1015,7 +1037,7 @@ pub fn cargo( } } - // FIXME: Don't use LLD if we're compiling libtest, since it fails to link it. + // FIXME: Don't use LLD with MSVC if we're compiling libtest, since it fails to link it. // See https://github.com/rust-lang/rust/issues/68647. let can_use_lld = mode != Mode::Std; @@ -1027,6 +1049,11 @@ pub fn cargo( let target = crate::envify(&target.triple); cargo.env(&format!("CARGO_TARGET_{}_LINKER", target), target_linker); } + + if self.config.use_lld && !target.contains("msvc") { + rustflags.arg("-Clink-args=-fuse-ld=lld"); + } + if !(["build", "check", "clippy", "fix", "rustc"].contains(&cmd)) && want_rustdoc { cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler)); }