<p dir="auto">The problem occurs when trying to compile the Slackbuild numpy or numpy3. THe compilation fails in the same position (see error message)<br>
I am unsure what needs to be fixed and why this compilation fails. Any help would be appreciated.</p>
<h3 dir="auto">Reproducing code example:</h3>
<p dir="auto">I tried to build a Slackbuild version of the latest numpy/numpy3 source on a recent stock slackware64-current install with OpenBLAS 0.3.3 added (<a href="http://slackbuilds.org" rel="nofollow">http://slackbuilds.org</a>)</p>
<h3 dir="auto">Error message:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="error: Command &quot;gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DHAVE_CBLAS -Ibuild/src.linux-x86_64-2.7/numpy/core/src/private -Inumpy/core/include -Ibuild/src.linux-x86_64-2.7/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/usr/include/python2.7 -Ibuild/src.linux-x86_64-2.7/numpy/core/src/private -Ibuild/src.linux-x86_64-2.7/numpy/core/src/npymath -Ibuild/src.linux-x86_64-2.7/numpy/core/src/private -Ibuild/src.linux-x86_64-2.7/numpy/core/src/npymath -Ibuild/src.linux-x86_64-2.7/numpy/core/src/private -Ibuild/src.linux-x86_64-2.7/numpy/core/src/npymath -c numpy/core/src/multiarray/numpyos.c -o build/temp.linux-x86_64-2.7/numpy/core/src/multiarray/numpyos.o -MMD -MF build/temp.linux-x86_64-2.7/numpy/core/src/multiarray/numpyos.o.d&quot; failed with exit status 1"><pre class="notranslate"><code class="notranslate">error: Command "gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DHAVE_CBLAS -Ibuild/src.linux-x86_64-2.7/numpy/core/src/private -Inumpy/core/include -Ibuild/src.linux-x86_64-2.7/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/usr/include/python2.7 -Ibuild/src.linux-x86_64-2.7/numpy/core/src/private -Ibuild/src.linux-x86_64-2.7/numpy/core/src/npymath -Ibuild/src.linux-x86_64-2.7/numpy/core/src/private -Ibuild/src.linux-x86_64-2.7/numpy/core/src/npymath -Ibuild/src.linux-x86_64-2.7/numpy/core/src/private -Ibuild/src.linux-x86_64-2.7/numpy/core/src/npymath -c numpy/core/src/multiarray/numpyos.c -o build/temp.linux-x86_64-2.7/numpy/core/src/multiarray/numpyos.o -MMD -MF build/temp.linux-x86_64-2.7/numpy/core/src/multiarray/numpyos.o.d" failed with exit status 1
</code></pre></div>
<h3 dir="auto">Numpy/Python version information: 1.14.3 (both numpy and numpy3)</h3>
<p dir="auto">On a clean Linux system (nothing but the most recent Manjaro Linux and the latest 64-bit Anaconda Linux install) I decided to try to use the conda compilers instead of the system ones to build NumPy and SciPy against the Anaconda-provided Python 3.7. There are some issues with that.</p>
<ol dir="auto">
<li>The <code class="notranslate">conda activate</code> scripts set <code class="notranslate">LDFLAGS</code>. This needs to be handled by setting <code class="notranslate">export NPY_DISTUTILS_APPEND_FLAGS=1</code>. That's a good thing to put in your <code class="notranslate">.bash_profile</code> anyway. So not a big issue.</li>
<li>The build fails because of include paths:</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In file included from numpy/core/src/common/numpyos.c:23:0:
/home/rgommers/anaconda3/x86_64-conda_cos6-linux-gnu/sysroot/usr/include/xlocale.h:28:16: error: redefinition of 'struct __locale_struct'
 typedef struct __locale_struct
                ^~~~~~~~~~~~~~~
In file included from /usr/include/bits/types/locale_t.h:22:0,
                 from /usr/include/string.h:152,
                 from /home/rgommers/anaconda3/include/python3.7m/Python.h:30,
                 from numpy/core/src/common/numpyos.c:2:
/usr/include/bits/types/__locale_t.h:28:8: note: originally defined here
 struct __locale_struct
        ^~~~~~~~~~~~~~~
In file included from numpy/core/src/common/numpyos.c:23:0:
/home/rgommers/anaconda3/x86_64-conda_cos6-linux-gnu/sysroot/usr/include/xlocale.h:40:4: error: conflicting types for '__locale_t'
 } *__locale_t;
    ^~~~~~~~~~
In file included from /usr/include/bits/types/locale_t.h:22:0,
                 from /usr/include/string.h:152,
                 from /home/rgommers/anaconda3/include/python3.7m/Python.h:30,
                 from numpy/core/src/common/numpyos.c:2:
/usr/include/bits/types/__locale_t.h:42:33: note: previous declaration of '__locale_t' was here
 typedef struct __locale_struct *__locale_t;
                                 ^~~~~~~~~~
In file included from numpy/core/src/common/numpyos.c:23:0:
/home/rgommers/anaconda3/x86_64-conda_cos6-linux-gnu/sysroot/usr/include/xlocale.h:43:20: error: conflicting types for 'locale_t'
 typedef __locale_t locale_t;
                    ^~~~~~~~
In file included from /usr/include/string.h:152:0,
                 from /home/rgommers/anaconda3/include/python3.7m/Python.h:30,
                 from numpy/core/src/common/numpyos.c:2:
/usr/include/bits/types/locale_t.h:24:20: note: previous declaration of 'locale_t' was here
 typedef __locale_t locale_t;
                    ^~~~~~~~
numpy/core/src/common/numpyos.c: In function 'NumPyOS_ascii_strtold':
numpy/core/src/common/numpyos.c:568:13: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
     clocale = newlocale(LC_ALL_MASK, &quot;C&quot;, NULL);
             ^
numpy/core/src/common/numpyos.c:571:39: warning: passing argument 3 of 'strtold_l' from incompatible pointer type [-Wincompatible-pointer-types]
         result = strtold_l(s, endptr, clocale);
                                       ^~~~~~~
In file included from /home/rgommers/anaconda3/include/python3.7m/Python.h:34:0,
                 from numpy/core/src/common/numpyos.c:2:
/usr/include/stdlib.h:303:20: note: expected 'locale_t {aka struct __locale_struct *}' but argument is of type 'locale_t {aka struct __locale_struct *}'
 extern long double strtold_l (const char *__restrict __nptr,
                    ^~~~~~~~~
numpy/core/src/common/numpyos.c:572:20: warning: passing argument 1 of 'freelocale' from incompatible pointer type [-Wincompatible-pointer-types]
         freelocale(clocale);
                    ^~~~~~~
In file included from numpy/core/src/common/numpyos.c:4:0:
/usr/include/locale.h:180:13: note: expected 'locale_t {aka struct __locale_struct *}' but argument is of type 'locale_t {aka struct __locale_struct *}'
 extern void freelocale (locale_t __dataset) __THROW;
             ^~~~~~~~~~
x86_64-conda_cos6-linux-gnu-cc: numpy/core/src/common/npy_longdouble.c
x86_64-conda_cos6-linux-gnu-cc: numpy/core/src/multiarray/mapping.c
x86_64-conda_cos6-linux-gnu-cc: numpy/core/src/multiarray/methods.c
x86_64-conda_cos6-linux-gnu-cc: numpy/core/src/umath/matmul.c
x86_64-conda_cos6-linux-gnu-cc: numpy/core/src/umath/ufunc_object.c
error: Command &quot;/home/rgommers/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -fPIC -DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DSCIPY_MKL_H -DHAVE_CBLAS -I/usr/local/include -I/usr/include -I/home/rgommers/anaconda3/include -Inumpy/core/src/umath -Inumpy/core/src/npymath -Inumpy/core/src/common -Inumpy/core/include -Inumpy/core/include/numpy -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/home/rgommers/anaconda3/include/python3.7m -Inumpy/core/src/common -Inumpy/core/src/npymath -Inumpy/core/src/common -Inumpy/core/src/npymath -c numpy/core/src/common/numpyos.c -o build/temp.linux-x86_64-3.7/numpy/core/src/common/numpyos.o -MMD -MF build/temp.linux-x86_64-3.7/numpy/core/src/common/numpyos.o.d&quot; failed with exit status 1"><pre class="notranslate"><code class="notranslate">In file included from numpy/core/src/common/numpyos.c:23:0:
/home/rgommers/anaconda3/x86_64-conda_cos6-linux-gnu/sysroot/usr/include/xlocale.h:28:16: error: redefinition of 'struct __locale_struct'
 typedef struct __locale_struct
                ^~~~~~~~~~~~~~~
In file included from /usr/include/bits/types/locale_t.h:22:0,
                 from /usr/include/string.h:152,
                 from /home/rgommers/anaconda3/include/python3.7m/Python.h:30,
                 from numpy/core/src/common/numpyos.c:2:
/usr/include/bits/types/__locale_t.h:28:8: note: originally defined here
 struct __locale_struct
        ^~~~~~~~~~~~~~~
In file included from numpy/core/src/common/numpyos.c:23:0:
/home/rgommers/anaconda3/x86_64-conda_cos6-linux-gnu/sysroot/usr/include/xlocale.h:40:4: error: conflicting types for '__locale_t'
 } *__locale_t;
    ^~~~~~~~~~
In file included from /usr/include/bits/types/locale_t.h:22:0,
                 from /usr/include/string.h:152,
                 from /home/rgommers/anaconda3/include/python3.7m/Python.h:30,
                 from numpy/core/src/common/numpyos.c:2:
/usr/include/bits/types/__locale_t.h:42:33: note: previous declaration of '__locale_t' was here
 typedef struct __locale_struct *__locale_t;
                                 ^~~~~~~~~~
In file included from numpy/core/src/common/numpyos.c:23:0:
/home/rgommers/anaconda3/x86_64-conda_cos6-linux-gnu/sysroot/usr/include/xlocale.h:43:20: error: conflicting types for 'locale_t'
 typedef __locale_t locale_t;
                    ^~~~~~~~
In file included from /usr/include/string.h:152:0,
                 from /home/rgommers/anaconda3/include/python3.7m/Python.h:30,
                 from numpy/core/src/common/numpyos.c:2:
/usr/include/bits/types/locale_t.h:24:20: note: previous declaration of 'locale_t' was here
 typedef __locale_t locale_t;
                    ^~~~~~~~
numpy/core/src/common/numpyos.c: In function 'NumPyOS_ascii_strtold':
numpy/core/src/common/numpyos.c:568:13: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
     clocale = newlocale(LC_ALL_MASK, "C", NULL);
             ^
numpy/core/src/common/numpyos.c:571:39: warning: passing argument 3 of 'strtold_l' from incompatible pointer type [-Wincompatible-pointer-types]
         result = strtold_l(s, endptr, clocale);
                                       ^~~~~~~
In file included from /home/rgommers/anaconda3/include/python3.7m/Python.h:34:0,
                 from numpy/core/src/common/numpyos.c:2:
/usr/include/stdlib.h:303:20: note: expected 'locale_t {aka struct __locale_struct *}' but argument is of type 'locale_t {aka struct __locale_struct *}'
 extern long double strtold_l (const char *__restrict __nptr,
                    ^~~~~~~~~
numpy/core/src/common/numpyos.c:572:20: warning: passing argument 1 of 'freelocale' from incompatible pointer type [-Wincompatible-pointer-types]
         freelocale(clocale);
                    ^~~~~~~
In file included from numpy/core/src/common/numpyos.c:4:0:
/usr/include/locale.h:180:13: note: expected 'locale_t {aka struct __locale_struct *}' but argument is of type 'locale_t {aka struct __locale_struct *}'
 extern void freelocale (locale_t __dataset) __THROW;
             ^~~~~~~~~~
x86_64-conda_cos6-linux-gnu-cc: numpy/core/src/common/npy_longdouble.c
x86_64-conda_cos6-linux-gnu-cc: numpy/core/src/multiarray/mapping.c
x86_64-conda_cos6-linux-gnu-cc: numpy/core/src/multiarray/methods.c
x86_64-conda_cos6-linux-gnu-cc: numpy/core/src/umath/matmul.c
x86_64-conda_cos6-linux-gnu-cc: numpy/core/src/umath/ufunc_object.c
error: Command "/home/rgommers/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -fPIC -DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DSCIPY_MKL_H -DHAVE_CBLAS -I/usr/local/include -I/usr/include -I/home/rgommers/anaconda3/include -Inumpy/core/src/umath -Inumpy/core/src/npymath -Inumpy/core/src/common -Inumpy/core/include -Inumpy/core/include/numpy -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/home/rgommers/anaconda3/include/python3.7m -Inumpy/core/src/common -Inumpy/core/src/npymath -Inumpy/core/src/common -Inumpy/core/src/npymath -c numpy/core/src/common/numpyos.c -o build/temp.linux-x86_64-3.7/numpy/core/src/common/numpyos.o -MMD -MF build/temp.linux-x86_64-3.7/numpy/core/src/common/numpyos.o.d" failed with exit status 1
</code></pre></div>
<p dir="auto">The problem seems to be that we explicitly include <code class="notranslate">/usr/include/</code> and <code class="notranslate">/usr/local/include/</code> in the <code class="notranslate">default_include_dirs</code> in <code class="notranslate">numpy/distutils/system_info.py</code>. If we remove those, then everything builds fine. I think this is the right thing to do, because those paths are already<br>
included by compilers anyway.</p>
<p dir="auto">The conda compiler docs linked above don't discuss this. They do explain this:<br>
<em>Some users want to use the latest Anaconda packages but do not yet want to use the Anaconda compilers. To enable this, the latest Python package builds have a default _sysconfigdata file. This file sets the compilers provided by the system, such as gcc and g++, as the default compilers. This way legacy recipes will keep working.</em><br>
It continues to talk about how to switch to conda compilers by setting <code class="notranslate">_PYTHON_SYSCONFIGDATA_NAME</code>, however this isn't enough.</p>
<p dir="auto">This is the default (from <code class="notranslate">anaconda3/lib/python3.7/distutils/sysconfig.py</code>):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="export _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_m_linux_x86_64-linux-gnu"><pre class="notranslate"><code class="notranslate">export _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_m_linux_x86_64-linux-gnu
</code></pre></div>
<p dir="auto">So setting it to that is a do-nothing. If you get the name wrong you'll get an error like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ModuleNotFoundError: No module named '_sysconfigdata_m_linux_x86_64-linux-gn'"><pre class="notranslate"><code class="notranslate">ModuleNotFoundError: No module named '_sysconfigdata_m_linux_x86_64-linux-gn'
</code></pre></div>
<p dir="auto">Now we set it to the value as set by <code class="notranslate">anaconda3/etc/conda/activate.d/activate-gcc_linux-64.sh</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="export _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_x86_64_conda_cos6_linux_gnu"><pre class="notranslate"><code class="notranslate">export _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_x86_64_conda_cos6_linux_gnu
</code></pre></div>
<p dir="auto">This is what the conda compiler docs recommend:<br>
<a href="https://docs.conda.io/projects/conda-build/en/latest/resources/compiler-tools.html#backward-compatibility" rel="nofollow">https://docs.conda.io/projects/conda-build/en/latest/resources/compiler-tools.html#backward-compatibility</a>.<br>
It still gives us the same error though:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="error: Command &quot;/home/rgommers/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -fPIC -DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DSCIPY_MKL_H -DHAVE_CBLAS -I/usr/local/include -I/usr/include -I/home/rgommers/anaconda3/include -Inumpy/core/src/umath -Inumpy/core/src/npymath -Inumpy/core/src/common -Inumpy/core/include -Inumpy/core/include/numpy -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/home/rgommers/anaconda3/include/python3.7m -Inumpy/core/src/common -Inumpy/core/src/npymath -Inumpy/core/src/common -Inumpy/core/src/npymath -c numpy/core/src/common/numpyos.c -o build/temp.linux-x86_64-3.7/numpy/core/src/common/numpyos.o -MMD -MF build/temp.linux-x86_64-3.7/numpy/core/src/common/numpyos.o.d&quot; failed with exit status 1"><pre class="notranslate"><code class="notranslate">error: Command "/home/rgommers/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -fPIC -DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DSCIPY_MKL_H -DHAVE_CBLAS -I/usr/local/include -I/usr/include -I/home/rgommers/anaconda3/include -Inumpy/core/src/umath -Inumpy/core/src/npymath -Inumpy/core/src/common -Inumpy/core/include -Inumpy/core/include/numpy -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/home/rgommers/anaconda3/include/python3.7m -Inumpy/core/src/common -Inumpy/core/src/npymath -Inumpy/core/src/common -Inumpy/core/src/npymath -c numpy/core/src/common/numpyos.c -o build/temp.linux-x86_64-3.7/numpy/core/src/common/numpyos.o -MMD -MF build/temp.linux-x86_64-3.7/numpy/core/src/common/numpyos.o.d" failed with exit status 1
</code></pre></div>
<p dir="auto">Also axplicitly including <code class="notranslate">--sysroot=/home/rgommers/anaconda3/x86_64-conda_cos6-linux-gnu/sysroot</code> in that failing build command doesn't change the build error.</p>
<p dir="auto">On the other hand, this fixes things (both with and without setting <code class="notranslate">_PYTHON_SYSCONFIGDATA_NAME</code>):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py
index 4d923ad26..8d32db6f2 100644
--- a/numpy/distutils/system_info.py
+++ b/numpy/distutils/system_info.py
@@ -278,7 +278,7 @@ else:
                                  '/opt/local/lib', '/sw/lib'], platform_bits)
     default_runtime_dirs = []
     default_include_dirs = ['/usr/local/include',
-                            '/opt/include', '/usr/include',
+                            '/opt/include',
                             # path of umfpack under macports
                             '/opt/local/include/ufsparse',
                             '/opt/local/include', '/sw/include',"><pre class="notranslate"><code class="notranslate">diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py
index 4d923ad26..8d32db6f2 100644
--- a/numpy/distutils/system_info.py
+++ b/numpy/distutils/system_info.py
@@ -278,7 +278,7 @@ else:
                                  '/opt/local/lib', '/sw/lib'], platform_bits)
     default_runtime_dirs = []
     default_include_dirs = ['/usr/local/include',
-                            '/opt/include', '/usr/include',
+                            '/opt/include',
                             # path of umfpack under macports
                             '/opt/local/include/ufsparse',
                             '/opt/local/include', '/sw/include',
</code></pre></div>
<p dir="auto">I think that's the right fix (ref <a href="https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html" rel="nofollow">https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html</a>). I think that all compilers include <code class="notranslate">/usr/include/</code> in their search path (however not 100% sure).</p>