Keith Packard is known for his X.Org/X11 work over the course of many years but alongside other software projects he also maintains Picolibc as a C library designed for embedded 32-bit and 64-bit systems. Recently he sent out a patch for adding Picolibc support to the GCC compiler.
During some New Year hacking, Keith Packard worked up patches for adding support for Picolibc to serve as the C library for use with GCC.
“The first patch in this series selects picolibc as the default C library when the target is *-picolibc-*. This configures the default compiler specs for picolibc usage, including the addition of three picolic-specific options.
The section patch in this series allows the default C library to be explicitly selected, separately from the target name. This allows toolchains for targets like Zephyr to default to picolibc without needing to include ‘picolibc’ in the target name.”
The new options for the picolibc target include –oslib= for inserting an OS library after the C library, –crt0= for an alternative crt0 to use in place of the one provided by Picolibc, and –printf= for specifying a customized version of printf instead of the one linked from the C library.
Upstream Picolibc supports a variety of targets such as ARC, ARM, m68k, MIPS, MSP430, Nios II, POWER9, RISC-V, and others plus x86_64 and i386 that are primarily for testing purposes.
The Picolibc support patches have yet to be merged to upstream GCC, but as mentioned by the GNU Tools on X, they are in favor of libc diversity. In addition to the GNU C Library (glibc), upstream GCC also supports other libc implementations like Bionic, uClibc, and musl.