Picking `c_longdouble` on linux PowerPC
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 8/100
Línea de trabajo
This is a design/tracking issue, not a scoped edit: read the whole body first, then the linked compiler-team#1050 ("Store C-compatible types in the target spec") and its Zulip thread, which is where the actual c_longdouble representation decision is being made. The relevant surface is the target spec definitions for the powerpc/powerpc64 Linux targets and how the C-compatible type is recorded there. Done means an agreed mapping (ELFv1 -> ppcf128, ELFv1/ELFv2 BE -> ppcf128, LE ELFv2 -> f128) is written down and reflected in those specs; until then this needs a compiler/targets contributor, not a newcomer.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
Links
- Lenguaje dominante
- Rust
- Estrellas
- 123k
- Forks
- 16.6k
- Merge medio
- 2 d 17 h
- PR fusionados (30 d)
- 532
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rust-lang/rust
-
strictly_dominates missing a `=`AbiertoC-bug needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
rust-lang/rust#166722 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
A-attributes relnotes relnotes-needs-review relnotes-tracking-issue T-compiler T-lang
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
A-run-make C-bug T-bootstrap
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Tracking issue for release notes of #161531: Remove `T: Send + Sync` bound from `Arc::downcast`Abiertorelnotes relnotes-tracking-issue T-libs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
A-str A-Unicode relnotes relnotes-tracking-issue T-libs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
Todos los issues de rust-lang/rust
Issues similares
-
bug P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
bug core-lang
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Windows microphone listing treats words in a device name as DirectShow labelsPosiblemente ocupada @Sujal-chaudhary la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
clipy-recorder/clipy#447 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
nightly-cleanup
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
max-sixty/worktrunk#4939 · 1 reacción ·
Los mantenedores suelen responder en 1 día