Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6864a5b

Browse files
committed
Use std uplifting more often
1 parent 41563c7 commit 6864a5b

File tree

5 files changed

+20
-40
lines changed

5 files changed

+20
-40
lines changed

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

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -99,28 +99,12 @@ impl Std {
9999
deps
100100
}
101101

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

@@ -228,7 +212,7 @@ impl Step for Std {
228212
// Stage of the stdlib that we're building
229213
let stage = build_compiler.stage;
230214

231-
if Self::should_be_uplifted_from_stage_1(builder, build_compiler.stage, target) {
215+
if Self::should_be_uplifted_from_stage_1(builder, build_compiler.stage) {
232216
let build_compiler_for_std_to_uplift = builder.compiler(1, builder.host_target);
233217
let stage_1_stamp = builder.std(build_compiler_for_std_to_uplift, target);
234218

‎src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl Step for JsonDocs {
115115

116116
fn make_run(run: RunConfig<'_>) {
117117
run.builder.ensure(JsonDocs {
118-
build_compiler: run.builder.compiler_for_std(run.builder.top_stage, run.target),
118+
build_compiler: run.builder.compiler_for_std(run.builder.top_stage),
119119
target: run.target,
120120
});
121121
}
@@ -769,7 +769,7 @@ pub struct Std {
769769

770770
impl Std {
771771
pub fn new(builder: &Builder<'_>, target: TargetSelection) -> Self {
772-
Std { build_compiler: builder.compiler_for_std(builder.top_stage, target), target }
772+
Std { build_compiler: builder.compiler_for_std(builder.top_stage), target }
773773
}
774774
}
775775

‎src/bootstrap/src/core/build_steps/doc.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,7 @@ impl Step for Std {
616616
return;
617617
}
618618
run.builder.ensure(Std {
619-
build_compiler: run
620-
.builder
621-
.compiler_for_std(run.builder.top_stage, run.builder.host_target),
619+
build_compiler: run.builder.compiler_for_std(run.builder.top_stage),
622620
target: run.target,
623621
format: if run.builder.config.cmd.json() {
624622
DocumentationFormat::Json

‎src/bootstrap/src/core/builder/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,10 +1373,11 @@ impl<'a> Builder<'a> {
13731373
/// we need:
13741374
/// - stage 2 libstd for target2 (uplifted from stage 1, where it was built by target1 rustc)
13751375
/// - stage 2 rustc for target2
1376+
///
13761377
/// However, without this optimization, we would also build stage 2 rustc for **target1**,
13771378
/// which is completely wasteful.
1378-
pub fn compiler_for_std(&self, stage: u32,target:TargetSelection) -> Compiler {
1379-
if compile::Std::should_be_uplifted_from_stage_1(self, stage, target) {
1379+
pub fn compiler_for_std(&self, stage: u32) -> Compiler {
1380+
if compile::Std::should_be_uplifted_from_stage_1(self, stage) {
13801381
self.compiler(1, self.host_target)
13811382
} else {
13821383
self.compiler(stage, self.host_target)

‎src/bootstrap/src/core/builder/tests.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,7 @@ mod snapshot {
10661066
[build] rustc 1 <host> -> rustc 2 <target1>
10671067
[build] rustc 2 <host> -> std 2 <host>
10681068
[build] rustc 2 <host> -> std 2 <target1>
1069+
[build] rustc 1 <host> -> std 1 <target2>
10691070
[build] rustc 2 <host> -> std 2 <target2>
10701071
");
10711072
}
@@ -1295,16 +1296,15 @@ mod snapshot {
12951296
[dist] docs <target1>
12961297
[doc] rustc 1 <host> -> std 1 <host> crates=[]
12971298
[dist] rustc 1 <host> -> json-docs 2 <host>
1298-
[build] rustdoc 2 <host>
1299-
[doc] rustc 2 <host> -> std 2 <target1> crates=[]
1300-
[dist] rustc 2 <host> -> json-docs 3 <target1>
1299+
[doc] rustc 1 <host> -> std 1 <target1> crates=[]
1300+
[dist] rustc 1 <host> -> json-docs 2 <target1>
13011301
[dist] mingw <host>
13021302
[dist] mingw <target1>
1303+
[build] rustdoc 2 <host>
13031304
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
13041305
[dist] rustc <host>
13051306
[dist] rustc 1 <host> -> std 1 <host>
1306-
[build] rustc 2 <host> -> std 2 <target1>
1307-
[dist] rustc 2 <host> -> std 2 <target1>
1307+
[dist] rustc 1 <host> -> std 1 <target1>
13081308
[dist] rustc 1 <host> -> rustc-dev 2 <host>
13091309
[dist] src <>
13101310
[dist] reproducible-artifacts <host>
@@ -1495,13 +1495,10 @@ mod snapshot {
14951495
[doc] rustc 1 <host> -> releases 2 <target1>
14961496
[build] rustc 0 <host> -> RustInstaller 1 <host>
14971497
[dist] docs <target1>
1498-
[build] rustc 1 <host> -> rustc 2 <host>
1499-
[build] rustdoc 2 <host>
1500-
[doc] rustc 2 <host> -> std 2 <target1> crates=[]
1501-
[dist] rustc 2 <host> -> json-docs 3 <target1>
1498+
[doc] rustc 1 <host> -> std 1 <target1> crates=[]
1499+
[dist] rustc 1 <host> -> json-docs 2 <target1>
15021500
[dist] mingw <target1>
1503-
[build] rustc 2 <host> -> std 2 <target1>
1504-
[dist] rustc 2 <host> -> std 2 <target1>
1501+
[dist] rustc 1 <host> -> std 1 <target1>
15051502
");
15061503
}
15071504

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /