binaryfiles - how does gcc compiler produces machine/processor independent binary? -
my question bit dummy, had question in mind.
how gcc @ compile time determines target machine/processor getting build-ed ?
are instructions generated gcc/g++ target system independent ?
for example have x86_64 machine intel based , amd based , motorola based system etc...
do processors have same instruction set , opcode associated ?
if not machine-code/binary generated gcc have kind of runtime check ?
thanks in advance answer.
this bit complicated. depends on how gcc configured , compiled during installation. on ubuntu 16.04 x64 system there gcc installation.
if in terminal type gcc -v
, i'll --target=x86_64-linux-gnu
, means gcc produce code x64 linux. --host=x86_64-linux-gnu
means gcc x64 linux application. more of @ link.
another useful output @ --with-multilib-list=m32,m64,mx32
- means compile default 64bit application 2 types of 32bit applications (-m32 , -mx32).
last not least --with-tune=generic
, means apps compiled generic x64 platform , user should able run them anywhere on x64 linux box.
there 2 options override - -march
, -mtune
. arch option tell compiler use intruction specific given cpu. tune tune code generation fit best given cpu. cpu either specific platform (like, say, sandybridge), generic platform (usually default) or native
, gcc during compilation check host cpu , perform code generation/tuning it.
last set of option covers setting fpu - select unit use (x87 or sse2+), instruction set (sse2, 3, 4, avx) etc. more link.
Comments
Post a Comment