Skip to content

Commit 82d23a6

Browse files
committed
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.
1 parent 56ada88 commit 82d23a6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/bootstrap/compile.rs

+17
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,23 @@ impl Step for Std {
158158
target_deps.extend(copy_third_party_objects(builder, &compiler, target));
159159
target_deps.extend(copy_self_contained_objects(builder, &compiler, target));
160160

161+
// The LLD wrappers and `rust-lld` are self-contained linking components that can be
162+
// necessary to link the stdlib on some targets. We'll also need to copy these binaries to
163+
// the `stage0-sysroot` to ensure the linker is found when bootstrapping on such a target.
164+
if compiler.stage == 0 && compiler.host == builder.config.build {
165+
// We want to copy the host `bin` folder within the `rustlib` folder in the sysroot.
166+
let src_sysroot_bin = builder
167+
.rustc_snapshot_sysroot()
168+
.join("lib")
169+
.join("rustlib")
170+
.join(&compiler.host.triple)
171+
.join("bin");
172+
let target_sysroot_bin =
173+
builder.sysroot_libdir(compiler, target).parent().unwrap().join("bin");
174+
t!(fs::create_dir_all(&target_sysroot_bin));
175+
builder.cp_r(&src_sysroot_bin, &target_sysroot_bin);
176+
}
177+
161178
let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "build");
162179
std_cargo(builder, target, compiler.stage, &mut cargo);
163180
for krate in &*self.crates {

0 commit comments

Comments
 (0)