Compilers

Which describes a cross compiler?

  1. AA compiler that blends two programming languages into a single new language
  2. BA compiler producing code for a different CPU than its host
  3. CA tool that compares the output of several compilers and picks the fastest
Show answer and explanation

Answer: B. A compiler producing code for a different CPU than its host

A cross compiler runs on, say, an x86 PC while generating machine code for an Arm or RISC-V microcontroller. It is essential when the target device, such as an embedded system, lacks the performance or memory to run a compiler itself. The generated code is checked by flashing it to the target or running it in an emulator of that device. It neither blends languages nor compares compilers.

  • A. It does not blend languages.
  • B. Correct. It generates code for a different kind of CPU.
  • C. It is not a tool for comparing results.
Practice this topic Back to topic

More Compilers questions

  1. When debugging a program compiled with optimization, some variables may show as "unavailable." What is the main reason?
  2. After thoroughly applying constant propagation, constant folding and dead-code elimination to the function above, what does it return and what code remains?
  3. What is the role of lexical analysis in a compiler?
  4. What is done during syntax analysis (parsing) in a compiler?
  5. Which is the best example of an error found during semantic analysis?