I was just trying to understand something about cross compilers which made me ask this question.
gcc
is a cross-compiler.
By default what it the target architecture for gcc
compilation if none is specified is the native target on which I am compiling the source. Correct ?
If the above is correct then how does it manage to generate the code for several different architectures even when it is explicitly specified ?
Shouldn't it have to know all the ISA's ? How is this managed ? Do they have all the information for all the existing ISA's ?
A given (particular) gcc
is built for a particular given target. Use gcc -v
to find out which.
Often, cross-compilers are installed as different commands, e.g. avr-gcc
on Debian for the Atmel AVR processor (with specific options ...)
On some architectures and systems (typically x86 & Linux) you may compile for a different variant. See this. In particular you may want to use -mtune=native
or -march=haswell
or -m32
...
If you build gcc
yourself from its source tarball, you'll give it at configure time specific configure options (e.g. --program-suffix=-avr
and --target=avr
for the avr-gcc
etc....)