diff mbox series

[v2,8/8] python3-numpy: call libm for ceil/floor/trunc on riscv64

Message ID 20261017112358.77434-9-oo.hehir@gmail.com
State New
Headers show
Series riscv64 ptest fixes | expand

Commit Message

OOHehir Oct. 17, 2026, 11:23 a.m. UTC
numpy builds with -std=c11, so GCC 15 onwards expands ceil/floor/trunc
inline on riscv64, & its first scheduling pass moves the fcvt above the
|x| < 2^52 check. ceil(+-inf) & ceil(1e300) then raise FE_INVALID, & the
72 cases of test_unary_spurious_fpexception fail. Confirmed as
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127908.

-fno-fp-int-builtin-inexact makes GCC call libm, which handles these
inputs correctly. python3-numpy-ptest on a VisionFive 2 (JH7110), with
2.5.3: 45770 pass, 0 fail. On qemuriscv64 with PTEST_RUNNER_TIMEOUT = "7200",
with 2.5.4: 45993 pass, 0 fail.

Signed-off-by: OOHehir <oo.hehir@gmail.com>
---
 meta/recipes-devtools/python/python3-numpy_2.5.4.bb | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/meta/recipes-devtools/python/python3-numpy_2.5.4.bb b/meta/recipes-devtools/python/python3-numpy_2.5.4.bb
index 93aa356db1..275c49690b 100644
--- a/meta/recipes-devtools/python/python3-numpy_2.5.4.bb
+++ b/meta/recipes-devtools/python/python3-numpy_2.5.4.bb
@@ -26,6 +26,11 @@  PACKAGECONFIG[svml] = "-Ddisable-svml=false,-Ddisable-svml=true"
 # the overflow tests fail with compiler-rt on aarch64
 LDFLAGS:append:toolchain-clang:aarch64 = " -rtlib=libgcc -unwindlib=libgcc"
 
+# GCC 15+ inlines ceil/floor/trunc on riscv64 with the fcvt ahead of the range
+# check, so +-inf raises FE_INVALID; call libm instead. GCC PR 127908.
+CFLAGS:append:toolchain-gcc:riscv64 = " -fno-fp-int-builtin-inexact"
+CXXFLAGS:append:toolchain-gcc:riscv64 = " -fno-fp-int-builtin-inexact"
+
 # To ensure reproducibility, remove entries from __config__ which expose build
 # machine details, such as build paths, host paths, and hardware configuration.
 strip_build_info() {