Skip to content

BUG: Building with AVX2 support causes illegal instruction error on import #32457

Description

@salfter

Describe the issue:

https://bugs.gentoo.org/972461#c31

I had AVX2 enabled on a Ryzen 7 3800X (aka Zen 2) host, which is supposed to support AVX2. After setting this in CPU_FLAGS_X86 and doing a full system rebuild, attempting to import numpy would crash with an illegal instruction error. This kept pybind11 (and some other packages) from building.

I ended up getting it working by disabling AVX2 for numpy and rebuilding numpy. Something like the following in /etc/portage/package.use will do:

dev-python/numpy CPU_FLAGS_X86: -avx2

Setting -fno-plt or -fplt in CPUFLAGS (as someone else had suggested) made no difference.

There was some speculation that gcc was doing something weird, but since whatever it is is affecting numpy in this way, you might want to look into it.

Reproduce the code example:

python -c 'import numpy'

Error message:

Illegal instruction

Python and NumPy Versions:

2.5.1
3.14.6 (main, Aug 26 2026, 11:38:32) [GCC 15.3.0]

Runtime Environment:

[{'numpy_version': '2.5.1',
'python': '3.14.6 (main, Aug 26 2026, 11:38:32) [GCC 15.3.0]',
'uname': uname_result(system='Linux', node='janeway', release='6.18.43-gentoo-dist-bin', version='#1 SMP PREEMPT_DYNAMIC Thu Aug 6 19:07:48 -00 2026', machine='x86_64')},
{'simd_extensions': {'baseline': ['X86_V2'],
'found': ['X86_V3'],
'not_found': ['X86_V4', 'AVX512_ICL', 'AVX512_SPR']}},
{'ignore_floating_point_errors_in_matmul': False},
{'available_backends': ['NETLIB', 'OPENBLAS'],
'current_backend': 'OPENBLAS',
'filepath': '/usr/lib64/libflexiblas.so.3.5',
'internal_api': 'flexiblas',
'loaded_backends': ['OPENBLAS'],
'num_threads': 16,
'prefix': 'libflexiblas',
'user_api': 'blas',
'version': '3.5.0'},
{'available_backends': ['NETLIB', 'OPENBLAS'],
'current_backend': 'OPENBLAS',
'filepath': '/usr/lib64/flexiblas/libflexiblas_fallback_lapack.so',
'internal_api': 'flexiblas',
'loaded_backends': ['OPENBLAS'],
'num_threads': 16,
'prefix': 'libflexiblas',
'user_api': 'blas',
'version': '3.5.0'},
{'architecture': 'ZEN',
'filepath': '/usr/lib64/libopenblas_zenp-r0.3.33.so',
'internal_api': 'openblas',
'num_threads': 16,
'prefix': 'libopenblas',
'threading_layer': 'openmp',
'user_api': 'blas',
'version': '0.3.33'},
{'filepath': '/usr/lib/gcc/x86_64-pc-linux-gnu/15/libgomp.so.1.0.0',
'internal_api': 'openmp',
'num_threads': 16,
'prefix': 'libgomp',
'user_api': 'openmp',
'version': None}]

How does this issue affect you or how did you find it:

It blocked installation/updates of any additional Python packages that depend on numpy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions