-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
--enable-new-dtags should only be used for the GNU linker #46204
Comments
|
I (of course) am using NetBSD ;-) I don't quite understand your question - binutils is very portable, and there are lots of ELF systems that are not Linux and do neither use glibc nor the Linux rtld. Maybe a few of those have aliased DT_RUNPATH to DT_RPATH now (I don't know), but NetBSD has not and is not planing to do so. So what is probably easiest here is: check for gnu linker (so it accepts the option) and for the linux kernel (as that is closed what you can easily get to check for the exact rtld in use). Alternative: make use of RUNPATH vs RPATH explicitly selectable in the target definition. |
There is no such thing as the "Linux rtld". For example, I'm fairly certain this issue is not an issue on Debian/kFreeBSD.
If an OS uses the GNU linker as the system linker and not the GNU rtld, I'd say that's asking for trouble. There is (as evidenced by this issue) no guarantee that the produced binaries are going to be compatible. One more piece of evidence that this is not somehow “Linux's fault”: DT_RUNPATH has been part of the ELF specification for over 17 years: http://www.sco.com/developers/gabi/2000-07-17/ch5.dynamic.html I'd prefer one of the following actions to be taken:
I looked at musl and it seems to be handling DT_RPATH and DT_RUNPATH equivalently. So I think everything would “just work” if Rust only passes |
OK, I am a bit reluctant to state the following - we never met in real life and I fear it might come across slightly strange. Let me do it anyway and I'll owe you a beverage of your choice when we should ever meet at a conference or wherever: If I follow your line of thinking, I come to a different result:
:-) So back to rustc: nothing of this changes the way history happened, helps us support systems out there or improve rust portability. If noone beats me to it, I will try again to come up with a working patch that makes use of the ld(1) option an explicit choice in the back/target definition. This will take some time due to my current bootstrap issues and the linker option handling being hardcoded in the zero stage bootstrap binaries. Side note: I have to admit I was wrong at the start of this thread: DT_RUNPATH is not a Linuxism, Solaris (and maybe other SVr4 ELF systems) had DT_RPATH following the original spec too (but I don't know if their "native" linker made using DT_RUNPATH an option). |
I'm a little confused why I installed a VM from the NetBSD 7.1 ISO on the website (GENERIC.201703111743Z) and I seem to get both
So I am a little confused that (If you give me instructions on how to get an environment that matches yours, I'm happy to follow them, I just have not had the chance to learn as much about the BSDs as I'd like and so I don't really know how to install / upgrade things on this VM....) |
Also to be clear - I'm not expressing a strong opinion either way on whether, if it is a bug in ld, Rust should / shouldn't work around it. I just want to make sure we understand what is happening and why for the sake of future people who come across this code. (And if it's a bug in GNU ld that's hard to fix, I'd advocate for the Rust maintainers taking some sort of reasonable workaround like matching the target on the Linux kernel, because that happens to be the right heuristic for all supported platforms, even though the kernel technically isn't relevant, and I can likely be talked into writing such a patch.) |
Thanks for looking into it. I am using NetBSD -current which has binutils 2.27 while NetBSD-7 had 2.23. I agree that this is a linker bug - but as you say, what can I do. I also opened a discussion on NetBSD to additionaly support DT_RUNPATH and wrote a patch for it (one line change). With that, and a Cargo.toml hack (as suggested in #45686) I could complete bootstrap on amd64, so will look into writing a proper patch. I'm sure you would be quicker with that, if you want to setup a test enviroment, just use NetBSD 8 beta, like this one: http://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-8/201711280120Z/images/NetBSD-8.0_BETA-amd64.iso (This is the "daily" build, the exact timestamp will be invalid in a few days, but there will be newer ones following the same naming scheme) |
Oh I see, this is binutils-gdb.git b1b00fcc, "ld: change --enable-new-dtags to only generate new dtags", from January 2013 / binutils 2.24. I also see from Google that this has affected a few other pieces of software in NetBSD that have added |
@MartinHusemann are you still running into this issue? My understanding is that it's FreeBSD specific, and not actually a bug in rustc but in the linker itself ... |
This can be closed - we agreed that this is an inconsistency between the linker and the runtime linker and I commited the patch I mentioned above , so NetBSD ld.elf_so treats DT_RUNPATH and DT_RPATH identical. |
AFAICT only Linux had broken DT_RPATH and replaced it with DT_RUNPATH. The latter is not implemented at all elsewhere, so while still using the gnu linker other platforms are broken by using RUNPATH instead of RPATH.
My attempts at trivially fixing it blindly (as bootstrap fails for me currently, see #45686) did not get far: #46202
But someone with a working setup should be able to fix it easily.
The text was updated successfully, but these errors were encountered: