|
cpp-toolchain documentation
Up-to-date C++ toolchain images for the complete development cycle - GNU and LLVM side by side
|
Two different things, both available from the build stage onwards:
Cross-arch is opt-in: the default (lean) images ship no cross toolchain. You get it either by pulling a -cross image or by building any stage with --build-arg BINUTILS_TARGETS='<triplets>'.
For each requested target, binutils.sh installs a complete cross toolchain via g++-<triplet> - which pulls cross binutils (as / ld / objdump / ...), cross glibc, cross libgcc and cross libstdc++.
That is enough to compile and link C and C++ for the target, and Clang auto-detects the cross-GCC install, so clang --target=<triplet> works with no extra flags.
The -cross images carry the live non-x86 ecosystems - ARM 64-bit (servers/embedded), ARM 32-bit (embedded) and RISC-V:
| Target triplet | Package installed | Pulls (cross) |
|---|---|---|
| aarch64-linux-gnu | g++-aarch64-linux-gnu | binutils · glibc · libgcc · libstdc++ |
| arm-linux-gnueabihf | g++-arm-linux-gnueabihf | binutils · glibc · libgcc · libstdc++ |
| riscv64-linux-gnu | g++-riscv64-linux-gnu | binutils · glibc · libgcc · libstdc++ |
common resolves to those three plus x86-64-linux-gnu, the host triplet, so a -cross image also carries g++-x86-64-linux-gnu. binutils.sh is where that list lives.
A custom build can name any triplet from binutils.sh --list-available --targets=all, or common for the published set - CPU, FPU, ABI and endianness are selected by the triplet itself, there is no separate switch.
See scripts/install/README.md for the axes, the full option reference, and the 7 triplets (out of 32) that have no cross-g++ and fall back to bare binutils.
Assuming the target has a cross-g++ (the published targets do):
| Capability | Status |
|---|---|
| Cross-compile + link C | ✅ |
| Cross-compile + link C++ (libstdc++) | ✅ |
| clang --target=<triplet> (C and C++, libstdc++) | ✅ auto-detects the cross-GCC install |
| Inspect / strip target objects (objdump / strip) | ✅ |
| Cross-compile C++ with libc++ | ❌ target libc++ not bundled - see below |
libc++ for the target (the GCC-free path) is not bundled - it has no portable apt cross package and requires an LLVM runtimes source build, tracked as a future scripts/libcxx.sh.
This affects the cross case only: the host libc++ is installed, so native clang++ -stdlib=libc++ works.
Distinct from cross-compilation: multilib is the same GCC emitting a secondary ABI of the host architecture, via gcc-<N>-multilib / g++-<N>-multilib (which pull libc6-dev-i386, libc6-dev-x32, lib32stdc++-<N>-dev, ...).
Installed by default, best-effort: multilib lags for brand-new GCC versions and does not exist on non-amd64 hosts, so an unavailable package is skipped with a log rather than failing the build. gcc.sh exposes --multilib (default on) and -m / --minimalistic (compilers only); an explicit --multilib=yes is honored strictly and fails hard if unavailable.