From acf3d87b86c9e297a0b5cc5311510749b575b8e6 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Tue, 13 Jul 2021 20:46:16 -0400 Subject: [PATCH] Clear rustc when dirty for all command modes, not just std This avoids incremental ICEs when building with stage 1 (see 76720). This also checks for `check`, since `x.py check --stage 1` could also hit the same issue (now that `check` supports a --stage argument). --- src/bootstrap/builder.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 56ecc6e68a98c..75cb0cf8ad006 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1072,14 +1072,12 @@ impl<'a> Builder<'a> { let libdir = self.rustc_libdir(compiler); // Clear the output directory if the real rustc we're using has changed; - // Cargo cannot detect this as it thinks rustc is bootstrap/debug/rustc. + // Cargo usually cannot detect this because we use the same version string for all stage1 + // builds, regardless of the git commit. // // Avoid doing this during dry run as that usually means the relevant // compiler is not yet linked/copied properly. - // - // Only clear out the directory if we're compiling std; otherwise, we - // should let Cargo take care of things for us (via depdep info) - if !self.config.dry_run && mode == Mode::Std && cmd == "build" { + if !self.config.dry_run && ["build", "check"].contains(&cmd) { self.clear_if_dirty(&out_dir, &self.rustc(compiler)); }