When trying to compile using -march=native on a VIA nano CPU, gcc selects "-march=core2" "-mtune=i386" then is unable to compile, as this creates a conflicts between 32 bits and 64 bits compilation modes, as show by the following test:
# echo 'int main(){return 0;}' > test.c && gcc -march=native -O2 -pipe test.c -o test && rm test.c test Compilation fails with the following error message and informations: [...] test.c:1:0: error: CPU you selected does not support x86-64 instruction set int main(){return 0;} ^ Using "-v -Q" option shows the detection problem: gnu/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.8.4/ test.c -march=core2 -mcx16 -msahf -mno-movbe -mno-aes -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2 -mno-sse4.1 -mno- lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=1024 -mtune=i386 -O2 -fno-use-linker-plugin The following patch allows gcc to select correct compilation options, which can be checked using "-v -Q" gcc options. GCC output becomes: gnu/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.8.4/ test.c -march=x86-64 -mcx16 -msahf -mno-movbe -mno-aes -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -msse3 -mssse3 -mno-sse4.2 -mno-sse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=1024 -mtune=generic -O2 -fno-use-linker-plugin which seems OK. The same problem appears with gcc 4.9.3 and 5.2, and likely with current git version. The following patch applies to gcc >= 4.9; it has been tested by recompiling the whole system from scratch on a Gentoo distribution using gcc version 4.9.3 (the current stable gcc version on Gentoo x86_64) with no issue. Please consider applying this patch to future releases. Jocelyn Mayer <l_ind...@magic.fr> PS: please CC me to any answer to this mail, as I didn't subscribe to the mailing list. --- --- gcc/config/i386/driver-i386.c.orig 2015-02-02 05:20:49.000000000 +0100 +++ gcc/config/i386/driver-i386.c 2015-08-23 01:11:03.000000000 +0200 @@ -601,15 +601,20 @@ switch (family) { case 6: - if (model > 9) - /* Use the default detection procedure. */ + if (has_longmode) processor = PROCESSOR_GENERIC; - else if (model == 9) - cpu = "c3-2"; - else if (model >= 6) - cpu = "c3"; else - processor = PROCESSOR_GENERIC; + { + if (model > 9) + /* Use the default detection procedure. */ + processor = PROCESSOR_GENERIC; + else if (model == 9) + cpu = "c3-2"; + else if (model >= 6) + cpu = "c3"; + else + processor = PROCESSOR_GENERIC; + } break; case 5: if (has_3dnow) @@ -623,6 +628,8 @@ /* We have no idea. */ processor = PROCESSOR_GENERIC; } + } else { + processor = PROCESSOR_GENERIC; } } else @@ -840,7 +847,12 @@ if (arch) { if (has_ssse3) - cpu = "core2"; + { + if (vendor == signature_CENTAUR_ebx) + cpu = "x86-64"; + else + cpu = "core2"; + } else if (has_sse3) { if (has_longmode)