about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRémy Rakic <remy.rakic+github@gmail.com>2023-09-25 19:27:48 +0000
committerRémy Rakic <remy.rakic+github@gmail.com>2023-10-01 10:35:30 +0000
commit82d23a6275f3476f5f9520dac07b218872a9cd2b (patch)
tree14a0717d9d4c22d7f5b9302b920ccbc771d7383f
parent56ada88e7e1f00e6c6e8a0957de295bc0e2d64f7 (diff)
downloadrust-82d23a6275f3476f5f9520dac07b218872a9cd2b.tar.gz
rust-82d23a6275f3476f5f9520dac07b218872a9cd2b.zip
bootstrap: copy self-contained linking components to stage0-sysroot
otherwise bootstrap will fail to link the stdlib on a target using the
self-contained linker: rust-lld will not be found since it's currently
not in the stage0-sysroot.
-rw-r--r--src/bootstrap/compile.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index 292ccc5780f..daf0798357b 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -158,6 +158,23 @@ impl Step for Std {
         target_deps.extend(copy_third_party_objects(builder, &compiler, target));
         target_deps.extend(copy_self_contained_objects(builder, &compiler, target));
 
+        // The LLD wrappers and `rust-lld` are self-contained linking components that can be
+        // necessary to link the stdlib on some targets. We'll also need to copy these binaries to
+        // the `stage0-sysroot` to ensure the linker is found when bootstrapping on such a target.
+        if compiler.stage == 0 && compiler.host == builder.config.build {
+            // We want to copy the host `bin` folder within the `rustlib` folder in the sysroot.
+            let src_sysroot_bin = builder
+                .rustc_snapshot_sysroot()
+                .join("lib")
+                .join("rustlib")
+                .join(&compiler.host.triple)
+                .join("bin");
+            let target_sysroot_bin =
+                builder.sysroot_libdir(compiler, target).parent().unwrap().join("bin");
+            t!(fs::create_dir_all(&target_sysroot_bin));
+            builder.cp_r(&src_sysroot_bin, &target_sysroot_bin);
+        }
+
         let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "build");
         std_cargo(builder, target, compiler.stage, &mut cargo);
         for krate in &*self.crates {