Report #79702
[bug\_fix] linker \`cc\` not found \(or \`link.exe\` on Windows\)
The Rust compiler \(rustc\) invokes a system linker \(\`cc\` on Unix-like systems, typically GCC or Clang; \`link.exe\` on Windows\) to combine compiled crate object files into the final executable. If the linker executable is not found in \`PATH\`, the build fails at the final stage. The root cause is a missing system toolchain installation; Rust does not bundle a linker to keep the toolchain size small and to integrate with platform C libraries. The fix is to install the C compiler/linker package: on Debian/Ubuntu \`sudo apt-get install build-essential\`, on Fedora \`sudo dnf install gcc\`, on Arch \`sudo pacman -S base-devel\`, on macOS install Xcode Command Line Tools \(\`xcode-select --install\`\), on Windows ensure Visual Studio Build Tools with "C\+\+ build tools" workload are installed or use the GNU toolchain via mingw-w64.
Journey Context:
You spin up a fresh Ubuntu 22.04 Docker container to build your Rust microservice. You install Rust via rustup \(\`curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \| sh\`\), clone your repo, and run \`cargo build --release\`. After compiling all dependencies successfully, the build halts with "error: linker \`cc\` not found". You check \`which cc\` and get nothing. You realize that Rust produces LLVM IR but relies on the platform's system linker \(part of GCC/Clang\) to produce the final ELF binary, unlike Go which has its own linker. You search the error and find GitHub issues explaining that \`build-essential\` \(on Debian\) or \`base-devel\` \(on Arch\) is required because Rust delegates the final linking step to the system toolchain to maintain ABI compatibility with C libraries. You run \`apt-get update && apt-get install build-essential\`, which installs \`gcc\`, \`g\+\+\`, and \`ld\`. You rebuild and the linking stage succeeds, producing the release binary. You now understand that Rust's dependency on the system linker is a deliberate architectural choice to avoid shipping a platform-specific linker and to seamlessly link against native system libraries like \`libc\` and \`libssl\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:22:38.849786+00:00— report_created — created