Skip to content

Picking c_longdouble on linux PowerPC #166424

Backlog

Description

@folkertdev

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 double being the IBM extended precision type)
  • ELFv2 (with long double being the IBM extended precision type)
  • ELFv2 (with long double being 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 double being double)

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_longdouble to be ppcf128 (the IBM extended precision type)
  • Big-endian ELFv2 glibc today can only define c_longdouble to be ppcf128 due to toolchain limitations that may be resolved in the future
  • Little-endian ELFv2 glibc can define c_longdouble to be either ppcf128 or f128
    • The general trend amongst distributions is to move towards f128
      • Debian switched with 13 (Trixie)
      • Fedora switched with 36, which means RHEL 10 made the switch as well
      • Ubuntu switched in 25.10
    • We believe f128 is 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 glibc
      • f128 also has hardware acceleration on POWER9 and later

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.

Links

Activity

  1. added
    O-PowerPC
    F-c_longdouble
    on Nov 23, 2026
  2. added
    needs-triage
    on Nov 23, 2026
  3. beetrees commented on Nov 23, 2026

    @beetrees
    Contributor

    On 32-bit PowerPC, the ABI leaves only a single choice for long double: double.

    The linked ABI is only the Embedded ABI variant. As summarised in the preface:

    This version of the Power Architecture 32-bit Application Binary Interface Supplement may take one of
    the following forms:
    Linux & Embedded
    The unified ABI document contains all text from all implementations of the ABI.
    Linux
    The technical conditions governing implementations of the Linux ABI are described by attribute
    conformance and inclusion rules in Appendix B, Section B.1. The attribute tags described in that part
    of the appendix are used to conditionally generate the Linux ABI variant of this document.
    Embedded
    The technical conditions governing implementations of the Embedded ABI are described by
    attribute conformance and inclusion rules in Appendix B, Section B.2. The attribute tags described
    in that part of the appendix are used to conditionally generate the Embedded ABI variant of this
    document.

    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 for long double: Appendix B states that the Embedded ABI must use double as long double, and for the Linux ABI:

    An implementation of the Linux ABI must implement ATR-LONG-DOUBLE-IBM and may also
    implement ATR-LONG-DOUBLE-IS-DOUBLE. A conforming application only uses one or the other.

    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.

  4. RalfJung commented on Nov 24, 2026

    @RalfJung
    Member

    Big-endian ELFv2 glibc today can only define c_longdouble to be ppcf128 due to toolchain limitations that may be resolved in the future

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    F-c_longdoubleO-PowerPCneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions