From 0192fa4786db80d2c9888af98e7ceec47d327887 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 2 Jul 2020 08:08:09 -0400 Subject: [PATCH] Make the default stage dependent on the subcommand ### x.py build/test: stage 1 I've seen very few people who actually use full stage 2 builds on purpose. These compile rustc and libstd twice and don't give you much more information than a stage 1 build (except in rare cases like https://github.com/rust-lang/rust/pull/68692#discussion_r376392145). For new contributors, this makes the build process even more daunting than it already is. As long as CI is changed to use `--stage 2` I see no downside here. ### x.py bench/dist/install: stage 2 These commands have to do with a finished, optimized version of rustc. It seems very rare to want to use these with a stage 1 build. ### x.py doc: stage 0 Normally when you document things you're just fixing a typo. In this case there is no need to build the whole rust compiler, since the documentation will usually be the same when generated with the beta compiler or with stage 1. Note that for this release cycle only there will be a significant different between stage0 and stage1 docs: https://github.com/rust-lang/rust/pull/73101. However most of the time this will not be the case. --- src/bootstrap/builder.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index c1c3c2f3ea797..5c25cfea9f268 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -527,9 +527,22 @@ impl<'a> Builder<'a> { } 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: build.config.stage.unwrap_or(2), + top_stage, kind, cache: Cache::new(), stack: RefCell::new(Vec::new()),