This works: /usr/local/bin/gcc -O3 -mtune=native -c Weapon.c This does not: /usr/local/bin/gcc -march=native Weapon.c -c -O3 Weapon.c:1: error: bad value (native) for -march= switch Weapon.c:1: error: bad value (native) for -mtune= switch
gcc -v yields: Using built-in specs. Target: i386-apple-darwin8.10.1 Configured with: ../gcc-4.2.1/configure --disable-checking --enable- languages=c,c++,fortran --with-arch=nocona Thread model: posix gcc version 4.2.1 ===== Per a suggestion from Ian Lance Taylor: /usr/local/bin/gcc -v -c -O3 -march=native Weapon.c /usr/local/libexec/gcc/i386-apple-darwin8.10.1/4.2.1/cc1 -quiet -v - D__DYNAMIC__ Weapon.c -fPIC -quiet -dumpbase Weapon.c -march=native - auxbase Weapon -O3 -version -o /var/tmp//ccSVG0aD.s ===== To which he replied with the issue: The problem is that the driver code is not working, and the bug is that gcc doesn't handle that correctly. There is some code in gcc to handle the driver code failing, and it works for -mtune=native, but not for -march=native. The driver code is supposed to change the -march=native to be -march=XXX for your CPU. The code is in gcc/config/i386/driver-i386.c. OK, I see the problem. The code in gcc/config/i386/linux.h looks like this: #define CC1_SPEC "%(cc1_cpu) %{profile:-p}" gcc/config/i386/darwin.h looks like this: #define CC1_SPEC "%{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}} \ %{!mmacosx-version-min=*:-mmacosx-version-min=%(darwin_minversion)} \ %{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }}" The version in darwin.h is missing the %(cc1_cpu). So there are two bugs: the darwin.h code does not invoke the driver code for -march=native or -mtune=native, and the i386.c code does not correctly handle -march=native. The effect of the first bug is that neither -march=native nor -mtune=native work on Darwin. The effect of the second bug is that -march=native actually gives an error, rather than being equivalent to -march=generic. -- Summary: -march=native does not work on darwin Product: gcc Version: 4.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: driver AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: fago at caltech dot edu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33144