Skip to content

Commit b13717b

Browse files
committed
Remove usage of compiler_for from the compile::Std step
1 parent 6b4ef85 commit b13717b

File tree

2 files changed

+18
-38
lines changed

2 files changed

+18
-38
lines changed

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

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -203,51 +203,31 @@ impl Step for Std {
203203

204204
let mut target_deps = builder.ensure(StartupObjects { compiler: build_compiler, target });
205205

206-
let compiler_to_use =
207-
builder.compiler_for(build_compiler.stage, build_compiler.host, target);
208-
trace!(?compiler_to_use);
209-
210-
if compiler_to_use != build_compiler
211-
// Never uplift std unless we have compiled stage 1; if stage 1 is compiled,
212-
// uplift it from there.
213-
//
214-
// FIXME: improve `fn compiler_for` to avoid adding stage condition here.
215-
&& build_compiler.stage > 1
206+
// Stage of the stdlib that we're building
207+
let stage = build_compiler.stage;
208+
209+
// If we're building a stage2+ libstd, full bootstrap is
210+
// disabled and we're not cross-compiling, then simply uplift a previously built
211+
// stage1 library.
212+
if build_compiler.stage > 1
213+
&& !builder.config.full_bootstrap
214+
&& target == builder.host_target
216215
{
217-
trace!(
218-
?compiler_to_use,
219-
?build_compiler,
220-
"compiler != compiler_to_use, uplifting library"
221-
);
222-
223-
builder.std(compiler_to_use, target);
224-
let msg = if compiler_to_use.host == target {
225-
format!(
226-
"Uplifting library (stage{} -> stage{})",
227-
compiler_to_use.stage, build_compiler.stage
228-
)
229-
} else {
230-
format!(
231-
"Uplifting library (stage{}:{} -> stage{}:{})",
232-
compiler_to_use.stage, compiler_to_use.host, build_compiler.stage, target
233-
)
234-
};
235-
builder.info(&msg);
216+
let build_compiler_for_std_to_uplift = builder.compiler(1, builder.host_target);
217+
builder.std(build_compiler_for_std_to_uplift, target);
218+
builder.info(&format!(
219+
"Uplifting library (stage{} -> stage{stage})",
220+
build_compiler_for_std_to_uplift.stage
221+
));
236222

237223
// Even if we're not building std this stage, the new sysroot must
238224
// still contain the third party objects needed by various targets.
239225
self.copy_extra_objects(builder, &build_compiler, target);
240226

241-
builder.ensure(StdLink::from_std(self, compiler_to_use));
227+
builder.ensure(StdLink::from_std(self, build_compiler_for_std_to_uplift));
242228
return;
243229
}
244230

245-
trace!(
246-
?compiler_to_use,
247-
?build_compiler,
248-
"compiler == compiler_to_use, handling not-cross-compile scenario"
249-
);
250-
251231
target_deps.extend(self.copy_extra_objects(builder, &build_compiler, target));
252232

253233
// We build a sysroot for mir-opt tests using the same trick that Miri does: A check build

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,10 @@ mod snapshot {
588588
[build] rustc 1 <host> -> std 1 <host>
589589
[build] rustc 1 <host> -> rustc 2 <host>
590590
[build] rustc 2 <host> -> std 2 <host>
591-
[build] rustc 1 <host> -> std 1 <target1>
592591
[build] rustc 2 <host> -> std 2 <target1>
593592
[build] rustdoc 2 <host>
594593
[build] llvm <target1>
594+
[build] rustc 1 <host> -> std 1 <target1>
595595
[build] rustc 1 <host> -> rustc 2 <target1>
596596
[build] rustdoc 2 <target1>
597597
");
@@ -730,9 +730,9 @@ mod snapshot {
730730
[build] rustc 1 <host> -> rustc 2 <host>
731731
[build] rustc 1 <host> -> LldWrapper 2 <host>
732732
[build] rustc 1 <host> -> LlvmBitcodeLinker 2 <host>
733-
[build] rustc 1 <host> -> std 1 <target1>
734733
[build] rustc 2 <host> -> std 2 <target1>
735734
[build] llvm <target1>
735+
[build] rustc 1 <host> -> std 1 <target1>
736736
[build] rustc 1 <host> -> rustc 2 <target1>
737737
[build] rustc 1 <host> -> LldWrapper 2 <target1>
738738
[build] rustc 1 <host> -> LlvmBitcodeLinker 2 <target1>

0 commit comments

Comments
 (0)