5

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?

2
  • 1
    I disagree with the dupe vote - they are not the same question. And the question is perfectly clear, even if a bit basic.
    – user22815
    Jan 26, 2017 at 21:54
  • It doesn't. You can't even run the compiler on one of those processors.
    – user253751
    Nov 20, 2018 at 2:55

2 Answers 2

13

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.

3

You use different compilers.

The GCC compiler for ARM is different from the GCC compiled for x86. They may share the same source but once they're compiled they become two different programs, different compilers.

You have different steps,

For example you're working on an x86, you can compile your compiler to run on x86, but you can also compile it to run on ARM.

And once you have your compiler running on ARM you can run it to output ARM-programs, but also to output x86-programs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.