newlib: Disable ld128 math library build for aarch64 windows

Message ID MA0P287MB3082BE5679FE643D31894F2E9F74A@MA0P287MB3082.INDP287.PROD.OUTLOOK.COM
State New
Headers
Series newlib: Disable ld128 math library build for aarch64 windows |

Commit Message

Thirumalai Nagalingam Feb. 24, 2026, 8:56 a.m. UTC
  Hello,
On AArch64 Windows targets (Cygwin and MinGW), long double has the same
representation & precision as double. The _fpmath.h header and the
ld128 libm implementation assume extended precision long double
semantics, which is not valid for these targets.

This patch detects AArch64 Windows targets and disables HAVE_FPMATH_H
accordingly, preventing inclusion of incompatible ld128 math routines.
This fixes build & ABI issues in libm for Cygwin AArch64.

Patch is attached & In-lined for reference.

Thanks & regards,
Thirumalai N
In-lined patch:
---
 newlib/configure         |  8 ++++++++
 newlib/libc/acinclude.m4 | 11 ++++++++++-
 newlib/libm/Makefile.inc |  2 ++
 3 files changed, 20 insertions(+), 1 deletion(-)

--
  

Comments

Corinna Vinschen March 17, 2026, 3:24 p.m. UTC | #1
On Feb 24 08:56, Thirumalai Nagalingam wrote:
> Hello,
> On AArch64 Windows targets (Cygwin and MinGW), long double has the same
> representation & precision as double. The _fpmath.h header and the
> ld128 libm implementation assume extended precision long double
> semantics, which is not valid for these targets.
> 
> This patch detects AArch64 Windows targets and disables HAVE_FPMATH_H
> accordingly, preventing inclusion of incompatible ld128 math routines.
> This fixes build & ABI issues in libm for Cygwin AArch64.
> 
> Patch is attached & In-lined for reference.
> 
> Thanks & regards,
> Thirumalai N
> In-lined patch:
> ---
>  newlib/configure         |  8 ++++++++
>  newlib/libc/acinclude.m4 | 11 ++++++++++-
>  newlib/libm/Makefile.inc |  2 ++
>  3 files changed, 20 insertions(+), 1 deletion(-)

Pushed.

Thanks,
Corinna
  

Patch

diff --git a/newlib/configure b/newlib/configure
index ab31510aa..2211598ef 100755
--- a/newlib/configure
+++ b/newlib/configure
@@ -6186,6 +6186,14 @@  else
 fi


+ case $host in
+  aarch64-*-mingw* | aarch64-*-cygwin*)
+    IS_AARCH64_WINDOWS=yes ;;
+  *)
+    IS_AARCH64_WINDOWS=no ;;
+esac
+
+
  if test -r "${srcdir}/libc/machine/${machine_dir}/machine/_fpmath.h"; then
   HAVE_FPMATH_H_TRUE=
   HAVE_FPMATH_H_FALSE='#'
diff --git a/newlib/libc/acinclude.m4 b/newlib/libc/acinclude.m4
index 52a6c57cf..a1040386b 100644
--- a/newlib/libc/acinclude.m4
+++ b/newlib/libc/acinclude.m4
@@ -63,7 +63,16 @@  m4_foreach_w([MACHINE], [
   z8k
 ], [AM_CONDITIONAL([HAVE_LIBC_MACHINE_]m4_toupper(MACHINE), test "${machine_dir}" = MACHINE)])

-AM_CONDITIONAL(HAVE_FPMATH_H, test -r "${srcdir}/libc/machine/${machine_dir}/machine/_fpmath.h")
+case $host in
+  aarch64-*-cygwin* | aarch64-*-mingw*)
+    IS_AARCH64_WINDOWS=yes ;;
+  *)
+    IS_AARCH64_WINDOWS=no ;;
+esac
+
+AM_CONDITIONAL([HAVE_FPMATH_H],
+  [test -r "${srcdir}/libc/machine/${machine_dir}/machine/_fpmath.h" &&
+   test "$IS_AARCH64_WINDOWS" = no])


 AM_CONDITIONAL(MACH_ADD_SETJMP, test "x$mach_add_setjmp" = "xtrue")
diff --git a/newlib/libm/Makefile.inc b/newlib/libm/Makefile.inc
index bf31b1be7..a0147f0a2 100644
--- a/newlib/libm/Makefile.inc
+++ b/newlib/libm/Makefile.inc
@@ -55,8 +55,10 @@  include %D%/test/Makefile.inc

 if HAVE_LIBM_MACHINE_AARCH64
 include %D%/machine/aarch64/Makefile.inc
+if HAVE_FPMATH_H
 include %D%/ld128/Makefile.inc
 endif
+endif
 if HAVE_LIBM_MACHINE_AMDGCN
 include %D%/machine/amdgcn/Makefile.inc
 endif