Skip to content

Commit 935bc19

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 935bc19

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/bootstrap/compile.rs

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

0 commit comments

Comments
 (0)