[7/7] libgfortran: don't add REAL(KIND=17) when long double is IEEE 128-bit

Message ID 20260707144106.10130-8-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
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-arm-bootstrap pending Build did not complete; will be retriggered
linaro-tcwg-bot/tcwg_gcc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-aarch64-bootstrap fail Build failed

Commit Message

Piotr Kubaj July 7, 2026, 2:40 p.m. UTC
  On powerpc64le, kinds-override.h unconditionally defines a second
128-bit real kind (REAL(KIND=17), _Float128) whenever long double is
16 bytes, assuming long double is IBM double-double so a distinct
IEEE-128 kind is needed.  When long double already is IEEE-128
(__LONG_DOUBLE_IEEE128__) KIND=17 duplicates KIND=16, and unless
USE_IEC_60559 is defined the *_r17.c files use the libquadmath *q
entry points (jnq, fabsq, ...).  When libquadmath is not configured
(HAVE_FLOAT128 undefined) those are undeclared, so libgfortran fails
to build with "implicit declaration of function 'jnq'" -- an error
since GCC 14.  Reproducible on FreeBSD 16 powerpc64le, which defaults
long double to IEEE-128.

Only define the separate _Float128 KIND=17 when long double is not
already IEEE-128.

libgfortran/ChangeLog:

	* kinds-override.h: Do not define REAL(KIND=17) when long double
	is already IEEE 128-bit (__LONG_DOUBLE_IEEE128__).

Signed-off-by: Piotr Kubaj <pkubaj@FreeBSD.org>
---
 libgfortran/kinds-override.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/libgfortran/kinds-override.h b/libgfortran/kinds-override.h
--- a/libgfortran/kinds-override.h
+++ b/libgfortran/kinds-override.h
@@ -30,7 +30,7 @@ 
 #endif
 
 /* Keep these conditions on one line so grep can filter it out.  */
-#if defined(__powerpc64__)  && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__  && __SIZEOF_LONG_DOUBLE__ == 16
+#if defined(__powerpc64__)  && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__  && __SIZEOF_LONG_DOUBLE__ == 16 && !defined(__LONG_DOUBLE_IEEE128__)
 typedef _Float128 GFC_REAL_17;
 typedef _Complex _Float128 GFC_COMPLEX_17;
 #define HAVE_GFC_REAL_17