Skip to content
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

lib/rustlib/<arch>/bin/gcc-ld/ld should be wrapped for -Clinker-flavor=gcc-lld #46

Closed
oxalica opened this issue Jul 28, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@oxalica
Copy link
Owner

oxalica commented Jul 28, 2021

The option is available on nightly now: rust-lang/rust#85961
And it may be enabled by default on Ubuntu in the future: rust-lang/rust#71515

Currently the ld executable (actually lld) runs but failed to find C libraries. It should to be wrapped by wrapBintoolsWith.

@oxalica oxalica added the bug Something isn't working label Jul 30, 2021
@sledgehammervampire
Copy link

sledgehammervampire commented Jul 31, 2021

Wait, so -Z gcc-ld=lld not working for C libraries might be a Nix thing, and not rustc in general?

Edit: Nope. I tried -C link-arg=-fuse-ld=lld, which I think uses the nixpkgs lld, and my project with a C dependency doesn't work, unlike without the flag.

@oxalica
Copy link
Owner Author

oxalica commented Jul 31, 2021

Wait, so -Z gcc-ld=lld not working for C libraries might be a Nix thing, and not rustc in general?

It's not about C libraries. Currently it doesn't work for a simple rust hello world program, since std requires -lc.

I tried -C link-arg=-fuse-ld=lld, which I think uses the nixpkgs lld

It may be another issue. Currently I'm using the rust-lld shipped by rust toolchain with some manual wrapping and it works fine with things like openssl. But of course, you still need nix-shell -p openssl pkg-config to let the build script find the library first.

@sledgehammervampire
Copy link

On my machine, using -Z gcc-ld=lld and -C link-arg=-fuse-ld=lld with the Rust from this overlay works for pure-Rust projects. Does it not work for you?

@oxalica
Copy link
Owner Author

oxalica commented Aug 13, 2021

On my machine, using -Z gcc-ld=lld and -C link-arg=-fuse-ld=lld with the Rust from this overlay works for pure-Rust projects.

Oh yes, it seems working now. Weird.

I also tested openssl which links to C library. It also works fine in nix-shell -p openssl pkg-config environment.

@oxalica oxalica closed this as completed Aug 13, 2021
@sledgehammervampire
Copy link

sledgehammervampire commented Aug 22, 2021

Hmm, that's strange. When I use a dependency with openssl-sys, say reqwest 0.11.4, I get this error when running a compiled program:

target/debug/downloader: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants