Skip to content

Change to use self-contained lld by default in rustup nightly artifacts breaks native linking #168

@Nemo157

Description

@Nemo157

rust-lang/rust#71515 (comment) mentions that the next nightly will switch to using the self-contained lld by default instead of the system linker. Trying to do some pre-testing of this setup by manually enabling the new defaults in a project with a native dependency indicates that this causes issues with library loading (presumably something rpath related, but I've never dug into the details of how that is handled normally):

> cargo rustc -- -Clink-self-contained=+linker -Clinker-flavor=gnu-lld-cc
   Compiling u2f-touch-detector v0.1.0 (/home/nemo157/sources/u2f-touch-detector)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.58s

> $CARGO_HOME/target/shared/x86_64-unknown-linux-gnu/debug/u2f-touch-detector --help
/run/user/1000/cargo-home/target/shared/x86_64-unknown-linux-gnu/debug/u2f-touch-detector: error while loading shared libraries: libudev.so.1: cannot open shared object file: No such file or directory

The PR linked from the tracking issue mentions that the workaround will be to use -Zlinker-features=-lld.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions