Skip to main content
OpenWrt uses musl libc as its default C standard library for all cross-compiled target binaries. musl is a modern, lightweight implementation of the C standard library designed for Linux-based systems.

Why musl?

musl was chosen over glibc as the default for several reasons:
Propertymuslglibc
Binary sizeVery small (~600 KB)Large (several MB)
Static linkingExcellent supportProblematic with some features
SecurityClean, auditable codebaseLarger attack surface
Standards complianceStrict POSIX complianceExtensions and GNU-isms
Startup overheadLowHigher (dynamic linker is heavier)
LocalesMinimal built-inExtensive (larger footprint)
For embedded routers with 8–64 MB of flash storage, musl’s smaller footprint is a significant practical advantage.

musl Source Location

toolchain/musl/
  Makefile        # Build recipe
  Config.in       # Kconfig options
  common.mk       # Shared build logic
  patches/        # musl-specific patches
  include/        # Additional headers (fortify)

musl Configuration

The only musl-specific menuconfig option is:
Config symbol: MUSL_DISABLE_CRYPT_SIZE_HACK
Prompt: Include crypt() support for SHA256, SHA512 and Blowfish ciphers
Default: y
Disabling this option removes ~14 KB (LZMA-compressed) of crypt support. The stubs return ENOSYS for SHA-256/SHA-512/Blowfish hashes.

Switching to glibc

To use glibc instead of musl:
make menuconfig
# Navigate to:
# Advanced configuration options (for developers)
#   -> Toolchain Options
#     -> C Library implementation
#       -> Use glibc
Switching the C library invalidates all compiled packages and toolchain artifacts. Always run make clean before rebuilding with a different libc.

Binary Compatibility

Binaries compiled against musl are not compatible with systems using glibc, and vice versa. This means:
  • Precompiled binaries from a Debian/Ubuntu host will generally not run on an OpenWrt device (which uses musl)
  • OpenWrt packages from a musl build will not run on a system using glibc
  • Static binaries (linked with -static) are the exception: they embed the libc and are self-contained
If you need to run third-party glibc-linked binaries on OpenWrt, musl-libc includes a compatibility shim. However, full glibc compatibility is not guaranteed.

Fortify Headers

OpenWrt’s musl build includes fortification headers from toolchain/fortify-headers/. These provide compile-time and runtime buffer overflow detection for common C functions (memcpy, strcpy, etc.) when the target includes musl. Fortification is enabled when:
#define _FORTIFY_SOURCE 2
This is injected via the toolchain include path (TOOLCHAIN_INC_DIRS includes .../include/fortify when CONFIG_USE_MUSL=y).

C++ Support

For C++ applications on constrained targets, OpenWrt provides:
  • libstdc++: The standard GCC C++ library. Pulled in as a dependency when any C++ package is installed.
  • uClibc++: A minimal C++ library (uclibc++ package) for extremely size-constrained applications. Does not support the full C++11/14/17 feature set but produces much smaller binaries.
The uClibc++ package is available in package/libs/uclibc++ and is used by packages that explicitly select it via DEPENDS:=+uclibc++.