Polyglot: Concepts
    Overview
    Concepts
    Compile Time and Runtime
    Standard Libraries
    Build Tools
    Numerics
    Memory Management
    Zero Cost Abstractions
    Design Patterns
    Compatibility
    Functional Programming
    Bit Manipulation
    Generics
    String Interning
Polyglot: Language Notes

Standard Libraries

Updated: 2022-10-13

C Standard Libraries

  • glibc: GNU's implementation of C Standard Library.
  • musl a lightweight implementation, used by Alpine Linux;
  • Bionic: developed by Google for its Android operating system, designed for devices with less memory and processor power than a typical Linux system (Three-clause BSD)
  • llvm-libc: static linking friendly.

glibc

Main shared object: libc.so.6.

In the glibc 2.34, most components that used to be in separate shared objects were intesgraded into the main libc object, libc.so.6:

  • libpthread: the threading library.
  • libdl: the application interface for the dynamic linker
  • libutil
  • libanl

glibc follows the pioneering work of the musl C library, which provides absolutely everything (including the dynamic linker) in a single shared object.

glibc's license is not static linking friendly.

Check glibc version:

$ ldd --version 

musl

musl is an implementation of the C standard library built on top of the Linux system call API, including interfaces defined in the base language standard, POSIX, and widely agreed-upon extensions. musl is lightweight, fast, simple, free, and strives to be correct in the sense of standards-conformance and safety.

musl shows, it is theoretically possible to provide the entire C library through the dynamic linker.

LLVM-libc

https://github.com/llvm/llvm-project/tree/main/libc

Static linking friendly (the executable does not depend on any dynamically loaded shared library). Compiler driven security mitigations can be quickly applied to the entire executable by just rebuilding the application.

Comparing to glibc and musl:

  • statically linking glibc has license implications.
  • glibc and musl are sanitizer unfriendly: they cannot be built with sanitizers enabled.

klibc

klibc is a minimalistic subset of the standard C library, developed mainly to be used during the Linux startup process.