When a compiler runs on one machine and produces code for a different machine,…

2009

When a compiler runs on one machine and produces code for a different machine, this is called:

Answer: A. Cross compilationConceptA compiler is classified by the relationship between the machine it runs on (the host) and the machine its generated code is meant to run on (the…

  1. A.

    Cross compilation

  2. B.

    One pass compilation

  3. C.

    Two pass compilation

  4. D.

    None of the above

Attempted by 257 students.

Show answer & explanation

Correct answer: A

Concept

A compiler is classified by the relationship between the machine it runs on (the host) and the machine its generated code is meant to run on (the target). When host and target are the same platform, the compiler is called a native compiler. When host and target differ — for example, compiling on an x86 desktop to produce code for an ARM microcontroller — the compiler is called a cross compiler, and the process is cross compilation.

Application

  1. The stem describes exactly this host/target split: "runs on one machine" (the host) and "produces code for a different machine" (the target).

  2. This host-vs-target distinction is precisely the definition of a cross compiler, so the compiling activity described is cross compilation.

  3. "One pass" and "two pass" instead classify a compiler by how many times it scans/traverses the source program during translation — a completely different axis (single-machine internal architecture) that says nothing about whether the host and target machines differ.

  4. Since cross compilation directly and uniquely matches the stem's description, "None of the above" does not apply.

Cross-check

Real-world toolchains confirm this: GCC and LLVM/Clang both document a "host" (machine running the compiler) and a "target" (machine the generated code runs on); when a single toolchain build sets these to different architectures, its documentation calls it a cross compiler. This matches option 0 and rules out the pass-count based distractors, which describe an unrelated property of the compiler.

Explore the full course: Mppsc Assistant Professor Computer Science Paper 2

Loading lesson…