在 ARMv8架构上编译 numpy
对较早版本的numpy,如果直接执行 python3 setup.py install
,就会报告错误:
In file included from numpy/core/include/numpy/npy_math.h:580:0,
from numpy/core/src/npymath/npy_math_common.h:9,
from numpy/core/src/npymath/npy_math_complex.c.src:34:
numpy/core/src/npymath/npy_math_internal.h.src: In function ‘npy_cacoshf’:
numpy/core/src/npymath/npy_math_internal.h.src:482:12: internal compiler error: Segmentation fault
return @kind@@c@(x, y);
^~~~~~~~~~~~~~~
0x994aff crash_signal
参考 Github 上的 Issue,需要如下下的补丁文件:
diff --git a/numpy/core/src/npymath/npy_math_internal.c.src b/numpy/core/src/npymath/npy_math_internal.c.src
index dad3812..adcd83c 100644
--- numpy/core/src/npymath/npy_math_internal.h.src 2019-11-14 04:20.387180922 +0000
+++ numpy/core/src/npymath/npy_math_internal.h.src 2019-11-14 04:20.960646234 +0000
@@ -477,7 +477,7 @@
* #KIND = ATAN2,HYPOT,POW,FMOD,COPYSIGN#
*/
#ifdef HAVE_@KIND@@C@
-NPY_INPLACE @type@ npy_@kind@@c@(@type@ x, @type@ y)
+NPY_INPLACE __attribute__((optimize("-O0"))) @type@ npy_@kind@@c@(@type@ x, @type@ y)
{
return @kind@@c@(x, y);
}
将这个补丁打到 numpy/core/src/npymath/npy_math_internal.c.src 上,即可解决问题。
这个问题可以在华为社区多次搜索到。