23

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.

Yun
  • 3,056
  • 6
  • 9
  • 28
BehemothTheCat
  • 305
  • 3
  • 7
  • possible duplicate of [Obtaining current GCC architecture](http://stackoverflow.com/questions/11727855/obtaining-current-gcc-architecture) – mlt May 30 '15 at 21:08

1 Answers1

33

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-

Community
  • 1
  • 1
nos
  • 223,662
  • 58
  • 417
  • 506
  • 1
    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? – BehemothTheCat Jan 05 '15 at 21:40
  • 1
    It should be the base x86-64 instruction set, common to all x86-64 CPUs. – nos Jan 05 '15 at 22:40
  • 2
    ... which is something the documetation says doesn't exist :-P – BehemothTheCat Jan 06 '15 at 00:10
  • 3
    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. – nos Jan 06 '15 at 08:19
  • 1
    For anyone who cares, the x86-64 option was added to the documentation https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html – Tarick Welling Oct 19 '22 at 14:15