[PATCH] newlib: Disable ld128 math library build for aarch64 windows
Thirumalai Nagalingam <[email protected]> Tue, 24 Feb 2026 08:56:05 +0000
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <MA0P287MB3082BE5679FE643D31894F2E9F74A@MA0P287MB3082.INDP287.PROD.OUTLOOK.COM> |
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(-)
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
--
newlib-Disable-ld128-math-library-build-for-aarch64-.patch
(application/octet-stream, 2.5 KB)
From c0f4ac7b1d305b49c4229cddd0a7244c00d25e82 Mon Sep 17 00:00:00 2001 From: Thirumalai Nagalingam <[email protected]> Date: Tue, 3 Feb 2026 10:57:24 +0530 Subject: [PATCH] newlib: Disable ld128 math library build for aarch64 Windows Don't build long double newlib/libm for Windows on aarch64 as newlib/libm supports only 80bit or 128bit long doubles, while aarch64 Windows uses 64bit long doubles. Exclude aarch64-*-mingw* and aarch64-*-cygwin* targets from HAVE_FPMATH_H conditional to prevent building 128-bit long double math functions (ld128), which are incompatible with these platforms' 64bit long double representation. Signed-off-by: Martin Vejbora <[email protected]> Signed-off-by: Thirumalai Nagalingam <[email protected]> --- newlib/configure | 8 ++++++++ newlib/libc/acinclude.m4 | 11 ++++++++++- newlib/libm/Makefile.inc | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) 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 -- 2.53.0.windows.1