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?

  • 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 '17 at 21:54
  • It doesn't. You can't even run the compiler on one of those processors. – user253751 Nov 20 '18 at 2:55
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.

|improve this answer|||||
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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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