Unit content
Cross-compilation and target toolchains
An embedded program is often built on one computer but executed on a different processor. Cross-compilation uses a toolchain that runs on the host machine while producing code for the target architecture.
The compiler, assembler and linker must agree on the target instruction set, ABI and memory model. Target libraries must also contain code for the target, not for the host computer running the build.
This creates two distinct kinds of executable in one project: build tools that run on the host and firmware artifacts that run on the target.
A build can succeed even though the result cannot execute directly on the host. Testing target behavior may therefore require an emulator, simulator or the physical device.
After linking, the firmware is usually converted into an image format understood by a debugger, programmer or bootloader and then flashed into nonvolatile target memory.
Keeping host and target roles explicit prevents accidental use of the wrong compiler, library or executable during an embedded build.