Why a Custom Toolchain?
- Reproducibility: The same toolchain version is used regardless of what is installed on the build host.
- Correct sysroot: The toolchain is built against the same C library (musl or glibc) that will run on the target device.
- Embedded-specific tuning: Optimization flags, ABI choices, and floating-point handling are set for the target CPU.
- Controlled GCC version: Security and optimization features (PIE, SSP, LTO) are configured consistently.
Toolchain Components
binutils
GNU assembler (
as), linker (ld), and binary utilities (objcopy, strip, nm, etc.) for the target architecture.GCC
GNU C/C++ compiler. Versions 12, 13, 14 (default), and 15 are supported. Built in three stages: minimal, initial, and final.
musl libc
The default C library for OpenWrt targets. Lightweight, standards-compliant, and suitable for embedded systems.
glibc (optional)
The GNU C Library. Available as an alternative to musl via
menuconfig. Larger, but offers broader binary compatibility.Kernel Headers
Linux kernel UAPI headers that define the system call interface between userspace and the kernel.
Host Tools
Build-time utilities compiled for the host machine:
mkimage, mksquashfs, e2fsck, pkg-config, and more.Toolchain Source Layout
Building the Toolchain
make invocation that needs it.
Toolchain Output Location
After a successful build, the toolchain is installed into the staging directory:Host Tools
Build-time tools that run on the host (not the target) are installed in:tools/ directory in the OpenWrt tree and are prerequisites for the target build.
Selecting the C Library
The default C library is musl. To switch to glibc:External Toolchain
If you have a pre-existing cross-toolchain (e.g., from a vendor SDK), you can point OpenWrt to it:toolchain/Config.in and scripts/ext-toolchain.sh for details.