Skip to content

Commit d6298d3

Browse files
authored
Rollup merge of #104076 - ozkanonur:fix-ci-rustc-sysroot, r=jyn514
fix sysroot issue which appears for ci downloaded rustc Currently when compiler is downloaded rather than compiled, sysroot is being `ci-rustc-sysroot` because of https://github.com/rust-lang/rust/blob/7eef946fc0e0eff40e588eab77b09b287accbec3/src/bootstrap/compile.rs#L1125-L1131 this. And rustdoc is overriding the downloaded one at the end of the process. With the condition I add, we simply check if the current compiler stage is target build stage, if so use the proper sysroot instead of `ci-rustc-sysroot`. Resolves #103206
2 parents 747f29f + 654a4e8 commit d6298d3

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/bootstrap/compile.rs

+20-9
Original file line numberDiff line numberDiff line change
@@ -1121,13 +1121,18 @@ impl Step for Sysroot {
11211121
fn run(self, builder: &Builder<'_>) -> Interned<PathBuf> {
11221122
let compiler = self.compiler;
11231123
let host_dir = builder.out.join(&compiler.host.triple);
1124-
let sysroot = if compiler.stage == 0 {
1125-
host_dir.join("stage0-sysroot")
1126-
} else if builder.download_rustc() {
1127-
host_dir.join("ci-rustc-sysroot")
1128-
} else {
1129-
host_dir.join(format!("stage{}", compiler.stage))
1124+
1125+
let sysroot_dir = |stage| {
1126+
if stage == 0 {
1127+
host_dir.join("stage0-sysroot")
1128+
} else if builder.download_rustc() && compiler.stage != builder.top_stage {
1129+
host_dir.join("ci-rustc-sysroot")
1130+
} else {
1131+
host_dir.join(format!("stage{}", stage))
1132+
}
11301133
};
1134+
let sysroot = sysroot_dir(compiler.stage);
1135+
11311136
let _ = fs::remove_dir_all(&sysroot);
11321137
t!(fs::create_dir_all(&sysroot));
11331138

@@ -1138,9 +1143,15 @@ impl Step for Sysroot {
11381143
"Cross-compiling is not yet supported with `download-rustc`",
11391144
);
11401145

1141-
// #102002, cleanup stage1 and stage0-sysroot folders when using download-rustc so people don't use old versions of the toolchain by accident.
1142-
let _ = fs::remove_dir_all(host_dir.join("stage1"));
1143-
let _ = fs::remove_dir_all(host_dir.join("stage0-sysroot"));
1146+
// #102002, cleanup old toolchain folders when using download-rustc so people don't use them by accident.
1147+
for stage in 0..=2 {
1148+
if stage != compiler.stage {
1149+
let dir = sysroot_dir(stage);
1150+
if !dir.ends_with("ci-rustc-sysroot") {
1151+
let _ = fs::remove_dir_all(dir);
1152+
}
1153+
}
1154+
}
11441155

11451156
// Copy the compiler into the correct sysroot.
11461157
let ci_rustc_dir =

0 commit comments

Comments
 (0)