Auto merge of #116276 - lqd:lld-sysroot, r=onur-ozkan
bootstrap: copy self-contained linking components to `stage0-sysroot` I hit this issue while trying to bootstrap using a rustc where `rust-lld` is used by default: this was the cause of the failure to profile rustc-perf's bootstrap benchmark in https://github.com/rust-lang/rust/pull/113382. `stage0-sysroot` currently only has libs and self-contained objects, not the other self-contained linking components yet. Most notably, it does not contain the linker and wrappers that we build, and that rustup distributes. If you try to bootstrap using the bootstrap compiler's `rust-lld`, it will fail to link std at stage0 because `rust-lld` and the `gcc-ld` wrappers, will not be found in `stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/bin`. This PR copies the `bin` directory next to the `lib` directory when `rust.lld` is enabled in the config (though maybe it could be done unconditionally, the fact that we need it to link does not necessarily mean that we'd want to build and provide it at stage1). cc `@Kobzol` who also encountered this issue while using lld during bootstrap.
This commit is contained in:
commit
b0889cb4ed
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user