[numpy] Add upstream patch to fix xerbla linkage (bug #1172834)
Orion Poplawski
orion at fedoraproject.org
Tue Jan 6 22:18:06 UTC 2015
commit 162361b332d4caae4e4c9329c84491cdcee662ed
Author: Orion Poplawski <orion at cora.nwra.com>
Date: Tue Jan 6 15:18:20 2015 -0700
Add upstream patch to fix xerbla linkage (bug #1172834)
5392.patch | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
numpy.spec | 9 ++++-
2 files changed, 135 insertions(+), 1 deletions(-)
---
diff --git a/5392.patch b/5392.patch
new file mode 100644
index 0000000..6416d20
--- /dev/null
+++ b/5392.patch
@@ -0,0 +1,127 @@
+From f0b2dd7d5151878f2b4b3ea20ff551b27243f27d Mon Sep 17 00:00:00 2001
+From: Charles Harris <charlesr.harris at gmail.com>
+Date: Wed, 24 Dec 2014 11:26:13 -0700
+Subject: [PATCH] BUG: Xerbla doesn't get linked in 1.9 on Fedora 21.
+
+Add our python_xerbla to the blasdot sources. That function is
+needed for all modules that link to the ATLAS 3.10 libraries, which
+in Fedora 21 are located in just two files: libsatlas and libtatlas.
+
+Also make the test for xerbla linkage work better. If xerbla is not
+linked the test will be skipped with a message.
+---
+ numpy/core/blasdot/python_xerbla.c | 51 ++++++++++++++++++++++++++++++++++++++
+ numpy/core/setup.py | 3 ++-
+ numpy/linalg/tests/test_linalg.py | 9 ++++---
+ 3 files changed, 59 insertions(+), 4 deletions(-)
+ create mode 100644 numpy/core/blasdot/python_xerbla.c
+
+diff --git a/numpy/core/blasdot/python_xerbla.c b/numpy/core/blasdot/python_xerbla.c
+new file mode 100644
+index 0000000..bdf0b90
+--- /dev/null
++++ b/numpy/core/blasdot/python_xerbla.c
+@@ -0,0 +1,51 @@
++#include "Python.h"
++
++/*
++ * From f2c.h, this should be safe unless fortran is set to use 64
++ * bit integers. We don't seem to have any good way to detect that.
++ */
++typedef int integer;
++
++/*
++ From the original manpage:
++ --------------------------
++ XERBLA is an error handler for the LAPACK routines.
++ It is called by an LAPACK routine if an input parameter has an invalid value.
++ A message is printed and execution stops.
++
++ Instead of printing a message and stopping the execution, a
++ ValueError is raised with the message.
++
++ Parameters:
++ -----------
++ srname: Subroutine name to use in error message, maximum six characters.
++ Spaces at the end are skipped.
++ info: Number of the invalid parameter.
++*/
++
++int xerbla_(char *srname, integer *info)
++{
++ static const char format[] = "On entry to %.*s" \
++ " parameter number %d had an illegal value";
++ char buf[sizeof(format) + 6 + 4]; /* 6 for name, 4 for param. num. */
++
++ int len = 0; /* length of subroutine name*/
++#ifdef WITH_THREAD
++ PyGILState_STATE save;
++#endif
++
++ while( len<6 && srname[len]!='\0' )
++ len++;
++ while( len && srname[len-1]==' ' )
++ len--;
++#ifdef WITH_THREAD
++ save = PyGILState_Ensure();
++#endif
++ PyOS_snprintf(buf, sizeof(buf), format, len, srname, *info);
++ PyErr_SetString(PyExc_ValueError, buf);
++#ifdef WITH_THREAD
++ PyGILState_Release(save);
++#endif
++
++ return 0;
++}
+diff --git a/numpy/core/setup.py b/numpy/core/setup.py
+index 1cd1ee1..baaee20 100644
+--- a/numpy/core/setup.py
++++ b/numpy/core/setup.py
+@@ -954,12 +954,13 @@ def get_dotblas_sources(ext, build_dir):
+ if blas_info:
+ if ('NO_ATLAS_INFO', 1) in blas_info.get('define_macros', []):
+ return None # dotblas needs ATLAS, Fortran compiled blas will not be sufficient.
+- return ext.depends[:2]
++ return ext.depends[:3]
+ return None # no extension module will be built
+
+ config.add_extension('_dotblas',
+ sources = [get_dotblas_sources],
+ depends = [join('blasdot', '_dotblas.c'),
++ join('blasdot', 'python_xerbla.c'),
+ join('blasdot', 'apple_sgemv_patch.c'),
+ join('blasdot', 'cblas.h'),
+ ],
+diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py
+index 8edf36a..dec98db 100644
+--- a/numpy/linalg/tests/test_linalg.py
++++ b/numpy/linalg/tests/test_linalg.py
+@@ -1108,6 +1108,8 @@ def test_xerbla_override():
+ # and may, or may not, abort the process depending on the LAPACK package.
+ from nose import SkipTest
+
++ XERBLA_OK = 255
++
+ try:
+ pid = os.fork()
+ except (OSError, AttributeError):
+@@ -1137,15 +1139,16 @@ def test_xerbla_override():
+ a, a, 0, 0)
+ except ValueError as e:
+ if "DORGQR parameter number 5" in str(e):
+- # success
+- os._exit(os.EX_OK)
++ # success, reuse error code to mark success as
++ # FORTRAN STOP returns as success.
++ os._exit(XERBLA_OK)
+
+ # Did not abort, but our xerbla was not linked in.
+ os._exit(os.EX_CONFIG)
+ else:
+ # parent
+ pid, status = os.wait()
+- if os.WEXITSTATUS(status) != os.EX_OK or os.WIFSIGNALED(status):
++ if os.WEXITSTATUS(status) != XERBLA_OK:
+ raise SkipTest('Numpy xerbla not linked in.')
+
+
diff --git a/numpy.spec b/numpy.spec
index 4649f9a..57f8d0d 100644
--- a/numpy.spec
+++ b/numpy.spec
@@ -9,7 +9,7 @@
Name: numpy
Version: 1.9.1
-Release: 1%{?dist}
+Release: 2%{?dist}
Epoch: 1
Summary: A fast multidimensional array facility for Python
@@ -18,6 +18,9 @@ Group: Development/Languages
License: BSD and Python
URL: http://www.numpy.org/
Source0: http://downloads.sourceforge.net/numpy/%{name}-%{version}%{?relc}.tar.gz
+# Upstream patch to fix xerbla linkage
+# https://bugzilla.redhat.com/show_bug.cgi?id=1172834
+Patch0: https://github.com/numpy/numpy/pull/5392.patch
BuildRequires: python2-devel lapack-devel python-setuptools gcc-gfortran atlas-devel python-nose
Requires: python-nose
@@ -83,6 +86,7 @@ This package includes a version of f2py that works properly with NumPy.
%prep
%setup -q -n %{name}-%{version}%{?relc}
+%patch0 -p1 -b .xerbla
# workaround for rhbz#849713
# http://mail.scipy.org/pipermail/numpy-discussion/2012-July/063530.html
@@ -223,6 +227,9 @@ popd &> /dev/null
%changelog
+* Tue Jan 6 2015 Orion Poplawski <orion at nwra.com> - 1:1.9.1-2
+- Add upstream patch to fix xerbla linkage (bug #1172834)
+
* Tue Nov 04 2014 Jon Ciesla <limburgher at gmail.com> - 1:1.9.1-1
- Update to 1.9.1, BZ 1160273.
More information about the scm-commits
mailing list