about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2025-08-08 08:57:44 +0200
committerJakub Beránek <berykubik@gmail.com>2025-08-08 08:57:44 +0200
commit9eb9b5a191807e823ade467902f5e663f6ba9341 (patch)
tree00d76c2933ed640a9e83659960096dc52f7a844b /src
parent3abe5f9dbef7046d8c63b7c2f782ebe6142881ee (diff)
downloadrust-9eb9b5a191807e823ade467902f5e663f6ba9341.tar.gz
rust-9eb9b5a191807e823ade467902f5e663f6ba9341.zip
Build host library when cross-compiling `ToolTarget` tools
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/src/core/build_steps/tool.rs8
-rw-r--r--src/bootstrap/src/core/builder/tests.rs1
2 files changed, 7 insertions, 2 deletions
diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs
index 7b0ef942abe..aa00cd03c5b 100644
--- a/src/bootstrap/src/core/build_steps/tool.rs
+++ b/src/bootstrap/src/core/build_steps/tool.rs
@@ -334,7 +334,8 @@ pub fn prepare_tool_cargo(
 /// Determines how to build a `ToolTarget`, i.e. which compiler should be used to compile it.
 /// The compiler stage is automatically bumped if we need to cross-compile a stage 1 tool.
 pub enum ToolTargetBuildMode {
-    /// Build the tool using rustc that corresponds to the selected CLI stage.
+    /// Build the tool for the given `target` using rustc that corresponds to the top CLI
+    /// stage.
     Build(TargetSelection),
     /// Build the tool so that it can be attached to the sysroot of the passed compiler.
     /// 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(
     } else {
         // If we are cross-compiling a stage 1 tool, we cannot do that with a stage 0 compiler,
         // so we auto-bump the tool's stage to 2, which means we need a stage 1 compiler.
-        builder.compiler(build_compiler_stage.max(1), builder.host_target)
+        let build_compiler = builder.compiler(build_compiler_stage.max(1), builder.host_target);
+        // We also need the host stdlib to compile host code (proc macros/build scripts)
+        builder.std(build_compiler, builder.host_target);
+        build_compiler
     };
     builder.std(compiler, target);
     compiler
diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs
index 41fdb905e6a..1914e24fa35 100644
--- a/src/bootstrap/src/core/builder/tests.rs
+++ b/src/bootstrap/src/core/builder/tests.rs
@@ -985,6 +985,7 @@ mod snapshot {
                 .render_steps(), @r"
         [build] llvm <host>
         [build] rustc 0 <host> -> rustc 1 <host>
+        [build] rustc 1 <host> -> std 1 <host>
         [build] rustc 1 <host> -> std 1 <target1>
         [build] rustc 1 <host> -> cargo 2 <target1>
         ");