-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change to use self-contained lld by default in rustup nightly artifacts breaks native linking #168
Comments
I assume we'll probably need to wrap |
Hmm, finally got round to testing it on the latest nightly and it seems like it's not active by default when installed via the overlay. I'm not sure why though, |
I found out why, I use > CARGO_PROFILE_DEV_CODEGEN_BACKEND=llvm cargo run -- --help
Compiling u2f-touch-detector v0.1.0 (/home/nemo157/sources/u2f-touch-detector)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.61s
Running `/run/user/1000/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 |
I tried to figure out how to wrap the binaries, but |
The wrap() {
local dst="$1"
local wrapper="$2"
export prog="$3"
export use_response_file_by_default=${if isCCTools then "1" else "0"}
substituteAll "$wrapper" "$out/bin/$dst"
chmod +x "$out/bin/$dst"
} You could then reference the ld wrapper like so: mv $out/bin/rust-lld $out/bin/.rust-lld-unwrapped
wrap $out/bin/rust-lld \
${pkgs.path + /pkgs/build-support/bintools-wrapper/ld-wrapper.sh} \
$out/bin/.rust-lld-unwrapped Though there's a bunch of other things it expects substituted:
coreutils_bin = lib.getBin coreutils; # pkgs.coreutils but probably unnecessary?
suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config; # pkgs.stdenv.targetPlatform Edit: Ah, this needs more bintools stuff in |
Alternatively, maybe we could extend |
Thanks for the investment of the ld-wrapper. I ends up copying part of the wrapper implementation to make it actually work. I created #171 and it works for me now. I'm looking for tests and feedback from people involving here. |
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):The PR linked from the tracking issue mentions that the workaround will be to use
-Zlinker-features=-lld
.The text was updated successfully, but these errors were encountered: