@@ -48,10 +48,11 @@ def is_win(): # pragma: no cover
4848 elif is_win ():
4949 CPP_COMPILE_FLAGS += ["/std:c++17" ]
5050 else :
51- # Use x86-64-v3 (AVX2) as baseline - widely supported since 2013
52- # Avoid -march=native to prevent AVX-512 and newer CPU-specific instructions
53- CPP_COMPILE_FLAGS += ["-std=c++17" , "-march=x86-64-v3" , "-fvisibility=default" ]
54- C_COMPILE_FLAGS += ["-march=x86-64-v3" , "-fvisibility=default" ]
51+ # Target AVX2-era CPUs (2013+) without relying on -march=native or x86-64-v3, which older GCC
52+ # releases do not recognise. Explicitly request AVX2 features while avoiding AVX-512.
53+ avx2_flags = ["-mavx2" , "-mfma" , "-mf16c" ]
54+ CPP_COMPILE_FLAGS += ["-std=c++17" , "-fvisibility=default" ] + avx2_flags
55+ C_COMPILE_FLAGS += ["-fvisibility=default" ] + avx2_flags
5556
5657 include_dirs = []
5758 # Get the C++ include directory
@@ -195,10 +196,9 @@ def is_win(): # pragma: no cover
195196 # This is a good baseline for modern CPUs (2013+) while avoiding AVX-512
196197 machine = platform .machine ().lower ()
197198 system = platform .system ().lower ()
198- if machine .startswith ("arm" ) and not machine .startswith ("aarch64" ):
199- if system != "darwin" :
200- # ARM32 NEON is generally safe as baseline
201- CPP_COMPILE_FLAGS .append ("-mfpu=neon" )
199+ if machine .startswith ("arm" ) and not machine .startswith ("aarch64" ) and system != "darwin" :
200+ # ARM32 NEON is generally safe as baseline
201+ CPP_COMPILE_FLAGS .append ("-mfpu=neon" )
202202
203203 setup_config = {
204204 "name" : LIBRARY ,
0 commit comments