diff options
| author | Jakub Beránek <berykubik@gmail.com> | 2025-08-26 23:00:54 +0200 |
|---|---|---|
| committer | Jakub Beránek <berykubik@gmail.com> | 2025-08-27 08:01:19 +0200 |
| commit | 6864a5bf42baeb64d23f0b086152a9c2893b5ade (patch) | |
| tree | 815fa05288ebaea100fb2af28412e786d3b3cf01 /src | |
| parent | 41563c7d4a0e54a414502f727df9b9caa737da39 (diff) | |
| download | rust-6864a5bf42baeb64d23f0b086152a9c2893b5ade.tar.gz rust-6864a5bf42baeb64d23f0b086152a9c2893b5ade.zip | |
Use std uplifting more often
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/src/core/build_steps/compile.rs | 28 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/dist.rs | 4 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/doc.rs | 4 | ||||
| -rw-r--r-- | src/bootstrap/src/core/builder/mod.rs | 5 | ||||
| -rw-r--r-- | src/bootstrap/src/core/builder/tests.rs | 19 |
5 files changed, 20 insertions, 40 deletions
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 72069df4cbd..0b75e85772f 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -99,28 +99,12 @@ impl Std { deps } - /// Returns true if the standard library will be uplifted from stage 1 for the given - /// `build_compiler` (which determines the stdlib stage) and `target`. + /// Returns true if the standard library should be uplifted from stage 1. /// - /// Uplifting is enabled if we're building a stage2+ libstd, full bootstrap is - /// disabled and we have a stage1 libstd already compiled for the given target. - pub fn should_be_uplifted_from_stage_1( - builder: &Builder<'_>, - stage: u32, - target: TargetSelection, - ) -> bool { - stage > 1 - && !builder.config.full_bootstrap - // This estimates if a stage1 libstd exists for the given target. If we're not - // cross-compiling, it should definitely exist by the time we're building a stage2 - // libstd. - // Or if we are cross-compiling, and we are building a cross-compiled rustc, then that - // rustc needs to link to a cross-compiled libstd, so again we should have a stage1 - // libstd for the given target prepared. - // Even if we guess wrong in the cross-compiled case, the worst that should happen is - // that we build a fresh stage1 libstd below, and then we immediately uplift it, so we - // don't pay the libstd build cost twice. - && (target == builder.host_target || builder.config.hosts.contains(&target)) + /// Uplifting is enabled if we're building a stage2+ libstd and full bootstrap is + /// disabled. + pub fn should_be_uplifted_from_stage_1(builder: &Builder<'_>, stage: u32) -> bool { + stage > 1 && !builder.config.full_bootstrap } } @@ -228,7 +212,7 @@ impl Step for Std { // Stage of the stdlib that we're building let stage = build_compiler.stage; - if Self::should_be_uplifted_from_stage_1(builder, build_compiler.stage, target) { + if Self::should_be_uplifted_from_stage_1(builder, build_compiler.stage) { let build_compiler_for_std_to_uplift = builder.compiler(1, builder.host_target); let stage_1_stamp = builder.std(build_compiler_for_std_to_uplift, target); diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index a76bef93317..f113dd7683d 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_for_std(run.builder.top_stage, run.target), + build_compiler: run.builder.compiler_for_std(run.builder.top_stage), target: run.target, }); } @@ -769,7 +769,7 @@ pub struct Std { impl Std { pub fn new(builder: &Builder<'_>, target: TargetSelection) -> Self { - Std { build_compiler: builder.compiler_for_std(builder.top_stage, target), target } + Std { build_compiler: builder.compiler_for_std(builder.top_stage), target } } } diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index 379d997e1f2..9ef1fee1fec 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -616,9 +616,7 @@ impl Step for Std { return; } run.builder.ensure(Std { - build_compiler: run - .builder - .compiler_for_std(run.builder.top_stage, run.builder.host_target), + build_compiler: run.builder.compiler_for_std(run.builder.top_stage), 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 4f37e0edbad..b224a7e7322 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -1373,10 +1373,11 @@ impl<'a> Builder<'a> { /// we need: /// - stage 2 libstd for target2 (uplifted from stage 1, where it was built by target1 rustc) /// - stage 2 rustc for target2 + /// /// However, without this optimization, we would also build stage 2 rustc for **target1**, /// which is completely wasteful. - pub fn compiler_for_std(&self, stage: u32, target: TargetSelection) -> Compiler { - if compile::Std::should_be_uplifted_from_stage_1(self, stage, target) { + pub fn compiler_for_std(&self, stage: u32) -> Compiler { + if compile::Std::should_be_uplifted_from_stage_1(self, stage) { self.compiler(1, self.host_target) } else { self.compiler(stage, self.host_target) diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 491df10519a..b079117c5a7 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -1066,6 +1066,7 @@ mod snapshot { [build] rustc 1 <host> -> rustc 2 <target1> [build] rustc 2 <host> -> std 2 <host> [build] rustc 2 <host> -> std 2 <target1> + [build] rustc 1 <host> -> std 1 <target2> [build] rustc 2 <host> -> std 2 <target2> "); } @@ -1295,16 +1296,15 @@ mod snapshot { [dist] docs <target1> [doc] rustc 1 <host> -> std 1 <host> crates=[] [dist] rustc 1 <host> -> json-docs 2 <host> - [build] rustdoc 2 <host> - [doc] rustc 2 <host> -> std 2 <target1> crates=[] - [dist] rustc 2 <host> -> json-docs 3 <target1> + [doc] rustc 1 <host> -> std 1 <target1> crates=[] + [dist] rustc 1 <host> -> json-docs 2 <target1> [dist] mingw <host> [dist] mingw <target1> + [build] rustdoc 2 <host> [build] rustc 0 <host> -> GenerateCopyright 1 <host> [dist] rustc <host> [dist] rustc 1 <host> -> std 1 <host> - [build] rustc 2 <host> -> std 2 <target1> - [dist] rustc 2 <host> -> std 2 <target1> + [dist] rustc 1 <host> -> std 1 <target1> [dist] rustc 1 <host> -> rustc-dev 2 <host> [dist] src <> [dist] reproducible-artifacts <host> @@ -1495,13 +1495,10 @@ mod snapshot { [doc] rustc 1 <host> -> releases 2 <target1> [build] rustc 0 <host> -> RustInstaller 1 <host> [dist] docs <target1> - [build] rustc 1 <host> -> rustc 2 <host> - [build] rustdoc 2 <host> - [doc] rustc 2 <host> -> std 2 <target1> crates=[] - [dist] rustc 2 <host> -> json-docs 3 <target1> + [doc] rustc 1 <host> -> std 1 <target1> crates=[] + [dist] rustc 1 <host> -> json-docs 2 <target1> [dist] mingw <target1> - [build] rustc 2 <host> -> std 2 <target1> - [dist] rustc 2 <host> -> std 2 <target1> + [dist] rustc 1 <host> -> std 1 <target1> "); } |
