Skip to content

Commit 9eb9b5a

Browse files
committed
Build host library when cross-compiling ToolTarget tools
1 parent 3abe5f9 commit 9eb9b5a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ pub fn prepare_tool_cargo(
334334
/// Determines how to build a `ToolTarget`, i.e. which compiler should be used to compile it.
335335
/// The compiler stage is automatically bumped if we need to cross-compile a stage 1 tool.
336336
pub enum ToolTargetBuildMode {
337-
/// Build the tool using rustc that corresponds to the selected CLI stage.
337+
/// Build the tool for the given `target` using rustc that corresponds to the top CLI
338+
/// stage.
338339
Build(TargetSelection),
339340
/// Build the tool so that it can be attached to the sysroot of the passed compiler.
340341
/// Since we always dist stage 2+, the compiler that builds the tool in this case has to be
@@ -366,7 +367,10 @@ pub(crate) fn get_tool_target_compiler(
366367
} else {
367368
// If we are cross-compiling a stage 1 tool, we cannot do that with a stage 0 compiler,
368369
// so we auto-bump the tool's stage to 2, which means we need a stage 1 compiler.
369-
builder.compiler(build_compiler_stage.max(1), builder.host_target)
370+
let build_compiler = builder.compiler(build_compiler_stage.max(1), builder.host_target);
371+
// We also need the host stdlib to compile host code (proc macros/build scripts)
372+
builder.std(build_compiler, builder.host_target);
373+
build_compiler
370374
};
371375
builder.std(compiler, target);
372376
compiler

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,7 @@ mod snapshot {
985985
.render_steps(), @r"
986986
[build] llvm <host>
987987
[build] rustc 0 <host> -> rustc 1 <host>
988+
[build] rustc 1 <host> -> std 1 <host>
988989
[build] rustc 1 <host> -> std 1 <target1>
989990
[build] rustc 1 <host> -> cargo 2 <target1>
990991
");

0 commit comments

Comments
 (0)