What is the default for gcc -march option?
Asked Answered
H

1

24

The gcc info file says in the section on x86-64 specific flags, among other things:

There is no `-march=generic' option because `-march'
indicates the instruction set the compiler can use, and there
is no generic instruction set applicable to all processors.
In contrast, `-mtune' indicates the processor (or, in this
case, collection of processors) for which the code is
optimized.

My question then is, what instruction (sub-)set does gcc compile for when no -march option is given? There is a lot of related information about -march and -mtune in the webosphere, but none that I could find which answers this simple question. It can't be march=native, or else it would be impossible to compile generic distribution kernels and binary packages.

Henrik answered 5/1, 2015 at 20:0 Comment(1)
possible duplicate of Obtaining current GCC architectureJobi
E
35

The default flags for gcc can be set when gcc itself is compiled. Run:

  gcc -Q --help=target 

to see what the default is on your machine. Likely it'll just be x86-64 even though the man page doesn't document that as a value for -march-

Endowment answered 5/1, 2015 at 20:58 Comment(5)
Ok, the output contains march=x86-64. But since it is undocumented as you noted, this really only shifts the question: what does it really mean in terms of the instructions?Henrik
It should be the base x86-64 instruction set, common to all x86-64 CPUs.Endowment
... which is something the documetation says doesn't exist :-PHenrik
From what I can tell, the documenation says that in the context of 386 and x86-64 CPUs, which is true, there's no common instruction sets among those. But for x86-64 CPUs, there is.Endowment
For anyone who cares, the x86-64 option was added to the documentation gcc.gnu.org/onlinedocs/gcc/x86-Options.htmlFriesian

© 2022 - 2024 — McMap. All rights reserved.