What exactly does -march=native do?
Asked Answered
B

1

23

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?

Bluish answered 10/6, 2010 at 14:24 Comment(1)
Does this answer your question? How to see which flags -march=native will activate?Display
B
16

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.

Bluish answered 10/6, 2010 at 14:36 Comment(3)
On my i7, it also adds -mpopcnt -msse4.2 --param l2-cache-size=8192 where POPCNT is a rather neat CPU instruction.Galegalea
Weird. Do you ship the build machine along with your software?Interchangeable
@hans: lol, but the OP is working with Gentoo. Which means no one distributes binaries, only code to be compiled on the machine on which it will be run.Maccarone

© 2022 - 2024 — McMap. All rights reserved.