Repository navigation
Description
This is a weird mix of a tracking issue and design doc, meant to give background on how we should pick what type c_longdouble corresponds to on the Linux PowerPC targets.
Written by @Gelbpunkt and @folkertdev.
On PowerPC targets, there exist several ABIs with a variety of supported types for long double. Additionally, certain libcs and operating systems have decided to ignore ABI specifications and make up their own definitions for long double.
The target tuple does not always uniquely determine what type long double corresponds to, so in some cases we must either split a target, or pick a winner and accept being incompatible with toolchains that pick a different option.
32-bit PowerPC
On 32-bit PowerPC, the ABI leaves only a single choice for long double: double. The LSB spec says not to use long double at all.
However, Clang and GCC actually use the "IBM extended precision" (a double-double type) as their long double type by default. But certain libcs and operating systems like musl libc and some BSDs do use the spec-compliant f64.
Luckily there is generally a definitive choice for long double for a given target OS and target environment: the target tuple uniquely determines what type should be used.
64-bit PowerPC
On 64-bit PowerPC the situation is more complicated. There are two ELF ABIs:
The ELFv1 ABI defines the long double type to be the IBM extended precision type, in ELFv2 this is changed to be a choice between the IBM extended precision type and the IEEE754 binary128 (f128) type. That means different ABIs are in use today:
- ELFv1 (with
long doublebeing the IBM extended precision type) - ELFv2 (with
long doublebeing the IBM extended precision type) - ELFv2 (with
long doublebeing the IEEE binary128 type)
Additionally, some BSDs and musl libc have opted to use double as long double. These generally all use the ELFv2 ABI instead of ELFv1, which means there's also:
- ELFv2 (with
long doublebeingdouble)
which is technically not allowed by the ABI, but done in practice.
Crucially, for 64-bit PowerPC the target tuple does not uniquely determine what type long double corresponds to.
Background on ELFv1 versus ELFv2
Overall there seems to be a trend towards adopting ELFv2, and picking IEEE binary128 as the long double type (see sources below). However, doing so is currently not always possible, and some configurations may never be able to make the switch.
In order to be able to use the IEEE binary128 type on 64-bit PowerPC, GCC and Clang currently require the VSX extension to be enabled. This extension is implied by the powerpc64le baseline (which corresponds to POWER8), so all powerpc64le targets can make use of the IEEE binary128 type.
However, on powerpc64 (big-endian), the baseline in GCC is typically POWER4 (which has neither AltiVec nor VSX) and in LLVM and Rust, it's a PPC970 (which has AltiVec, but not VSX). The IEEE binary128 type could technically also be used with just AltiVec instead of VSX, but this is ongoing work on the LLVM side and currently not possible.
The ELFv2 ABI formally requires an ISA 2.07B (i.e. POWER8) CPU with all extensions (including both AltiVec and VSX), but in practice sets no requirements that wouldn't be met with just AltiVec (VSX doubles the vector register count, but the registers mandated by the ABI are included with AltiVec).
Hence, most distributions that use ELFv2 on big-endian powerpc64 do not include VSX in their baseline, technically breaking the spec. Private conversations with folks at IBM indicates that they're open to changing the ELFv2 specification to officially support this usecase.
Picking c_longdouble on 64-bit PowerPC
So, for Rust this means:
- ELFv1 is used for legacy glibc targets and should define
c_longdoubleto beppcf128(the IBM extended precision type) - Big-endian ELFv2 glibc today can only define
c_longdoubleto beppcf128due to toolchain limitations that may be resolved in the future - Little-endian ELFv2 glibc can define
c_longdoubleto be eitherppcf128orf128- The general trend amongst distributions is to move towards
f128 - We believe
f128is the right call for Rust in this case because it's the forward-looking choice if we want to avoid a target split for powerpc64le with glibcf128also has hardware acceleration on POWER9 and later
- The general trend amongst distributions is to move towards
What's next
The plan here is tentative, it might change. The c_longdouble type will likely stay unstable for a while, and we'll see how the compiler support for ELFv2 and f128 develops.
Activity
beetrees commentedon Nov 23, 2026
The linked ABI is only the Embedded ABI variant. As summarised in the preface:
The latest known Linux & Embedded unified ABI document has both
double(ATR-LONG-DOUBLE-IS-DOUBLE) and IBM extended precision (ATR-LONG-DOUBLE-IBM) as options forlong double: Appendix B states that the Embedded ABI must usedoubleaslong double, and for the Linux ABI:As you state, there's usually a definitive choice for each target so what the spec technically says doesn't really matter, but I thought this would be good background anyway.
RalfJung commentedon Nov 24, 2026
Big-endian ELFv2 glibc is not supported by glibc, right? Do we even have a target for that?
EDIT: We do, though it is currently tier 3.
Without upstream support, looking at what they do wrt ABI seems to me like reading tea leaves.