Skip to content

Commit e42c4d7

Browse files
committed
Auto merge of #102025 - chenyukang:fix-102002, r=jyn514
Delete the stage1 and stage0-sysroot directories when using download-rustc Fixes #102002
2 parents 5854680 + 60b39ba commit e42c4d7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/bootstrap/compile.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -1104,10 +1104,13 @@ impl Step for Sysroot {
11041104
/// 1-3.
11051105
fn run(self, builder: &Builder<'_>) -> Interned<PathBuf> {
11061106
let compiler = self.compiler;
1107+
let host_dir = builder.out.join(&compiler.host.triple);
11071108
let sysroot = if compiler.stage == 0 {
1108-
builder.out.join(&compiler.host.triple).join("stage0-sysroot")
1109+
host_dir.join("stage0-sysroot")
1110+
} else if builder.download_rustc() {
1111+
host_dir.join("ci-rustc-sysroot")
11091112
} else {
1110-
builder.out.join(&compiler.host.triple).join(format!("stage{}", compiler.stage))
1113+
host_dir.join(format!("stage{}", compiler.stage))
11111114
};
11121115
let _ = fs::remove_dir_all(&sysroot);
11131116
t!(fs::create_dir_all(&sysroot));
@@ -1118,6 +1121,11 @@ impl Step for Sysroot {
11181121
builder.config.build, compiler.host,
11191122
"Cross-compiling is not yet supported with `download-rustc`",
11201123
);
1124+
1125+
// #102002, cleanup stage1 and stage0-sysroot folders when using download-rustc so people don't use old versions of the toolchain by accident.
1126+
let _ = fs::remove_dir_all(host_dir.join("stage1"));
1127+
let _ = fs::remove_dir_all(host_dir.join("stage0-sysroot"));
1128+
11211129
// Copy the compiler into the correct sysroot.
11221130
let ci_rustc_dir =
11231131
builder.config.out.join(&*builder.config.build.triple).join("ci-rustc");

0 commit comments

Comments
 (0)