Skip to content

Commit

Permalink
bootstrap: copy self-contained linking components to stage0-sysroot
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lqd committed Sep 29, 2023
1 parent 56ada88 commit 935bc19
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,25 @@ 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
&& builder.config.lld_enabled
{
// We want to copy the `bin` folder next to the sysroot libdir.
let src_sysroot_bin = builder
.rustc_snapshot_libdir()
.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 {
Expand Down

0 comments on commit 935bc19

Please sign in to comment.