diff options
| author | onur-ozkan <work@onurozkan.dev> | 2025-03-22 09:43:53 +0000 |
|---|---|---|
| committer | onur-ozkan <work@onurozkan.dev> | 2025-05-30 21:04:22 +0300 |
| commit | 60394a807d6c37a274bac1b774e53cb6660ed790 (patch) | |
| tree | 00bf2ef8aaba206cf5303ab9f167db2c3b8e49f7 | |
| parent | 1ab2ba300cd5bc29571a2ae8a24eecd13cfb96ad (diff) | |
| download | rust-60394a807d6c37a274bac1b774e53cb6660ed790.tar.gz rust-60394a807d6c37a274bac1b774e53cb6660ed790.zip | |
fix CI-rustc bugs
Signed-off-by: onur-ozkan <work@onurozkan.dev>
| -rw-r--r-- | src/bootstrap/src/core/build_steps/clippy.rs | 26 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/compile.rs | 7 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/tool.rs | 5 |
3 files changed, 27 insertions, 11 deletions
diff --git a/src/bootstrap/src/core/build_steps/clippy.rs b/src/bootstrap/src/core/build_steps/clippy.rs index 07fd51919d4..5e8d6bba841 100644 --- a/src/bootstrap/src/core/build_steps/clippy.rs +++ b/src/bootstrap/src/core/build_steps/clippy.rs @@ -207,16 +207,18 @@ impl Step for Rustc { let compiler = builder.compiler(builder.top_stage, builder.config.build); let target = self.target; - if compiler.stage != 0 { - // If we're not in stage 0, then we won't have a std from the beta - // compiler around. That means we need to make sure there's one in - // the sysroot for the compiler to find. Otherwise, we're going to - // fail when building crates that need to generate code (e.g., build - // scripts and their dependencies). - builder.ensure(compile::Std::new(compiler, compiler.host)); - builder.ensure(compile::Std::new(compiler, target)); - } else { - builder.ensure(check::Std::new(target).build_kind(Some(Kind::Check))); + if !builder.download_rustc() { + if compiler.stage != 0 { + // If we're not in stage 0, then we won't have a std from the beta + // compiler around. That means we need to make sure there's one in + // the sysroot for the compiler to find. Otherwise, we're going to + // fail when building crates that need to generate code (e.g., build + // scripts and their dependencies). + builder.ensure(compile::Std::new(compiler, compiler.host)); + builder.ensure(compile::Std::new(compiler, target)); + } else { + builder.ensure(check::Std::new(target).build_kind(Some(Kind::Check))); + } } let mut cargo = builder::Cargo::new( @@ -286,7 +288,9 @@ macro_rules! lint_any { let compiler = builder.compiler(builder.top_stage, builder.config.build); let target = self.target; - builder.ensure(check::Rustc::new(target, builder).build_kind(Some(Kind::Check))); + if !builder.download_rustc() { + builder.ensure(check::Rustc::new(target, builder).build_kind(Some(Kind::Check))); + }; let cargo = prepare_tool_cargo( builder, diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 5d0a069db1c..633e6239f95 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -771,6 +771,7 @@ impl Step for StdLink { builder.cp_link_r(&stage0_bin_dir, &sysroot_bin_dir); let stage0_lib_dir = builder.out.join(host).join("stage0/lib"); + t!(fs::create_dir_all(sysroot.join("lib"))); builder.cp_link_r(&stage0_lib_dir, &sysroot.join("lib")); // Copy codegen-backends from stage0 @@ -789,6 +790,12 @@ impl Step for StdLink { let sysroot = builder.out.join(compiler.host.triple).join("stage0-sysroot"); builder.cp_link_r(&builder.initial_sysroot.join("lib"), &sysroot.join("lib")); } else { + if builder.download_rustc() { + // Ensure there are no CI-rustc std artifacts. + let _ = fs::remove_dir_all(&libdir); + let _ = fs::remove_dir_all(&hostdir); + } + add_to_sysroot( builder, &libdir, diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index 95d5bcb572b..f5f9a3ec4ab 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -329,6 +329,11 @@ pub(crate) fn get_tool_rustc_compiler( return target_compiler; } + if builder.download_rustc() && target_compiler.stage == 1 { + // We shouldn't drop to stage0 compiler when using CI rustc. + return builder.compiler(1, builder.config.build); + } + // Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise // we'd have stageN/bin/rustc and stageN/bin/$rustc_tool be effectively different stage // compilers, which isn't what we want. Rustc tools should be linked in the same way as the |
