From edcdb80914c9bc32bf3901ca68ff76d122cd2286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 26 Aug 2025 10:13:55 +0200 Subject: [PATCH] Add `compiler_for_std` --- src/bootstrap/src/core/build_steps/compile.rs | 2 +- src/bootstrap/src/core/build_steps/dist.rs | 2 +- src/bootstrap/src/core/build_steps/doc.rs | 4 +++- src/bootstrap/src/core/builder/mod.rs | 8 ++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index d30005c8d51d..bc978e1c4d06 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -150,7 +150,7 @@ impl Step for Std { trace!(force_recompile); run.builder.ensure(Std { - build_compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()), + build_compiler: run.builder.compiler_for_std(run.builder.top_stage, run.target), target: run.target, crates, force_recompile, diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 5287aa07fc17..1320c3f65d5d 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -115,7 +115,7 @@ impl Step for JsonDocs { fn make_run(run: RunConfig<'_>) { run.builder.ensure(JsonDocs { - build_compiler: run.builder.compiler(run.builder.top_stage, run.builder.host_target), + build_compiler: run.builder.compiler_for_std(run.builder.top_stage, run.target), target: run.target, }); } diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index 8c20c8c479af..379d997e1f2c 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -616,7 +616,9 @@ impl Step for Std { return; } run.builder.ensure(Std { - build_compiler: run.builder.compiler(run.builder.top_stage, run.builder.host_target), + build_compiler: run + .builder + .compiler_for_std(run.builder.top_stage, run.builder.host_target), target: run.target, format: if run.builder.config.cmd.json() { DocumentationFormat::Json diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index f794f4e079ae..02ca1a335163 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -1360,6 +1360,14 @@ impl<'a> Builder<'a> { self.ensure(compile::Assemble { target_compiler: Compiler::new(stage, host) }) } + pub fn compiler_for_std(&self, stage: u32, target: TargetSelection) -> Compiler { + if compile::Std::should_be_uplifted_from_stage_1(self, stage, target) { + self.compiler(1, self.host_target) + } else { + self.compiler(stage, self.host_target) + } + } + /// Similar to `compiler`, except handles the full-bootstrap option to /// silently use the stage1 compiler instead of a stage2 compiler if one is /// requested.