Skip to content

Commit c8c0119

Browse files
committed
Auto merge of #145472 - Kobzol:bootstrap-dist, r=jieyouxu
Enforce in bootstrap that dist and install must have stage at least 1 This is a continuation of my efforts to fix staging in bootstrap after the stage0 redesign. This PR gets rid of all `compiler_for` usages in the `dist` steps 🎉 The only remaining usages are in the `test` steps, which are my next goal, and which will be the final boss.. both because they are quite tricky, and because most of the the rest of the steps have been already fixed. The changes are relatively straightforward, `x dist` defaults to stage 2, so in that case we want to use a stage 1 build compiler for everything (except stdlib, but we usually use it even there because of uplifting). What I didn't fix yet are the docs steps, because they are *very* implicit right now, and fixing them deserves its own PR. The first commit reverts the tests that I accidentally removed in #145340 🤦‍♂️ I did it in this PR to avoid further git conflicts.. Best reviewed commit-by-commit. r? `@jieyouxu` try-job: dist-i686-linux try-job: dist-armhf-linux try-job: dist-x86_64-linux try-job: dist-x86_64-msvc try-job: dist-apple-various try-job: dist-x86_64-apple
2 parents d20509c + 7da375e commit c8c0119

File tree

11 files changed

+580
-262
lines changed

11 files changed

+580
-262
lines changed

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,30 @@ impl Std {
9696
}
9797
deps
9898
}
99+
100+
/// Returns true if the standard library will be uplifted from stage 1 for the given
101+
/// `build_compiler` (which determines the stdlib stage) and `target`.
102+
///
103+
/// Uplifting is enabled if we're building a stage2+ libstd, full bootstrap is
104+
/// disabled and we have a stage1 libstd already compiled for the given target.
105+
pub fn should_be_uplifted_from_stage_1(
106+
builder: &Builder<'_>,
107+
stage: u32,
108+
target: TargetSelection,
109+
) -> bool {
110+
stage > 1
111+
&& !builder.config.full_bootstrap
112+
// This estimates if a stage1 libstd exists for the given target. If we're not
113+
// cross-compiling, it should definitely exist by the time we're building a stage2
114+
// libstd.
115+
// Or if we are cross-compiling, and we are building a cross-compiled rustc, then that
116+
// rustc needs to link to a cross-compiled libstd, so again we should have a stage1
117+
// libstd for the given target prepared.
118+
// Even if we guess wrong in the cross-compiled case, the worst that should happen is
119+
// that we build a fresh stage1 libstd below, and then we immediately uplift it, so we
120+
// don't pay the libstd build cost twice.
121+
&& (target == builder.host_target || builder.config.hosts.contains(&target))
122+
}
99123
}
100124

101125
impl Step for Std {
@@ -193,22 +217,7 @@ impl Step for Std {
193217
// Stage of the stdlib that we're building
194218
let stage = build_compiler.stage;
195219

196-
// If we're building a stage2+ libstd, full bootstrap is
197-
// disabled and we have a stage1 libstd already compiled for the given target,
198-
// then simply uplift a previously built stage1 library.
199-
if build_compiler.stage > 1
200-
&& !builder.config.full_bootstrap
201-
// This estimates if a stage1 libstd exists for the given target. If we're not
202-
// cross-compiling, it should definitely exist by the time we're building a stage2
203-
// libstd.
204-
// Or if we are cross-compiling, and we are building a cross-compiled rustc, then that
205-
// rustc needs to link to a cross-compiled libstd, so again we should have a stage1
206-
// libstd for the given target prepared.
207-
// Even if we guess wrong in the cross-compiled case, the worst that should happen is
208-
// that we build a fresh stage1 libstd below, and then we immediately uplift it, so we
209-
// don't pay the libstd build cost twice.
210-
&& (target == builder.host_target || builder.config.hosts.contains(&target))
211-
{
220+
if Self::should_be_uplifted_from_stage_1(builder, build_compiler.stage, target) {
212221
let build_compiler_for_std_to_uplift = builder.compiler(1, builder.host_target);
213222
builder.std(build_compiler_for_std_to_uplift, target);
214223

0 commit comments

Comments
 (0)