From 1bc2fac92b12e03bff7e85aa106aa28fd34ee13f Mon Sep 17 00:00:00 2001 From: fosslinux Date: Sun, 20 Sep 2020 18:15:29 +1000 Subject: [PATCH] python-numpy: fix for armv5tel-musl. musl differs from glibc in that it dosen't provide fenv.h, on arm, when it believes the architecture dosen't use hardware floating point in any way. While this is mostly correct, numpy dosen't use them for floating point reasons -- it just uses them as general, as per the code, "normal GCC" constants. Hence, extract the constants from the file and provide them to numpy all the time for armv5tel-musl, the only affected arch. --- srcpkgs/python-numpy/files/fenv-constants.h | 10 ++++++++++ srcpkgs/python-numpy/files/fenv-constants.patch | 11 +++++++++++ srcpkgs/python-numpy/template | 9 +++++++++ 3 files changed, 30 insertions(+) create mode 100644 srcpkgs/python-numpy/files/fenv-constants.h create mode 100644 srcpkgs/python-numpy/files/fenv-constants.patch diff --git a/srcpkgs/python-numpy/files/fenv-constants.h b/srcpkgs/python-numpy/files/fenv-constants.h new file mode 100644 index 00000000000..c2c21d2bb23 --- /dev/null +++ b/srcpkgs/python-numpy/files/fenv-constants.h @@ -0,0 +1,10 @@ +#define FE_INVALID 1 +#define FE_DIVBYZERO 2 +#define FE_OVERFLOW 4 +#define FE_UNDERFLOW 8 +#define FE_INEXACT 16 +#define FE_ALL_EXCEPT 31 +#define FE_TONEAREST 0 +#define FE_DOWNWARD 0x800000 +#define FE_UPWARD 0x400000 +#define FE_TOWARDZERO 0xc00000 diff --git a/srcpkgs/python-numpy/files/fenv-constants.patch b/srcpkgs/python-numpy/files/fenv-constants.patch new file mode 100644 index 00000000000..987ad4e346f --- /dev/null +++ b/srcpkgs/python-numpy/files/fenv-constants.patch @@ -0,0 +1,11 @@ +--- numpy/core/src/npymath/ieee754.c.src 2020-09-20 14:53:51.998825328 +1000 ++++ numpy/core/src/npymath/ieee754.c.src 2020-09-20 14:54:03.611889518 +1000 +@@ -8,6 +8,8 @@ + #include "npy_math_private.h" + #include "numpy/utils.h" + ++#include "fenv-constants.h" ++ + #ifndef HAVE_COPYSIGN + double npy_copysign(double x, double y) + { diff --git a/srcpkgs/python-numpy/template b/srcpkgs/python-numpy/template index 52308fd2aa6..d7d64d8124c 100644 --- a/srcpkgs/python-numpy/template +++ b/srcpkgs/python-numpy/template @@ -15,6 +15,15 @@ distfiles="https://github.com/numpy/numpy/archive/v${version}.tar.gz" checksum=3c82a9b8616e3096a79a2af9c288d8ed4013a10fc7baf3eaf54655309734dadd alternatives="numpy:f2py:/usr/bin/f2py2" +post_patch() { + case "${XBPS_TARGET_MACHINE}" in + armv5tel-musl) + cp "${FILESDIR}/fenv-constants.h" numpy/core/src/npymath/ + patch -Np0 -i "${FILESDIR}/fenv-constants.patch" + ;; + esac +} + post_install() { # create compat symlinks for .h files vmkdir ${py2_inc}