-
Notifications
You must be signed in to change notification settings - Fork 894
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
rustup doesn't set LD_LIBRARY_PATH #932
Comments
Thanks for the bug report @Kingsquee. You are correct that dynamically linked libraries do not work correctly under rustup. This is an unfortunate tradeoff rustup makes to enable toolchain multiplexing. Dynamic linking in Rust is not well supported generally and is not considered a best practice today. rustup has a workaround for this problem in that There is frankly no solution on the horizon to fix this problem generally. Other single-toolchain installation methods will remain available. |
@brson There is a very straight-forward solution to this problem: have cargo copy the required dynamic libraries to the output directory. (On linux the compiler may also need to set This solves numerous issues with dynamic linking in one go, and makes it trivial to distribute rust binaries with all required dylibs. |
Having a .rustup/toolchains/current dir would make rustc usable, as intended. |
@Kingsquee That's not possible for multiple reasons:
|
|
@rustbot label: +O-linux |
The workaround |
In what way does it "not seem to work any more" ? indolence(git)(🦀🏠)% cat > test.rs
fn main(){println!("foo");}
indolence(git)(🦀🏠)% rustc test.rs -C prefer-dynamic
indolence(git)(🦀🏠)% ldd test
linux-vdso.so.1 (0x00007ffc447cd000)
libstd-05b39ac0cb4c5688.so => not found
libgcc_s.so.1 => /nix/store/65hafbsx91127farbmyyv4r5ifgjdg43-glibc-2.33-117/lib/libgcc_s.so.1 (0x00007f05e084d000)
libc.so.6 => /nix/store/65hafbsx91127farbmyyv4r5ifgjdg43-glibc-2.33-117/lib/libc.so.6 (0x00007f05e0678000)
/nix/store/65hafbsx91127farbmyyv4r5ifgjdg43-glibc-2.33-117/lib/ld-linux-x86-64.so.2 => /nix/store/65hafbsx91127farbmyyv4r5ifgjdg43-glibc-2.33-117/lib64/ld-linux-x86-64.so.2 (0x00007f05e086e000)
indolence(git)(🦀🏠)% ./test
./test: error while loading shared libraries: libstd-05b39ac0cb4c5688.so: cannot open shared object file: No such file or directory
zsh: exit 127 ./test
indolence(git)(🦀🏠)% rustup run stable ./test
foo
indolence(git)(🦀🏠)% |
OS: Fedora 24
Steps to reproduce:
test.rs
$ rustc test.rs
outputsfoo
$ rustc test.rs -C prefer-dynamic
outputserror while loading shared libraries: libstd-f5a209a9.so: cannot open shared object file: No such file or directory
The old rust installer used system paths, which meant one could simply install rustc and away we go. Since the
rustup
installer became standard, any code that requires-C prefer-dynamic
no longer runs out of the box, as LD_LIBRARY_PATH is not automatically updated with libstd's location.This renders a compiler flag on the stable release channel useless, and completely breaks the idea of Stability as a Deliverable.
Rust code also just became vastly more awkward to redistribute to less experienced developers. The fact it "just works" out of the box was one of the remaining reasons I've continued using Rust - going from source code to a working application was "install compiler, compile app, enjoy". Distributing free software is actually practical with this model. If I wanted to teach people to fiddle with paths I'd use C/++.
This is obviously a very angry bug report, but I hope its importance is clear, irregardless of however marginal its use case may seem. Please feel free to tell me I pushed the wrong button or something so I can continue being happy in life.
The text was updated successfully, but these errors were encountered: