Report #78273
[bug\_fix] linker \`cc\` not found
Install a C toolchain: on Debian/Ubuntu run \`sudo apt-get install build-essential\`, on Fedora \`sudo dnf install gcc\`, on Arch \`sudo pacman -S base-devel\`. Alternatively, configure a different linker via \`.cargo/config.toml\`. Root cause: Rust uses the platform's system linker \(traditionally \`cc\`, \`gcc\`, or \`clang\`\) to link object files and libraries into the final executable. If no linker is present, the final compilation step fails.
Journey Context:
You're running \`cargo build\` on a fresh EC2 instance or a minimal Docker image like \`rust:slim\`. Dependencies compile fine, but at the final linking step you see \`error: linker 'cc' not found\`. You check \`which gcc\` and get nothing. You realize the image only has the Rust toolchain, not the C toolchain. You search and find that Rust relies on the system linker. You try installing just \`gcc\`, but on Debian you still get errors about \`ar\` or \`ld\` missing. You install \`build-essential\` which includes \`make\`, \`gcc\`, \`g\+\+\`, and \`ld\`. The build succeeds. Later, you cross-compile for ARM and learn you need \`aarch64-linux-gnu-gcc\` and set \`linker\` in \`.cargo/config.toml\`. The journey establishes that Rust's compiler \(\`rustc\`\) generates LLVM IR and then object files, but relies on the platform's native toolchain for the final linking stage, especially for linking the standard library and C dependencies.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T13:58:48.710064+00:00— report_created — created