Skip to content

Commit

Permalink
fix #102002, Delete the stage1 and stage0-sysroot directories when us…
Browse files Browse the repository at this point in the history
…ing download-rustc
  • Loading branch information
chenyukang committed Sep 19, 2022
1 parent 11bb80a commit 973ff03
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,10 +1099,11 @@ 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 {
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 @@ -1113,6 +1114,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
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
6 changes: 4 additions & 2 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,10 @@ impl Step for Rustdoc {
// Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
// we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage
// compilers, which isn't what we want. Rustdoc should be linked in the same way as the
// rustc compiler it's paired with, so it must be built with the previous stage compiler.
let build_compiler = builder.compiler(target_compiler.stage - 1, builder.config.build);
// rustc compiler it's paired with, so it must be built with the previous stage compiler,
// if download_rustc is true, we will use the same target stage.
let target_stage = target_compiler.stage - if builder.download_rustc() { 0 } else { 1 };
let build_compiler = builder.compiler(target_stage, builder.config.build);

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

0 comments on commit 973ff03

Please sign in to comment.