Skip to content

Commit 973ff03

Browse files
committed
fix #102002, Delete the stage1 and stage0-sysroot directories when using download-rustc
1 parent 11bb80a commit 973ff03

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/bootstrap/compile.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1099,10 +1099,11 @@ impl Step for Sysroot {
10991099
/// 1-3.
11001100
fn run(self, builder: &Builder<'_>) -> Interned<PathBuf> {
11011101
let compiler = self.compiler;
1102+
let host_dir = builder.out.join(&compiler.host.triple);
11021103
let sysroot = if compiler.stage == 0 {
1103-
builder.out.join(&compiler.host.triple).join("stage0-sysroot")
1104+
host_dir.join("stage0-sysroot")
11041105
} else {
1105-
builder.out.join(&compiler.host.triple).join(format!("stage{}", compiler.stage))
1106+
host_dir.join(format!("stage{}", compiler.stage))
11061107
};
11071108
let _ = fs::remove_dir_all(&sysroot);
11081109
t!(fs::create_dir_all(&sysroot));
@@ -1113,6 +1114,11 @@ impl Step for Sysroot {
11131114
builder.config.build, compiler.host,
11141115
"Cross-compiling is not yet supported with `download-rustc`",
11151116
);
1117+
1118+
// #102002, cleanup stage1 and stage0-sysroot folders when using download-rustc
1119+
let _ = fs::remove_dir_all(host_dir.join("stage1"));
1120+
let _ = fs::remove_dir_all(host_dir.join("stage0-sysroot"));
1121+
11161122
// Copy the compiler into the correct sysroot.
11171123
let ci_rustc_dir =
11181124
builder.config.out.join(&*builder.config.build.triple).join("ci-rustc");

src/bootstrap/tool.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,10 @@ impl Step for Rustdoc {
512512
// Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
513513
// we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage
514514
// compilers, which isn't what we want. Rustdoc should be linked in the same way as the
515-
// rustc compiler it's paired with, so it must be built with the previous stage compiler.
516-
let build_compiler = builder.compiler(target_compiler.stage - 1, builder.config.build);
515+
// rustc compiler it's paired with, so it must be built with the previous stage compiler,
516+
// if download_rustc is true, we will use the same target stage.
517+
let target_stage = target_compiler.stage - if builder.download_rustc() { 0 } else { 1 };
518+
let build_compiler = builder.compiler(target_stage, builder.config.build);
517519

518520
// When using `download-rustc` and a stage0 build_compiler, copying rustc doesn't actually
519521
// build stage0 libstd (because the libstd in sysroot has the wrong ABI). Explicitly build

0 commit comments

Comments
 (0)