Skip to content

Commit 60394a8

Browse files
committed
fix CI-rustc bugs
Signed-off-by: onur-ozkan <[email protected]>
1 parent 1ab2ba3 commit 60394a8

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

src/bootstrap/src/core/build_steps/clippy.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,18 @@ impl Step for Rustc {
207207
let compiler = builder.compiler(builder.top_stage, builder.config.build);
208208
let target = self.target;
209209

210-
if compiler.stage != 0 {
211-
// If we're not in stage 0, then we won't have a std from the beta
212-
// compiler around. That means we need to make sure there's one in
213-
// the sysroot for the compiler to find. Otherwise, we're going to
214-
// fail when building crates that need to generate code (e.g., build
215-
// scripts and their dependencies).
216-
builder.ensure(compile::Std::new(compiler, compiler.host));
217-
builder.ensure(compile::Std::new(compiler, target));
218-
} else {
219-
builder.ensure(check::Std::new(target).build_kind(Some(Kind::Check)));
210+
if !builder.download_rustc() {
211+
if compiler.stage != 0 {
212+
// If we're not in stage 0, then we won't have a std from the beta
213+
// compiler around. That means we need to make sure there's one in
214+
// the sysroot for the compiler to find. Otherwise, we're going to
215+
// fail when building crates that need to generate code (e.g., build
216+
// scripts and their dependencies).
217+
builder.ensure(compile::Std::new(compiler, compiler.host));
218+
builder.ensure(compile::Std::new(compiler, target));
219+
} else {
220+
builder.ensure(check::Std::new(target).build_kind(Some(Kind::Check)));
221+
}
220222
}
221223

222224
let mut cargo = builder::Cargo::new(
@@ -286,7 +288,9 @@ macro_rules! lint_any {
286288
let compiler = builder.compiler(builder.top_stage, builder.config.build);
287289
let target = self.target;
288290

289-
builder.ensure(check::Rustc::new(target, builder).build_kind(Some(Kind::Check)));
291+
if !builder.download_rustc() {
292+
builder.ensure(check::Rustc::new(target, builder).build_kind(Some(Kind::Check)));
293+
};
290294

291295
let cargo = prepare_tool_cargo(
292296
builder,

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,7 @@ impl Step for StdLink {
771771
builder.cp_link_r(&stage0_bin_dir, &sysroot_bin_dir);
772772

773773
let stage0_lib_dir = builder.out.join(host).join("stage0/lib");
774+
t!(fs::create_dir_all(sysroot.join("lib")));
774775
builder.cp_link_r(&stage0_lib_dir, &sysroot.join("lib"));
775776

776777
// Copy codegen-backends from stage0
@@ -789,6 +790,12 @@ impl Step for StdLink {
789790
let sysroot = builder.out.join(compiler.host.triple).join("stage0-sysroot");
790791
builder.cp_link_r(&builder.initial_sysroot.join("lib"), &sysroot.join("lib"));
791792
} else {
793+
if builder.download_rustc() {
794+
// Ensure there are no CI-rustc std artifacts.
795+
let _ = fs::remove_dir_all(&libdir);
796+
let _ = fs::remove_dir_all(&hostdir);
797+
}
798+
792799
add_to_sysroot(
793800
builder,
794801
&libdir,

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,11 @@ pub(crate) fn get_tool_rustc_compiler(
329329
return target_compiler;
330330
}
331331

332+
if builder.download_rustc() && target_compiler.stage == 1 {
333+
// We shouldn't drop to stage0 compiler when using CI rustc.
334+
return builder.compiler(1, builder.config.build);
335+
}
336+
332337
// Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
333338
// we'd have stageN/bin/rustc and stageN/bin/$rustc_tool be effectively different stage
334339
// compilers, which isn't what we want. Rustc tools should be linked in the same way as the

0 commit comments

Comments
 (0)