Is there a way to get gcc to output the available -march=arch options? I'm getting build errors (tried -march=x86_64
) and I don't know what my options are.
The compiler I'm using is a proprietary wrapper around gcc that doesn't seem to like -march=skylake
. The flags should be the same so I assume whatever options I'd send to gcc to dump architectures would be the same for this wrapper.
I managed to cause gcc to error with a bogus parameter and it dumped a list, but I'm not seeing that now that I'm going through a wrapper.
How can I get gcc to tell me what it supports?
Use
gcc --target-help
It's often not the general architecture like
x86
orx86-64
but the specific microarchitectures. But there'sx86-64
(notx86_64
) for a generic x86 CPU with 64-bit extensions. The full list for each architecture can be found on GCC's-march
manual. For x86:While the baseline version of
-march
is-march=x86-64
, the baseline / default tune option is-mtune=generic
. That aims to not be terrible anywhere, avoiding performance pitfalls even at the cost of extra instructions or code size.-march=native
will pick the right arch and tune settings for the machine the compiler is running on, ortune=generic
if the compiler doesn't recognize the specific model of CPU it's running on.(e.g. old gcc on a Skylake, will still enable
-mavx2 -mpopcnt -mbmi2
and so on, but will set-mtune=generic
instead of something closer to appropriate.)