8000 Auto merge of #116276 - lqd:lld-sysroot, r=onur-ozkan · compiler-errors/rust@b0889cb · GitHub
[go: up one dir, main page]

Skip to content
  • Commit b0889cb

    Browse files
    committed
    Auto merge of rust-lang#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 rust-lang#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.
    2 parents 781ebbe + 82d23a6 commit b0889cb

    File tree

    1 file changed

    +17
    -0
    lines changed

    1 file changed

    +17
    -0
    lines changed

    src/bootstrap/compile.rs

    Lines changed: 17 additions & 0 deletions
    Origina CA9C l 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)
    0