[6/7] fortran: only apply the IEEE-128 long double kind remap with glibc

Message ID 20260707144106.10130-7-pkubaj@FreeBSD.org
State New
Headers
Series powerpc64le: support IEEE-128 long double on FreeBSD |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Build passed

Commit Message

Piotr Kubaj July 7, 2026, 2:40 p.m. UTC
  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 <pkubaj@FreeBSD.org>
---
 gcc/fortran/trans-types.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Patch

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)