Skip to content

Commit 5fde111

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 5fde111

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/bootstrap/compile.rs

+16
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,22 @@ 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 `bin` folder next to the sysroot libdir.
166+
let src_sysroot_bin = builder
167+
.rustc_snapshot_libdir()
168+
.join("rustlib")
169+
.join(&compiler.host.triple)
170+
.join("bin");
171+
let target_sysroot_bin =
172+
builder.sysroot_libdir(compiler, target).parent().unwrap().join("bin");
173+
t!(fs::create_dir_all(&target_sysroot_bin));
174+
builder.cp_r(&src_sysroot_bin, &target_sysroot_bin);
175+
}
176+
161177
let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "build");
162178
std_cargo(builder, target, compiler.stage, &mut cargo);
163179
for krate in &*self.crates {

0 commit comments

Comments
 (0)