From 28d8ac070c1efaeb9ffe94c5df95dca0b5292317 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Mon, 3 Feb 2025 11:49:22 +0000 Subject: [PATCH] keep `Rustc` private and use `Assemble` instead Signed-off-by: onur-ozkan --- src/bootstrap/src/core/build_steps/compile.rs | 16 +++++++++++----- src/bootstrap/src/core/build_steps/dist.rs | 2 +- src/bootstrap/src/core/build_steps/doc.rs | 2 +- src/bootstrap/src/core/build_steps/test.rs | 9 ++++----- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 61160a80a33c4..091e75607e60e 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -839,9 +839,9 @@ fn cp_rustc_component_to_ci_sysroot(builder: &Builder<'_>, sysroot: &Path, conte #[derive(Debug, PartialOrd, Ord, Clone, PartialEq, Eq, Hash)] pub struct Rustc { - pub target: TargetSelection, + target: TargetSelection, /// The **previous** compiler used to compile this compiler. - pub compiler: Compiler, + compiler: Compiler, /// Whether to build a subset of crates, rather than the whole compiler. /// /// This should only be requested by the user, not used within bootstrap itself. @@ -851,6 +851,7 @@ pub struct Rustc { } impl Rustc { + #[cfg(test)] pub fn new(compiler: Compiler, target: TargetSelection) -> Self { Self { target, compiler, crates: Default::default() } } @@ -923,7 +924,8 @@ impl Step for Rustc { let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target); if compiler_to_use != compiler { - builder.ensure(Rustc::new(compiler_to_use, target)); + let _ = builder.compiler(compiler_to_use.stage, target); + let msg = if compiler_to_use.host == target { format!( "Uplifting rustc (stage{} -> stage{})", @@ -1424,7 +1426,7 @@ impl Step for CodegenBackend { let target = self.target; let backend = self.backend; - builder.ensure(Rustc::new(compiler, target)); + let _ = builder.compiler(compiler.stage, target); if builder.config.keep_stage.contains(&compiler.stage) { builder.info( @@ -1861,7 +1863,11 @@ impl Step for Assemble { // link to these. (FIXME: Is that correct? It seems to be correct most // of the time but I think we do link to these for stage2/bin compilers // when not performing a full bootstrap). - let actual_stage = builder.ensure(Rustc::new(build_compiler, target_compiler.host)); + let actual_stage = builder.ensure(Rustc { + compiler: build_compiler, + target: target_compiler.host, + crates: vec![], + }); // Current build_compiler.stage might be uplifted instead of being built; so update it // to not fail while linking the artifacts. build_compiler.stage = actual_stage; diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 18f920b85eee0..43312c8a30d40 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -727,7 +727,7 @@ impl Step for RustcDev { return None; } - builder.ensure(compile::Rustc::new(compiler, target)); + let _ = builder.compiler(compiler.stage, target); let tarball = Tarball::new(builder, "rustc-dev", &target.triple); diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index 0eb4080c053a7..a761eed0f1d4b 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -953,7 +953,7 @@ macro_rules! tool_doc { // Rustdoc needs the rustc sysroot available to build. // FIXME: is there a way to only ensure `check::Rustc` here? Last time I tried it failed // with strange errors, but only on a full bors test ... - builder.ensure(compile::Rustc::new(compiler, target)); + let _ = builder.compiler(compiler.stage, target); } // Build cargo command. diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index c1b7fee17350a..89b1b1d4c01db 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -251,7 +251,6 @@ impl Step for Cargotest { /// test` to ensure that we don't regress the test suites there. fn run(self, builder: &Builder<'_>) { let compiler = builder.compiler(self.stage, self.host); - builder.ensure(compile::Rustc::new(compiler, compiler.host)); let cargo = builder.ensure(tool::Cargo { compiler, target: compiler.host }); // Note that this is a short, cryptic, and not scoped directory name. This @@ -369,7 +368,7 @@ impl Step for RustAnalyzer { // We don't need to build the whole Rust Analyzer for the proc-macro-srv test suite, // but we do need the standard library to be present. - builder.ensure(compile::Rustc::new(compiler, host)); + let _ = builder.compiler(compiler.stage, host); let workspace_path = "src/tools/rust-analyzer"; // until the whole RA test suite runs on `i686`, we only run @@ -1662,7 +1661,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the }; if suite.ends_with("fulldeps") { - builder.ensure(compile::Rustc::new(compiler, target)); + let _ = builder.compiler(compiler.stage, target); } if suite == "debuginfo" { @@ -2813,7 +2812,7 @@ impl Step for CrateRustdoc { // the target rustdoc (`ci-rustc-sysroot` vs `stage2`). In that case, we need to ensure this // explicitly to make sure it ends up in the stage2 sysroot. builder.ensure(compile::Std::new(compiler, target)); - builder.ensure(compile::Rustc::new(compiler, target)); + let _ = builder.compiler(compiler.stage, target); let mut cargo = tool::prepare_tool_cargo( builder, @@ -2904,7 +2903,7 @@ impl Step for CrateRustdocJsonTypes { // `compiler`, then it would cause rustdoc to be built *again*, which // isn't really necessary. let compiler = builder.compiler_for(builder.top_stage, target, target); - builder.ensure(compile::Rustc::new(compiler, target)); + let _ = builder.compiler(compiler.stage, target); let cargo = tool::prepare_tool_cargo( builder,