c++cgccgcc4

What exactly does -march=native do?


Gentoo Wiki told me the following:

Warning: GCC 4.2 and above support -march=native. -march=native applies additional settings beyond -march, specific to your CPU. Unless you have a specific reason not to (e.g. distcc cross-compiling), you should probably be using -march=native, rather than anything listed below.

What are those additional settings?


Solution

  • Nevermind.

    $ cc -march=core2 -E -v - </dev/null 2>&1 | grep cc1
     /[...]/cc1 -E -quiet -v -iprefix /[...]/4.3.2/ - -march=core2
    
    $ cc -march=native -E -v - </dev/null 2>&1 | grep cc1
     /[...]/cc1 -E -quiet -v -iprefix /[...]/4.3.2/ - -march=core2 -mcx16 -msahf --param l1-cache-size=32 --param l1-cache-line-size=64 -mtune=core2
    

    I'm starting to like this option a lot. -mcx16 and -msahf are two additional CPU instructions gcc can now use, which weren't available in earlier Core2's.