Skip to content

powerpc64: allow querying ELF ABI version #60617

Open
@q66

Description

@q66

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 with glibc. In my distribution, both little and big endian systems are supported, with glibc and musl, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    O-PowerPCTarget: PowerPC processorsT-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions