Skip to content

Commit f9464d8

Browse files
Auto merge of #145472 - Kobzol:bootstrap-dist, r=<try>
Enforce in bootstrap that dist and install must have stage at least 1 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 f605b57 + ad8384e commit f9464d8

File tree

10 files changed

+574
-253
lines changed

10 files changed

+574
-253
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)