diff mbox series

[blacksail,34/60] python3-numpy: call libm for ceil/floor/trunc on riscv64

Message ID 36c20b7f159cacaae09d748721194e0a11bb7a74.1793867929.git.yoann.congal@smile.fr
State RFC, archived
Delegated to: Yoann Congal
Headers show
Series [blacksail,01/60] gstreamer1.0-plugins-bad: use gtk+3 dependency name | expand

Commit Message

Yoann Congal Nov. 5, 2026, 8:42 a.m. UTC
From: Owen O'Hehir <oo.hehir@gmail.com>

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>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 873468f620fdbb6d5a65bbfd842ece53b1f93748)
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
 meta/recipes-devtools/python/python3-numpy_2.5.3.bb | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/meta/recipes-devtools/python/python3-numpy_2.5.3.bb b/meta/recipes-devtools/python/python3-numpy_2.5.3.bb
index 338bdd2bbd0..c95c00841a4 100644
--- a/meta/recipes-devtools/python/python3-numpy_2.5.3.bb
+++ b/meta/recipes-devtools/python/python3-numpy_2.5.3.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() {