Skip to content

Commit 8072fa1

Browse files
committed
fix CI-rustc bugs
Signed-off-by: onur-ozkan <[email protected]>
1 parent 84818ea commit 8072fa1

File tree

4 files changed

+27
-13
lines changed

4 files changed

+27
-13
lines changed

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

+15-11
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

+7
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ impl Step for StdLink {
772772
builder.cp_link_r(&stage0_bin_dir, &sysroot_bin_dir);
773773

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

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

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,11 @@ pub(crate) fn get_tool_rustc_compiler(
330330
return target_compiler;
331331
}
332332

333+
if builder.download_rustc() && target_compiler.stage == 1 {
334+
// We shouldn't drop to stage0 compiler when using CI rustc.
335+
return builder.compiler(1, builder.config.build);
336+
}
337+
333338
// Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
334339
// we'd have stageN/bin/rustc and stageN/bin/$rustc_tool be effectively different stage
335340
// compilers, which isn't what we want. Rustc tools should be linked in the same way as the
@@ -809,7 +814,6 @@ impl Step for LldWrapper {
809814
fields(build_compiler = ?self.build_compiler, target_compiler = ?self.target_compiler),
810815
),
811816
)]
812-
813817
fn run(self, builder: &Builder<'_>) -> ToolBuildResult {
814818
if builder.config.dry_run() {
815819
return ToolBuildResult {

src/bootstrap/src/core/builder/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,6 @@ impl<'a> Builder<'a> {
12761276
),
12771277
),
12781278
)]
1279-
12801279
/// FIXME: This function is unnecessary (and dangerous, see <https://github.com/rust-lang/rust/issues/137469>).
12811280
/// We already have uplifting logic for the compiler, so remove this.
12821281
pub fn compiler_for(

0 commit comments

Comments
 (0)