Debugging & Toolchain · Interview question

What is cross-compilation and how do you know a toolchain is for cross-compiling?

A strong answer

Cross-compilation is building code on one machine (the host, your x86 or ARM laptop) that runs on a different architecture (the target, say a Cortex-M microcontroller). It's necessary because the target can't compile its own code (no OS, limited resources) and its instruction set differs from the host's, so the host toolchain must emit machine code for the target rather than for the host, and you then flash that image to the device since you can't run it on the host. You recognize a cross-toolchain by its prefix, a target triple like arm-none-eabi-gcc: arm is the target CPU family, none means no operating system (bare metal), and eabi is the embedded application binary interface; contrast arm-linux-gnueabihf which targets ARM with Linux. Every tool carries the prefix, arm-none-eabi-gcc, -ld, -objcopy, -gdb, -size. The classic mistake is invoking the plain host gcc to build firmware, which produces x86 code that simply won't run on the MCU; you must use the prefixed cross-toolchain and target flags (-mcpu=cortex-m4 -mthumb, etc.).

What a weak answer sounds like

You know the answer. Do you know what gets you dinged?

Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.

From the lesson

The Toolchain

The chain of programs that turns source into a flashable image (compiler, assembler, linker, loader), plus cross-compilation (arm-none-eabi-*) and objcopy from ELF to .bin/.hex.

More The Toolchain questions

Browse all 472 interview questions
What is cross-compilation and how do you know a toolchain is for cross-compiling? | EmbeddedPrep.io