[PATCH v3 6/7] fortran: only apply the IEEE-128 long double kind remap with glibc
Piotr Kubaj <[email protected]> Wed, 15 Jul 2026 08:24:21 +0200
| Newsgroups | gmane.comp.gcc.patches,gmane.comp.gcc.fortran |
|---|---|
| Message-ID | <[email protected]> |
gfc_init_kinds detects the powerpc64le -mabi=ieeelongdouble case and, for libgfortran, gives REAL(KIND=16) the ABI of KIND=17 and routes its runtime math through the glibc *ieee128 / libquadmath entry points. That machinery is glibc-specific (it is keyed on TARGET_GLIBC_MAJOR/MINOR); on a non-glibc target such as FreeBSD it makes libgfortran reference names that do not exist (__*ieee128, and libquadmath *q such as iroundq). Restrict the block to glibc (TARGET_GLIBC_MAJOR >= 2). On FreeBSD long double is native IEEE-128, so REAL(KIND=16) keeps its natural kind-16 ABI and its math resolves to the plain *l libm entry points. gcc/fortran/ChangeLog: * trans-types.cc (gfc_init_kinds): Only apply the -mabi=ieeelongdouble kind remapping on glibc. Signed-off-by: Piotr Kubaj <[email protected]> --- gcc/fortran/trans-types.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc --- a/gcc/fortran/trans-types.cc +++ b/gcc/fortran/trans-types.cc @@ -513,7 +513,8 @@ precision. For libgfortran calls pretend the IEEE 754 quad TFmode has kind 17 rather than 16 and use kind 16 for the IBM extended format TFmode. */ - if (composite_mode != QImode && saw_r16 && !MODE_COMPOSITE_P (r16_mode)) + if (composite_mode != QImode && saw_r16 && !MODE_COMPOSITE_P (r16_mode) + && TARGET_GLIBC_MAJOR >= 2) { for (int i = 0; i < r_index; ++i) if (gfc_real_kinds[i].kind == 16) -- 2.49.0