-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Make rpath usage optional #5219
Comments
Why is this problematic for packaging? Is it because the rpath values end up with the wrong values? Each crate's rpath has several values, one of which is supposed to be the final installation location (controlled with |
In general Fedora recommends to not use rpaths [0], because the paths are hardcoded in the binary. Fedora preferres to point the dynamic linker to the appropriate paths [1]. [0] https://fedoraproject.org/wiki/Packaging:Guidelines#Beware_of_Rpath |
The following rpath is used in e.g. the cargo binary:
The rpath referres to rpm's buildroot, where the lib won't stay (it will be instaled to |
Thanks for those links. We do generate rpaths with the expectation that some of them will be invalidated by moving the binaries around. It's possible we could consider removing rpath, but it sure is nice to not think about dynamic loading when running binaries out of my build directory. We could easily add a We could also just remove rpath completely - it doesn't work on windows anyway. Another thing to consider is that, if we just used rustpkg for all builds, and let rustpkg install all libraries at a known location, then we might be able to conveniently not use rpath while still doing the right thing at load time. Can user directories like |
Yes - I can fully understand how easy running rust in the build directory is when using rpaths :) You mention thet some libs might reside in |
Just to summarize my thoughts: If rpath is used, the rpath path beeing used should only use directories below To include libraries at buildtime or when using the binaries in the build directory I'd suggest using wrappers (isn't autotools doing it like this?) which set |
Any follow up thoughts? |
Our package manager will by default not be installing libraries to a system location and will instead put them in the user's directory, The behavior you recommend requires some deep changes to how Rust works, so need to be considered carefully. Does the current behavior prevent packaging in Fedora, and is there a minimal change we can make to unblock packaging? @graydon You'll probably be interested in this subject. |
Thanks for the rustpkg explanation. I think that I'll spend a bit more time with looking at Btw.: I noted that the libdir isn't configurabel. Fedora for example keeps x86_64 libs in (/usr)?/lib64, and i686 in (/usr)/lib. IIUIC this is currently not possible with rust as the libs will be installed to /usr/lib/arch-specific-path |
@fabiand The point about libdir is well taken and I updated #5223. I am not entirely sure how rustpkg does it's build now or how @catamorphism and @graydon intend for it to work, but based on the current language design I would expect that, yes, binaries installed to Currently there are several rpaths configured for each linked library so that they hopefully fall back to something useful when the libraries are moved around during install or during the bootstrapping process, something like:
Under this scheme I would expect that |
Yes, there are several rpaths used (seen in As said, system wide binaries are the best example for binaries where you don't want to many rpaths - including no rpaths pointing to some user dir. |
Please don't tag TJC :( |
Sorry, TJC! Maybe it's time to give in and start working on Rust :) Seriously though, sorry. I'm sure it's a real PITA. |
@thestinger mentioned that this is a security issue, which I didn't realize. Debian also says not to do this. |
By the way, it's possible to strip this with |
@brson I generally wonder why you don't add a user-specific |
We used to. Users kept forgetting and/or getting annoyed having to adjust it when running from a build dir. Rpaths made it possible to run foo/bar/rustc no matter which rustc you chose. |
@graydon right. IIUIC - I always feel like a noob when it comes to autotools - autotools are generating wrappers for binaries which are created during a build process and moves the original binaries to hiddend irectories. The wrappers are then modifying the environment (setting env vars etc) to achieve the same goal (so e.g. that rustc can be run from the dev directory without messing with the env vars yourself). I wonder if this could help. |
Okay, it's actually not autools which creates these wrappers but libtool: http://www.flameeyes.eu/autotools-mythbuster/libtool/wrappers.html |
Sorry, I didn't mean to imply a disinterest in fixing this better, just noting how it came to be. Also strongly disinterested in using libtool. Would prefer going back to telling users to set env vars. |
@graydon: How about defaulting to static linking (when it works)? Dynamic linking is valuable, but mostly for global installs handled by a package manager. Of course, if we end up with a bunch of tools using I think RPATH will just lead to confusion, and it's an easy security hole to leave open. |
I would be very happy to get static linking working well enough to make it a default in many such cases. But we ought to do the right thing when linking dynamically too. Is rpath-using- |
The absolute paths are the ones that can easily be a security issue, so Using the |
Nominating for milestone 2: backwards compatible. (The choice of whether one needs to put a setting in It also could well be that this is more appropriately assocated with milestone 1: well-defined. I suspect @catamorphism and @graydon have a more concrete notion about this. |
I don't have anything much to add to this despite it coming up for triage today. I think it has to be fixed still, I'm still happy to do it via whatever combination of static linking by default and use of |
accepted for backwards-compatible milestone |
I'm getting worried that we won't resolve this for 1.0. I agree this is important to fix. Here's my current suggestion:
With this logic the rust package itself could avoid rpath where distros have their own way of dealing with library paths. The rustc installed by these distros would still be rpathing user's crates for the sake of convenience. Is this an acceptable compromise or do distros want us to completely disable rpath? I'm afraid that doing so would provide an inconsistent developer experience depending on how rustc is acquired; if we need to do that then we instead must find a way to completely eliminate rpath. |
If we start to just statically link everything by default then rpath becomes much less important and we can just say it's up to users to figure it out if they opt into dynamic linking. |
@brson: I think we should completely remove absolute rpaths. It's okay to have $ORIGIN-based ones but it may not be a good default. I'm not sure what the answer is to that, but agree that static linking basically resolves this. |
By default, the compiler and libraries are all still built with rpaths, but this can be opted out of with --disable-rpath to ./configure or --no-rpath to rustc. cc rust-lang#5219
By default, the compiler and libraries are all still built with rpaths, but this can be opted out of with --disable-rpath to ./configure or --no-rpath to rustc. Closes #5219
By default, the compiler and libraries are all still built with rpaths, but this can be opted out of with --disable-rpath to ./configure or --no-rpath to rustc. Closes #5219
By default, the compiler and libraries are all still built with rpaths, but this can be opted out of with --disable-rpath to ./configure or --no-rpath to rustc. cc rust-lang#5219
It doesn't appear that this is fully working. There are still rpaths in the binaries when configured with /usr/bin/rustc: RPATH=$ORIGIN/../lib:/build/rust-git/src/rust/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib:/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib |
What steps did you follow to having the rpath show up? I thought I double checked on linux that the configure flag worked, but I may have overlooked something. |
All I can tell you is that it still has rpaths when building with |
By default, the compiler and libraries are all still built with rpaths, but this can be opted out of with --disable-rpath to ./configure or --no-rpath to rustc. cc rust-lang#5219
If let else mutex changelog: Adds lint to catch incorrect use of `Mutex::lock` in `if let` expressions with lock calls in any of the blocks. closes: rust-lang#5219
Currently (something after 0.5) rustc (IIUIC) is using rpaths to point libs and binaries to the appropriate locations. This is problematic when rustc and the other libs/bins are package e.g. for Fedora.
The rpath usage should be made optional - /etc/ld.so.conf.d can be used instead - and LD_LIBRARY_PATH.
The text was updated successfully, but these errors were encountered: