Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

161.11. libstdcxx-arm-none-eabi-16.2.0

The C++ standard library for arm-none-eabi, built against picolibc

Version 16.2.0, release 1
Shelf embedded — Microcontroller and bare-metal development: cross toolchains, C libraries, flashers, debug probes and serial consoles
Phase 41_system (System), 469 of 1047 in build order
Licence GPL-3.0-or-later WITH GCC-exception-3.1
Homepage https://gcc.gnu.org/
Build time 52.7 SBU
Installed size 209.6 MiB in 1624 files
Recipe ports/core/embedded/libstdcxx-arm-none-eabi/kpkgbuild

About

The C++ standard library for bare-metal ARM: libstdc++.a, libsupc++.a and libstdc++exp.a for every multilib of gcc-arm-none-eabi, and the headers under /usr/arm-none-eabi/include/c++, built against picolibc. With it arm-none-eabi-g++ can compile and link C++ firmware for the Cortex-M and Cortex-R parts of its rmprofile multilib set, and picotool, whose RP2350 helper programs are pico-sdk projects that enable C++, depends on it. It is the second build of the cross compiler’s gcc source: libstdc++ compiles against the target C library, and picolibc is built with that compiler, so the compiler, the C library and this library are three recipes. How the split works is in A second build of the same source.

Why it is in KDOS

The comment above the 4 ports from binutils-arm-none-eabi to libstdcxx-arm-none-eabi in script/phases/41_system/packages.d/embedded.txt:

THE ORDER IS THE DEPENDENCY. binutils first, then a gcc built --without-headers so libgcc can exist before a libc does, then the libc built WITH that gcc. One recipe cannot do the last two: the compiler has to be installed before the library it compiles can configure against it.

Cortex-M and Cortex-R. --with-multilib-list=rmprofile is what keeps this to the profiles a microcontroller actually is, rather than every ARM variant since 1985.

Sources

Dependencies

Depends on: gcc-arm-none-eabi, binutils-arm-none-eabi, picolibc-arm-none-eabi, gmp, mpfr, mpc, zlib, zstd.

Required by (1): picotool.

Patches

build.sh applies these; kpkg applies nothing by itself.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install libstdcxx-arm-none-eabi'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/embedded/libstdcxx-arm-none-eabi.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/embedded/libstdcxx-arm-none-eabi
echo 'e6738e29597f733270731aa90600f37ffdc045079dfc27ec7e8192cc81085c3e  gcc-arm-none-eabi-16.2.0.tar.xz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/libstdcxx-arm-none-eabi
SRC=$SRC_ROOT/libstdcxx-arm-none-eabi-16.2.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf gcc-arm-none-eabi-16.2.0.tar.xz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers _up, group and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

patch -p1 -i "$PORT_SRC/picolibc-long-double-math.patch"
mkdir -p build && cd build
../configure \
	--target=arm-none-eabi \
	--prefix=/usr \
	--libexecdir=/usr/lib \
	--with-sysroot=/usr/arm-none-eabi \
	--with-native-system-header-dir=/include \
	--enable-languages=c,c++ \
	--with-picolibc \
	--without-newlib \
	--with-headers=no \
	--disable-nls \
	--disable-shared \
	--disable-threads \
	--disable-libssp \
	--disable-libgomp \
	--disable-libquadmath \
	--disable-libatomic \
	--disable-libstdcxx-pch \
	--disable-libstdcxx-verbose \
	--enable-hosted-libstdcxx \
	--disable-decimal-float \
	--with-gnu-as --with-gnu-ld \
	--with-zstd=/usr \
	--without-isl \
	--enable-multilib \
	--with-multilib-list=rmprofile \
	--with-pkgversion="KDOS" \
	CFLAGS_FOR_TARGET="-Os -pipe -ffunction-sections -fdata-sections" \
	CXXFLAGS_FOR_TARGET="-Os -pipe -ffunction-sections -fdata-sections"
make all-target-libstdc++-v3 2>&1 | tee ../libstdcxx-build.log
test "${PIPESTATUS[0]}" -eq 0
if grep -F 'stamp-modules-bits] Error' ../libstdcxx-build.log; then
	exit 1
fi
make -C arm-none-eabi/libstdc++-v3 DESTDIR=$PKG install
find "$PKG" \( -name '*.la' -o -name '*-gdb.py' \) -delete
rm -rf "$PKG/usr/share"

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/libstdcxx-arm-none-eabi, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf libstdcxx-arm-none-eabi-16.2.0-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/libstdcxx-arm-none-eabi, and runs the triggers its paths call for.

Contents

Installed directories: /usr/arm-none-eabi/include/c++, /usr/share/licenses/libstdcxx-arm-none-eabi.

Notes