尝试在本地构建 numpy 时,我收到以下错误:
gcc: numpy/core/src/common/mem_overlap.c
gcc -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fno-semantic-interposition -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now build/temp.linux-x86_64-3.8/numpy/core/src/multiarray/_multiarray_tests.o build/temp.linux-x86_64-3.8/numpy/core/src/common/mem_overlap.o -L/usr/lib -Lbuild/temp.linux-x86_64-3.8 -lnpymath -o numpy/core/_multiarray_tests.cpython-38-x86_64-linux-gnu.so
/usr/bin/ld: build/temp.linux-x86_64-3.8/numpy/core/src/common/mem_overlap.o:/home/ross/repos/numpy/numpy/core/include/numpy/ndarraytypes.h:1824: multiple definition of `PyArrayDTypeMeta_Type'; build/temp.linux-x86_64-3.8/numpy/core/src/multiarray/_multiarray_tests.o:/home/ross/repos/numpy/numpy/core/include/numpy/ndarraytypes.h:1824: first defined here
collect2: error: ld returned 1 exit status
error: Command "gcc -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fno-semantic-interposition -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now build/temp.linux-x86_64-3.8/numpy/core/src/multiarray/_multiarray_tests.o build/temp.linux-x86_64-3.8/numpy/core/src/common/mem_overlap.o -L/usr/lib -Lbuild/temp.linux-x86_64-3.8 -lnpymath -o numpy/core/_multiarray_tests.cpython-38-x86_64-linux-gnu.so" failed with exit status 1
`bisect`ing 将 1809a0fde 确定为问题的根源。 请注意,此错误仅在我使用 gcc 10.1 时发生。 gcc 9.3 没有遇到任何问题。 ### 重现代码示例:$ git clone https://github.com/numpy/numpy.git
$ git checkout 1809a0fde
$ pip install -r test_requirements.txt
$ python setup.py build_ext -i
### 错误信息:从 numpy 源目录运行。 Cythonizing 源 numpy/random/_bounded_integers.pxd.in 没有改变 处理 numpy/random/mtrand.pyx numpy/random/_common.pyx 没有改变 处理 numpy/random/_mt19937.pyx 处理 numpy/random/_pcg64.pyx 处理 numpy/random/_generator.pyx numpy/random/_bounded_integers.pyx 没有改变 numpy/random/_sfc64.pyx 没有改变 numpy/random/_philox.pyx 没有改变 numpy/random/bit_generator.pyx 没有改变 numpy/random/_bounded_integers.pyx.in 没有改变 numpy/core/setup.py:406: MismatchCAPIWarning:检测到 API 不匹配,必须更新 C API 版本号。 当前 C api 版本为 13,校验和为 17a0f366e55ec05e5c5c149123478452,但在 core/codegen_dir/cversions.txt 中记录的 C API 版本 13 校验和为 5b0e8bbded00b166125974fc73e80 如果在 C API 中添加了函数,则必须更新 numpy/core/setup_common.py 中的 C_API_VERSION。 check_api_version(C_API_VERSION, codegen_dir) blas_opt_info: blas_mkl_info: 自定义 UnixCCompiler 在 ['/home/ross/.virtualenvs/tmp/lib'、'/usr/local/lib'、'/usr/lib64'、'/usr/lib'、'/usr/lib/' 中找不到库 mkl_rt ] 无法使用 blis_info: 在 ['/home/ross/.virtualenvs/tmp/lib'、'/usr/local/lib'、'/usr/lib64'、'/usr/lib'、'/usr/lib/' 中找不到库 blis ] 无法使用 openblas_info: C 编译器:gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fno-semantic-interposition -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fPIC 创建 /tmp/tmpp_pb97eg/tmp 创建/tmp/tmpp_pb97eg/tmp/tmpp_pb97eg 编译选项:'-c' gcc:/tmp/tmpp_pb97eg/source.c gcc -pthread /tmp/tmpp_pb97eg/tmp/tmpp_pb97eg/source.o -L/usr/lib64 -lopenblas -o /tmp/tmpp_pb97eg/a.out 成立: 图书馆 = ['openblas','openblas'] library_dirs = ['/usr/lib64'] 语言 = c define_macros = [('HAVE_CBLAS', None)] 成立: 图书馆 = ['openblas','openblas'] library_dirs = ['/usr/lib64'] 语言 = c define_macros = [('HAVE_CBLAS', None)] “numpy/distutils”中不存在的路径:“site.cfg” lapack_opt_info: lapack_mkl_info: 在 ['/home/ross/.virtualenvs/tmp/lib'、'/usr/local/lib'、'/usr/lib64'、'/usr/lib'、'/usr/lib/' 中找不到库 mkl_rt ] 无法使用 openblas_lapack_info: C 编译器:gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fno-semantic-interposition -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fPIC 创建 /tmp/tmpeicqr4ho/tmp 创建/tmp/tmpeicqr4ho/tmp/tmpeicqr4ho 编译选项:'-c' gcc:/tmp/tmpeicqr4ho/source.c gcc -pthread /tmp/tmpeicqr4ho/tmp/tmpeicqr4ho/source.o -L/usr/lib64 -lopenblas -o /tmp/tmpeicqr4ho/a.out /usr/bin/ld: /tmp/tmpeicqr4ho/tmp/tmpeicqr4ho/source.o: 在函数‘main’中: /tmp/tmpeicqr4ho/source.c:4:对`zungqr_'的未定义引用 collect2: 错误: ld 返回 1 个退出状态 无法使用 openblas_clapack_info: 在 ['/home/ross/.virtualenvs/tmp/lib'、'/usr/local/lib'、'/usr/lib64'、'/usr/lib'、'/usr/lib 中找不到库 openblas、lapack /'] 无法使用 火焰信息: 在 ['/home/ross/.virtualenvs/tmp/lib'、'/usr/local/lib'、'/usr/lib64'、'/usr/lib'、'/usr/lib/' 中找不到库火焰] 无法使用 atlas_3_10_threads_info: 设置 PTATLAS=ATLAS 在 /home/ross/.virtualenvs/tmp/lib 中找不到库 lapack_atlas 图书馆 tatlas,在 /home/ross/.virtualenvs/tmp/lib 中找不到 tatlas 在 /usr/local/lib 中找不到库 lapack_atlas 库 tatlas,在 /usr/local/lib 中找不到 tatlas 在 /usr/lib64 中找不到库 lapack_atlas 库 tatlas,在 /usr/lib64 中找不到 tatlas 在 /usr/lib 中找不到库 lapack_atlas 库 tatlas,在 /usr/lib 中找不到 tatlas 在 /usr/lib/ 中找不到库 lapack_atlas 库 tatlas,在 /usr/lib/ 中找不到 tatlas无法使用 atlas_3_10_info: 在 /home/ross/.virtualenvs/tmp/lib 中找不到库 lapack_atlas 图书馆 satlas,在 /home/ross/.virtualenvs/tmp/lib 中找不到 在 /usr/local/lib 中找不到库 lapack_atlas 在 /usr/local/lib 中找不到库 satlas,satlas 在 /usr/lib64 中找不到库 lapack_atlas 图书馆 satlas,satlas 在 /usr/lib64 中找不到 在 /usr/lib 中找不到库 lapack_atlas 图书馆 satlas,satlas 在 /usr/lib 中找不到 在 /usr/lib/ 中找不到库 lapack_atlas 图书馆 satlas,satlas 在 /usr/lib/ 中找不到 无法使用 atlas_threads_info: 设置 PTATLAS=ATLAS 在 /home/ross/.virtualenvs/tmp/lib 中找不到库 lapack_atlas 在 /home/ross/.virtualenvs/tmp/lib 中找不到库 ptf77blas、ptcblas、atlas 在 /usr/local/lib 中找不到库 lapack_atlas 在 /usr/local/lib 中找不到库 ptf77blas、ptcblas、atlas 在 /usr/lib64 中找不到库 lapack_atlas 在 /usr/lib64 中找不到库 ptf77blas、ptcblas、atlas 在 /usr/lib 中找不到库 lapack_atlas 在 /usr/lib 中找不到库 ptf77blas、ptcblas、atlas 在 /usr/lib/ 中找不到库 lapack_atlas 在 /usr/lib/ 中找不到库 ptf77blas、ptcblas、atlas 无法使用 atlas_info: 在 /home/ross/.virtualenvs/tmp/lib 中找不到库 lapack_atlas 在 /home/ross/.virtualenvs/tmp/lib 中找不到库 f77blas、cblas、atlas 在 /usr/local/lib 中找不到库 lapack_atlas 在 /usr/local/lib 中找不到库 f77blas、cblas、atlas 在 /usr/lib64 中找不到库 lapack_atlas 在 /usr/lib64 中找不到库 f77blas、cblas、atlas 在 /usr/lib 中找不到库 lapack_atlas 在 /usr/lib 中找不到库 f77blas、cblas、atlas 在 /usr/lib/ 中找不到库 lapack_atlas 在 /usr/lib/ 中找不到库 f77blas、cblas、atlas 无法使用 加速信息: 无法使用 lapack_info: 在 ['/home/ross/.virtualenvs/tmp/lib'、'/usr/local/lib'、'/usr/lib64'、'/usr/lib'、'/usr/lib/' 中找不到库 lapack ] 无法使用 /home/ross/repos/numpy/numpy/distutils/system_info.py:1748: 用户警告: 未找到 Lapack (http://www.netlib.org/lapack/) 库。 搜索库的目录可以在 numpy/distutils/site.cfg 文件(部分 [lapack])或通过设置 LAPACK 环境变量。 返回 getattr(self, '_calc_info_{}'.format(name))() lapack_src_info: 无法使用 /home/ross/repos/numpy/numpy/distutils/system_info.py:1748: 用户警告: 未找到 Lapack (http://www.netlib.org/lapack/) 源。 搜索源的目录可以在 numpy/distutils/site.cfg 文件(部分 [lapack_src])或通过设置 LAPACK_SRC 环境变量。 返回 getattr(self, '_calc_info_{}'.format(name))() 无法使用 numpy_linalg_lapack_lite: 成立: 语言 = c define_macros = [('HAVE_BLAS_ILP64', None), ('BLAS_SYMBOL_SUFFIX', '64_')] 'numpy/random' 中不存在的路径:'{gen}.pxd' 'numpy/random' 中不存在的路径:'{gen}.pxd' /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'define_macros' 警告。警告(味精) 运行 build_ext 运行 build_src build_src 构建 py_modules 源 构建库“npymath”源 将 'numpy/core/src/npymath' 添加到 include_dirs。 无 - h_files = ['numpy/core/src/npymath/npy_math_internal.h'] 构建库“npysort”源 将 'numpy/core/src/common' 添加到 include_dirs。 无 - h_files = ['numpy/core/src/common/npy_sort.h', 'numpy/core/src/common/npy_partition.h', 'numpy/core/src/common/npy_binsearch.h'] 构建库“npyrandom”源 构建扩展“numpy.core._multiarray_tests”源 conv_template:> numpy/core/src/multiarray/_multiarray_tests.c 构建扩展“numpy.core._multiarray_umath”源 conv_template:> numpy/core/src/multiarray/arraytypes.c conv_template:> numpy/core/src/multiarray/einsum.c conv_template:> numpy/core/src/multiarray/lowlevel_strided_loops.c conv_template:> numpy/core/src/multiarray/nditer_templ.c conv_template:> numpy/core/src/multiarray/scalartypes.c conv_template:> numpy/core/src/umath/funcs.inc 将 'numpy/core/src/umath' 添加到 include_dirs。 conv_template:> numpy/core/src/umath/simd.inc conv_template:> numpy/core/src/umath/loops.h conv_template:> numpy/core/src/umath/loops.c conv_template:> numpy/core/src/umath/matmul.h conv_template:> numpy/core/src/umath/matmul.c conv_template:> numpy/core/src/umath/clip.h conv_template:> numpy/core/src/umath/clip.c conv_template:> numpy/core/src/umath/scalarmath.c conv_template:> numpy/core/src/npymath/npy_math_internal.h 将 'numpy/core/src/npymath' 添加到 include_dirs。 conv_template:> numpy/core/src/npymath/ieee754.c conv_template:> numpy/core/src/npymath/npy_math_complex.c conv_template:> numpy/core/src/common/templ_common.h 将 'numpy/core/src/common' 添加到 include_dirs。 conv_template:> numpy/core/src/common/npy_cpu_features.c numpy.core - h_files = ['numpy/core/src/umath/funcs.inc', 'numpy/core/src/umath/simd.inc', 'numpy/core/src/umath/loops.h ', 'numpy/core/src/umath/matmul.h', 'numpy/core/src/umath/clip.h', 'numpy/core/src/npymath/npy_math_internal.h', 'numpy/core/src /common/templ_common.h'、'numpy/core/include/numpy/config.h'、'numpy/core/include/numpy/_numpyconfig.h'、'numpy/core/include/numpy/__multiarray_api.h'、 'numpy/core/include/numpy/__ufunc_api.h'] 构建扩展“numpy.core._umath_tests”源 构建扩展“numpy.core._rational_tests”源 构建扩展“numpy.core._struct_ufunc_tests”源 构建扩展“numpy.core._operand_flag_tests”源 构建扩展“numpy.fft._pocketfft_internal”源 构建扩展“numpy.linalg.lapack_lite”源 ### 警告:使用未优化的 lapack ### 构建扩展“numpy.linalg._umath_linalg”源 ### 警告:使用未优化的 lapack ### 建筑扩展“numpy.random._mt19937”来源 构建扩展“numpy.random._philox”源 构建扩展“numpy.random._pcg64”源 构建扩展“numpy.random._sfc64”源 构建扩展“numpy.random._common”源 构建扩展“numpy.random.bit_generator”源 构建扩展“numpy.random._generator”源 构建扩展“numpy.random._bounded_integers”源 构建扩展“numpy.random.mtrand”源 构建 data_files 源 build_src:构建 npy-pkg 配置文件 自定义 UnixCCompiler 使用 new_build_clib 自定义 UnixCCompiler 构建“npymath”库 编译 C 源代码 C 编译器:gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fno-semantic-interposition -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fPIC 编译选项:'-Inumpy/core/src/npymath -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/ross/.virtualenvs/tmp/include -I/usr/include/python3.8 - Inumpy/core/src/common -Inumpy/core/src/npymath -c' 额外选项:'-std=c99' gcc:numpy/core/src/npymath/halffloat.c gcc: numpy/core/src/npymath/npy_math.c gcc: numpy/core/src/npymath/npy_math_complex.c gcc:numpy/core/src/npymath/ieee754.c ar:将 4 个目标文件添加到 build/temp.linux-x86_64-3.8/libnpymath.a 构建“npyrandom”库 编译 C 源代码 C 编译器:gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fno-semantic-interposition -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fPIC 编译选项:'-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/ross/.virtualenvs/tmp/include -I/usr/include/python3.8 -Inumpy/core/src/common - Inumpy/core/src/npymath -c' 额外选项:'-std=c99' gcc:numpy/random/src/distributions/distributions.c gcc:numpy/random/src/distributions/random_mvhg_count.c gcc:numpy/random/src/distributions/random_mvhg_marginals.c gcc:numpy/random/src/distributions/random_hypergeometric.c ar:将 5 个目标文件添加到 build/temp.linux-x86_64-3.8/libnpyrandom.a 自定义 UnixCCompiler 使用 new_build_ext 自定义 UnixCCompiler 构建“numpy.core._multiarray_tests”扩展 编译 C 源代码 C 编译器:gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fno-semantic-interposition -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fPIC 编译选项:'-DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -Inumpy/core/include -Inumpy/core/include/numpy -Inum/commonpy /src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/home/ross/.virtualenvs/tmp/包含 -I/usr/include/python3.8 -Inumpy/core/src/common -Inumpy/core/src/npymath -c' 额外选项:'-std=c99' gcc:numpy/core/src/common/mem_overlap.c gcc:numpy/core/src/multiarray/_multiarray_tests.c gcc -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fno-semantic-interposition -Wl,-O1,--sort-common, --as-needed,-z,relro,-z,now build/temp.linux-x86_64-3.8/numpy/core/src/multiarray/_multiarray_tests.o build/temp.linux-x86_64-3.8/numpy/core/ src/common/mem_overlap.o -L/usr/lib -Lbuild/temp.linux-x86_64-3.8 -lnpymath -o numpy/core/_multiarray_tests.cpython-38-x86_64-linux-gnu.so /usr/bin/ld: build/temp.linux-x86_64-3.8/numpy/core/src/common/mem_overlap.o:/home/ross/repos/numpy/numpy/core/include/numpy/ndarraytypes.h: 1825:多次定义`PyArrayDTypeMeta_Type'; build/temp.linux-x86_64-3.8/numpy/core/src/multiarray/_multiarray_tests.o:/home/ross/repos/numpy/numpy/core/include/numpy/ndarraytypes.h:1825:这里首先定义 collect2: 错误: ld 返回 1 个退出状态 错误:命令“gcc -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fno-semantic-interposition -Wl,-O1,-- sort-common,--as-needed,-z,relro,-z,now build/temp.linux-x86_64-3.8/numpy/core/src/multiarray/_multiarray_tests.o build/temp.linux-x86_64-3.8/ numpy/core/src/common/mem_overlap.o -L/usr/lib -Lbuild/temp.linux-x86_64-3.8 -lnpymath -o numpy/core/_multiarray_tests.cpython-38-x86_64-linux-gnu.so”失败退出状态为 1
Python版本:3.8.3
NumPy 版本:1809a0fde
海湾合作委员会版本:10.1
我想这些定义可能不是严格意义上的(现在你注意到了,clang 静态分析也给了我一些关于它的警告)。 在我们将它们公开之前,它们可能需要移动到特定的头文件中?
我也看到了,gcc 10.1.1。 昨晚升级了我的操作系统,之后总是有问题...
我看到这个
jupiter<strong i="6">@23</strong>:06 ➤ gcc --version
gcc (GCC) 10.1.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
错误是声明中缺少extern
,gh-16435 应该修复它,Ross 为我测试了它。
最有用的评论
错误是声明中缺少
extern
,gh-16435 应该修复它,Ross 为我测试了它。