Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the compiler know about the instruction set of my CPU? [closed]

I've read that

The compiler converts code written in a human-readable programming language into a machine code representation which is understood by your processor.

How does the compiler know about the instruction set of my CPU?

Any reference to understand job of assembler, linker and loader would be helpful.

like image 799
OnlyQuestions Avatar asked Dec 21 '22 02:12

OnlyQuestions


1 Answers

How does the compiler know about the instruction set of my CPU?

Most compilers only know how emit code for a specific CPU (or a small number of them). Each target CPU requires that someone write a compiler back-end for it, and that task is non-trivial.

GCC supports a large variety of targets, but even GCC is built to emit code for only a few targets. In other words, you can build GCC to emit code for x86_64 and i*86 processors, and you can build another copy to emit code for PowerPC, but you can't build a single GCC that will produce code for all three.

Any reference to understand job of assembler, linker and loader

Google search for above terms led me here.

like image 161
Employed Russian Avatar answered Dec 24 '22 00:12

Employed Russian