Skip to content

Commit

Permalink
Auto merge of #102025 - chenyukang:fix-102002, r=jyn514
Browse files Browse the repository at this point in the history
Delete the stage1 and stage0-sysroot directories when using download-rustc

Fixes #102002
  • Loading branch information
bors committed Oct 7, 2022
2 parents 5854680 + 60b39ba commit e42c4d7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1104,10 +1104,13 @@ impl Step for Sysroot {
/// 1-3.
fn run(self, builder: &Builder<'_>) -> Interned<PathBuf> {
let compiler = self.compiler;
let host_dir = builder.out.join(&compiler.host.triple);
let sysroot = if compiler.stage == 0 {
builder.out.join(&compiler.host.triple).join("stage0-sysroot")
host_dir.join("stage0-sysroot")
} else if builder.download_rustc() {
host_dir.join("ci-rustc-sysroot")
} else {
builder.out.join(&compiler.host.triple).join(format!("stage{}", compiler.stage))
host_dir.join(format!("stage{}", compiler.stage))
};
let _ = fs::remove_dir_all(&sysroot);
t!(fs::create_dir_all(&sysroot));
Expand All @@ -1118,6 +1121,11 @@ impl Step for Sysroot {
builder.config.build, compiler.host,
"Cross-compiling is not yet supported with `download-rustc`",
);

// #102002, cleanup stage1 and stage0-sysroot folders when using download-rustc so people don't use old versions of the toolchain by accident.
let _ = fs::remove_dir_all(host_dir.join("stage1"));
let _ = fs::remove_dir_all(host_dir.join("stage0-sysroot"));

// Copy the compiler into the correct sysroot.
let ci_rustc_dir =
builder.config.out.join(&*builder.config.build.triple).join("ci-rustc");
Expand Down

0 comments on commit e42c4d7

Please sign in to comment.