rust-overlay icon indicating copy to clipboard operation
rust-overlay copied to clipboard

wrap linkers

Open yshui opened this issue 4 months ago • 2 comments

rustup toolchains come with their own linkers, and is used for linking rust programs. e.g.:

"-B/nix/store/cvvrlhx1wq0bcpiv06rc4q6r06spc4nz-rust-with-components-2025-08-04/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld"

which is part of the linker command. under /nix/store/cvvrlhx1wq0bcpiv06rc4q6r06spc4nz-rust-with-components-2025-08-04/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld there are a bunch of variants of lld:

 ld.lld ld64.lld  lld-link  wasm-ld

which all are just wrappers for rust-lld.

problem is, rust-lld is not wrapped, in the sense that it won't add extra nix rpaths to the resulting executable. which means the result cannot run without a properly set LD_LIBRARY_PATH.

rust-overlay should wrap rust-lld.

yshui avatar Aug 05 '25 16:08 yshui

a quick workaround:

export RUSTFLAGS="-C link-self-contained=n"

then you need to add llvmPackages.bintools to your buildInputs.

yshui avatar Aug 05 '25 17:08 yshui

This should already be fixed more than 1 year ago since #171. The latest nightly also uses the contained linker by default on x86_64-linux now, and it works fine for me.

Could you double check the rust-overlay revision you are using and provide a reproduction code? What command are you running and what is the error message?

oxalica avatar Sep 15 '25 09:09 oxalica

i am so sorry... i have too many instances of rust compilers laying around. i looked again and i was actually using the one from fenix when i found this problem. i reported to the wrong project.

yshui avatar Dec 16 '25 23:12 yshui