How does a compiler know the machine language of targeted processor to which the source code has to be converted

assemblyccompiler

For ex: Two machines have the same compiler and the same operating system. But the two machines have different processors (different assembly instructions).As the compiler was downloaded with respect to the operating system, how does the source code get converted to machine language of each processor?

Best Answer

Essentially, through configuration options.

A compiler that understands multiple back-ends will usually assume that source code should be compiled to the platform (os + processor type) on which the compiler itself is running. Everything else would be cross-compiling, and would have to be specified via command-line switches or configuration files.