Search code examples
pythonpipclang

Unknown target CPU 'x86-64-v3' when building via pip/clang


When installing the netifaces package with pip, I get the following error while building its wheel (Debian 10, and Python 3.10):

building 'netifaces' extension
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64-v3 -fPIC -fPIC -DNETIFACES_VERSION=0.11.0 -I/path/to/venv/include -I/install/include/python3.10 -c netifaces.c -o build/temp.linux-x86_64-cpython-310/netifaces.o
error: unknown target CPU 'x86-64-v3'
note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cannonlake, icelake-client, icelake-server, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, x86-64
error: command '/usr/bin/clang' failed with exit code 1

I see that -march=x86-64-v3 is on the clang command line, and that the list of supported architectures includes x86-64 but not x86-64-v3.

How can I either a) set -march=x86-64 during the pip install, or b) add x86-64-v3 to the supported architecture list?

I am a little confused because I installed clang with apt-get install clang so my assumption is that it would come with support for the current architecture.


If it matters:

$ uname -a
Linux magic 4.19.0-26-amd64 #1 SMP Debian 4.19.304-1 (2024-01-09) x86_64 GNU/Linux

Also:

>>> import platform
>>> print(platform.machine())
x86_64

Solution

  • The x86-64-vX nomenclature was introduced just within the past few years, and the first version of clang/llvm to support it was 12.0.0.

    Debian 10 (buster) is very old, and becomes completely unsupported in one month.. In particular, its default clang/llvm version is 7.0. If you upgrade to the current Debian 12 (bookworm), its default clang version is 14 and so then all of this will just work.

    If that isn't possible, then instead of the clang package you can install clang-12 or clang-13 which are the latest versions that buster includes. See How to install Clang 11 on Debian for the procedure, replacing 11 with 12 or 13 as appropriate.