C Library
▶ The C library is an essential component of a Linux system ▶ Interface between the applications and the kernel ▶ Provides the well-known standard C API to ease application development ▶ Several C libraries are available: glibc, uClibc, musl, dietlibc, newlib, etc. ▶ The choice of the C library must be made at the time of the cross-compiling toolchain generation, as the GCC compiler is compiled against a specific C library.
glibc
▶ License: LGPL ▶ C library from the GNU project ▶ Designed for performance, standards compliance and portability ▶ Found on all GNU / Linux host systems ▶ Of course, actively maintained ▶ By default, quite big for small embedded systems: approx 2.5 MB on ARM (version 2.9 - libc: 1.5 MB, libm: 750 KB) ▶ But some features not needed in embedded systems can be configured out (merged from the old eglibc project). ▶ http://www.gnu.org/software/libc/
uClibc-ng
▶ http://uclibc-ng.org/ ▶ A continuation of the old uClibc project ▶ License: LGPL ▶ Lightweight C library for small embedded systems
- High configurability: many features can be enabled or disabled through a menuconfig interface
- Supports most embedded architectures
- Supports no-MMU architectures (ARM Cortex-M, Blackfin, etc.)
- No guaranteed binary compatibility. May need to recompile applications when the library configuration changes.
- Focus on size rather than performance
- Small compile time ▶ Most of the applications compile with uClibc-ng. This applies to all applications used in embedded systems. ▶ Size (arm): 3.5 times smaller than glibc!
- uClibc-ng 1.0.14: approx. 716kB (libuClibc: 282kB, libm:73kB)
- glibc 2.22: approx 2.5 MB ▶ Some features not available or limited: priority-inheritance mutexes, fixed Name Service Switch functionality, etc. ▶ Used on a large number of production embedded products, including consumer electronic devices
▶ Executable size comparison on ARM, tested with glibc 2.22 and uClibc-ng 1.0.14 ▶ Plain ``hello world'' program (stripped): helloworld static dynamic uClibc 33.4kB 2.5kB uClibc with Thumb-2 25.4kB 2.5kB eglibc with Thumb-2 479kB 2.7kB ▶ Busybox (stripped): busybox static dynamic uClibc 818kB 664kB uClibc with Thumb-2 602kB 504kB eglibc with Thumb-2 1206kB 503kB
musl C Library
http://www.musl-libc.org/ ▶ A lightweight, fast and simple library for embedded systems ▶ Created while uClibc's development was stalled ▶ In particular, great at making small static executables ▶ Permissive license (MIT) ▶ Compare features with other C libraries: http://www.etalabs.net/compare_libcs.html ▶ Supported by build systems such as Buildroot
Other smaller C libraries
▶ Dietlibc, http://fefe.de/dietlibc/. Approximately 70 KB. ▶ Newlib, http://sourceware.org/newlib/ ▶ Klibc, http://www.kernel.org/pub/linux/libs/klibc/,designed for use in an initramfs or initrd at boot time.