-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
powerpc64: allow querying ELF ABI version #60617
Comments
Actually, this could easily be implemented as a string in |
It's actually that all musl is ELFv2, as is other little-endian, while big-endian uses ELFv1. rust/src/librustc_target/abi/call/powerpc64.rs Lines 127 to 134 in cfdc84a
And here's what GCC has to say about those
LLVM has a So I wonder if the little bit of ABI handling we have for musl is actually enough... |
It's not enough (in my distro I use external LLVM, which is patched to use ELFv2 correctly, and for bootstrap executables that use internal LLVM i have that patched as well). Yes, all I'm working on a proof of concept implementation of this which will also include using |
Anyway, my current design is something like the following:
|
That design sounds good to me. The only point that might be controversial is exposing this in |
That is true, but that's ARM, where you have the ABI defined as a part of the triple. Meanwhile, on POWER, you have a single triple environment, So this would be pretty much |
Yeah, FreeBSD will be switching to Big Endian ELFv2 during the current (13-CURRENT) development cycle. Progress is being tracked at https://wiki.freebsd.org/powerpc/llvm-elfv2 and is moving forward at a rapid pace. FreeBSD detection would generally done by caring about the version as well (the whole triple is powerpc64-unknown-freebsd13.0 and while it currently means "ELFv1" by default, it will mean "ELFv2" after flag day. powerpc64-unknown-freebsd12.0 and down can be considered to be ELFv1 and powerpc64-unknown-freebsd14.0 and up can be considered to be ELFv2. powerpc64-unknown-freebsd13.0 is the only ambiguous one.) As you mentioned, the FreeBSD kernel can run ELFv1 and ELFv2 binaries alongside each other. (but it's best to at least keep them isolated in different chroots, if only to prevent confusion regarding unloadable libraries, since we will not be using different ABI libdirs like we do for running 32 bit programs on a 64 bit install, and the runtime dynamic linker is not named after the ELF ABI, so will conflict if you try and mix ELFv1 and ELFv2 in the same sysroot.) |
BTW, for reference, the detection code for LLVM that we will be running with the FreeBSD in-tree LLVM and asking to be applied to upstream LLVM once flag day happens is at https://reviews.freebsd.org/D20383 |
I wrote some code for the |
Triage: not aware of any updates here |
This also applies to OpenBSD/powerpc64 which uses the ELF v2 ABI. |
didn't find time to look into this further, sorry - maybe i'll try again in the next few weeks as i have more free time |
See also rust-lang/rfcs#2992 |
There are two ABIs on ppc64, ELFv1 (legacy) and ELFv2 (introduced a couple years back, used by default for little endian). Rust currently has logic in it that for the
musl
libc, ELFv2 is used on big endian and ELFv1 is used otherwise. This is inadequate, as you can use ELFv2 as well withglibc
. In my distribution, both little and big endian systems are supported, withglibc
andmusl
, and they are all set up for ELFv2.In order to achieve that, Rust in the distribution is patched so that it will always properly use ELFv2 ABI. However, this is a potential problem for some crates that for example need to deal with assembly code; they have no way to query the ABI version. For endianness, they can do like
#[cfg(target_endian = "big")]
. For ABI, there is no equivalent (in C, you can do#if _CALL_ELF == 2
).I can look into implementing this, but I need to know what would be the best syntax and way to implement this. As I see it, it would need a new field in the target options, but this would of course be specific to ppc64, and ABI on ppc64 in e.g. gcc is treated more like a list than a string (you can also have
-mabi=altivec
,-mabi=ibmlongdouble
and so on, in addition to-mabi=elfv2
), so I was wondering if something more generic/extensible would be better.Of course, eventually it'd be best to also allow setting it when compiling, and make it properly pass everything down to llvm, but that's less of a concern, for now I just need crates to be able to read it.
The text was updated successfully, but these errors were encountered: