<p dir="auto">On AlpineLinux, which is a mil based Linux distributive, some of numpy's test fail. The log is attached.<br>
<a href="https://github.com/numpy/numpy/files/106482/log.txt">log.txt</a></p>
<p dir="auto">There are two types of issues - one for various missed overflow/underflow exceptions, the second one is for incorrect results from musl's trigonometric functions.</p>
<p dir="auto">The first one can be fixed by including <code class="notranslate">fenv.h</code> header in musl builds, AFAIU this can be done in <code class="notranslate">numpy/numpy/core/src/npymath/ieee754.c.src</code> and <code class="notranslate">numpy/core/include/numpy/ufuncobject.h  </code> by replacing <code class="notranslate">__GLIBC__</code> with <code class="notranslate">__GNUC__</code></p>
<p dir="auto">The second group can be fixed by disabling the trigonometric functions in <code class="notranslate">numpy/numpy/core/src/private/npy_config.h</code> not only for glibc, but also for musl. An issue here is that musl doesn't provide any macro like the <code class="notranslate">__GLIBC__</code> to detect it.</p>
<p dir="auto">So the question, is numpy interested in such a patch? Could you please share your opinions  what is best way to implement it?</p>
<p dir="auto">Otherwise the patch can be implement in corresponding package for AlpineLinux</p>
<p dir="auto">I've ran into issue with linalg.solve on different systems: in RHEL and Ubuntu it will raise an LinAlgError exception, but on Alpine it will return <code class="notranslate">nan</code>.</p>
<p dir="auto">Ubuntu:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ docker run -it --rm ubuntu:18.04 /bin/sh
$ apt-get install python3-numpy
# python3
Python 3.6.6 (default, Sep 12 2018, 18:26:19)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import numpy
&gt;&gt;&gt; numpy.linalg.solve(numpy.array([[0]]), numpy.array([[0]]))
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;/usr/lib/python3/dist-packages/numpy/linalg/linalg.py&quot;, line 375, in solve
    r = gufunc(a, b, signature=signature, extobj=extobj)
  File &quot;/usr/lib/python3/dist-packages/numpy/linalg/linalg.py&quot;, line 90, in _raise_linalgerror_singular
    raise LinAlgError(&quot;Singular matrix&quot;)
numpy.linalg.linalg.LinAlgError: Singular matrix"><pre class="notranslate">$ docker run -it --rm ubuntu:18.04 /bin/sh
$ apt-get install python3-numpy
<span class="pl-c"><span class="pl-c">#</span> python3</span>
Python 3.6.6 (default, Sep 12 2018, 18:26:19)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type <span class="pl-s"><span class="pl-pds">"</span>help<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>copyright<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>credits<span class="pl-pds">"</span></span> or <span class="pl-s"><span class="pl-pds">"</span>license<span class="pl-pds">"</span></span> <span class="pl-k">for</span> more information.
<span class="pl-k">&gt;&gt;&gt;</span> import numpy
<span class="pl-k">&gt;&gt;&gt;</span> numpy.linalg.solve(numpy.array([[0]]), numpy.array([[0]]))
Traceback (most recent call last):
  File <span class="pl-s"><span class="pl-pds">"</span>&lt;stdin&gt;<span class="pl-pds">"</span></span>, line 1, <span class="pl-k">in</span> <span class="pl-k">&lt;</span>module<span class="pl-k">&gt;</span>
  File <span class="pl-s"><span class="pl-pds">"</span>/usr/lib/python3/dist-packages/numpy/linalg/linalg.py<span class="pl-pds">"</span></span>, line 375, <span class="pl-k">in</span> solve
    r <span class="pl-k">=</span> gufunc(a, b, signature=signature, extobj=extobj)
  File <span class="pl-s"><span class="pl-pds">"</span>/usr/lib/python3/dist-packages/numpy/linalg/linalg.py<span class="pl-pds">"</span></span>, line 90, <span class="pl-k">in</span> _raise_linalgerror_singular
    raise LinAlgError(<span class="pl-s"><span class="pl-pds">"</span>Singular matrix<span class="pl-pds">"</span></span>)
numpy.linalg.linalg.LinAlgError: Singular matrix</pre></div>
<p dir="auto">Alpine:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ docker run -it --rm alpine:3.8 /bin/sh
# apk --update add python3 py3-numpy
/ # python3
Python 3.6.6 (default, Aug 24 2018, 05:04:18)
[GCC 6.4.0] on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import numpy
&gt;&gt;&gt; numpy.linalg.solve(numpy.array([[0]]), numpy.array([[0]]))
array([[nan]])"><pre class="notranslate"><code class="notranslate">$ docker run -it --rm alpine:3.8 /bin/sh
# apk --update add python3 py3-numpy
/ # python3
Python 3.6.6 (default, Aug 24 2018, 05:04:18)
[GCC 6.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import numpy
&gt;&gt;&gt; numpy.linalg.solve(numpy.array([[0]]), numpy.array([[0]]))
array([[nan]])
</code></pre></div>
<p dir="auto">I would expect to receive same exception on Alpine as well. Is this known issue?</p>
<p dir="auto">I've tried to use either lapack  or openblas on alpine, compile numpy from source — it's still would return <code class="notranslate">nan</code>.</p>