Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 14:35, 26 October 2024 by Atmois (talk | contribs) (Atmois moved page Musl libc to Musl: Misspelled title: musl)

musl

musl

musl ldd command output.
Release Status Maintained
Last Release 1.2.5 (2024-02-29, commit[2])
Language(s) C
Developer(s) Rich Felker (dalias) and others
Website musl.libc.org

musl is a C standard library intended for operating systems based on the Linux kernel, released under the MIT License. It was developed by Rich Felker to write a clean, efficient, and standards-conformant libc implementation.

Usage on Operating Systems

Linux distributions which use musl as their standard C library (some use only musl) include but are not limited to:

The seL4 microkernel ships with musl, for binaries that have been linked against glibc, gcompat, glibmus-hq. can be used to execute them on musl-based distros.

Comparisons between different C library implementations.

Bloat comparison musl uClibc dietlibc glibc
Complete .a set 426k 500k 120k 2.0M †
Complete .so set 527k 560k 185k 7.9M †
Smallest static C program 1.8k 5k 0.2k 662k
Static hello (using printf) 13k 70k 6k 662k
Dynamic overhead (min. dirty) 20k 40k 40k 48k
Static overhead (min. dirty) 8k 12k 8k 28k
Static stdio overhead (min. dirty) 8k 24k 16k 36k
Configurable featureset no yes minimal minimal
Behavior on resource exhaustion musl uClibc dietlibc glibc
Thread-local storage reports failure aborts n/a aborts
SIGEV_THREAD timers no failure n/a n/a lost overruns
pthread_cancel no failure aborts n/a aborts
regcomp and regexec reports failure crashes reports failure crashes
fnmatch no failure unknown no failure reports failure
printf family no failure no failure no failure reports failure
strtol family no failure no failure no failure no failure
Performance comparison musl uClibc dietlibc glibc
Tiny allocation & free 0.005 0.004 0.013 0.002
Big allocation & free 0.027 0.018 0.023 0.016
Allocation contention, local 0.048 0.134 0.393 0.041
Allocation contention, shared 0.050 0.132 0.394 0.062
Zero-fill (memset) 0.023 0.048 0.055 0.012
String length (strlen) 0.081 0.098 0.161 0.048
Byte search (strchr) 0.142 0.243 0.198 0.028
Substring (strstr) 0.057 1.273 1.030 0.088
Thread creation/joining 0.248 0.126 45.761 0.142
Mutex lock/unlock 0.042 0.055 0.785 0.046
UTF-8 decode buffered 0.073 0.140 0.257 0.351
UTF-8 decode byte-by-byte 0.153 0.395 0.236 0.563
Stdio putc/getc 0.270 0.808 7.791 0.497
Stdio putc/getc unlocked 0.200 0.282 0.269 0.144
Regex compile 0.058 0.041 0.014 0.039
Regex search (a{25}b) 0.188 0.188 0.967 0.137
Self-exec (static linked) 234µs 245µs 272µs 457µs
Self-exec (dynamic linked) 446µs 590µs 675µs 864µs
ABI and versioning comparison musl uClibc dietlibc glibc
Stable ABI yes no unofficially yes
LSB-compatible ABI incomplete no no yes
Backwards compatibility yes no unofficially yes
Forwards compatibility yes no unofficially no
Atomic upgrades yes no no no
Symbol versioning no no no yes
Algorithms comparison musl uClibc dietlibc glibc
Substring search (strstr) twoway naive naive twoway
Regular expressions dfa dfa backtracking dfa
Sorting (qsort) smoothsort shellsort naive quicksort introsort
Allocator (malloc) musl-native dlmalloc diet-native ptmalloc
Features comparison musl uClibc dietlibc glibc
Conformant printf yes yes no yes
Exact floating point printing yes no no yes
C99 math library yes partial no yes
C11 threads API yes no no no
C11 thread-local storage yes yes no yes
GCC libstdc++ compatibility yes yes no yes
POSIX threads yes yes, on most archs broken yes
POSIX process scheduling stub incorrect no incorrect
POSIX thread priority scheduling yes yes no yes
POSIX localedef no no no yes
Wide character interfaces yes yes minimal yes
Legacy 8-bit codepages no yes minimal slow, via gconv
Legacy CJK encodings no no no slow, via gconv
UTF-8 multibyte native; 100% conformant native; nonconformant dangerously nonconformant slow, via gconv; nonconformant
Iconv character conversions most major encodings mainly UTFs no the kitchen sink
Iconv transliteration extension no no no yes
Openwall-style TCB shadow yes no no no
Sun RPC, NIS no yes yes yes
Zoneinfo (advanced timezones) yes no yes yes
Gmon profiling no no yes yes
Debugging features no no no yes
Various Linux extensions yes yes partial yes
Target architectures comparison musl uClibc dietlibc glibc
i386 yes yes yes yes
x86_64 yes yes yes yes
x86_64 x32 ABI (ILP32) experimental no no non-conforming
ARM yes yes yes yes
Aarch64 (64-bit ARM) yes no no yes
MIPS yes yes yes yes
SuperH yes yes no yes
Microblaze yes partial no yes
PowerPC (32- and 64-bit) yes yes yes yes
Sparc no yes yes yes
Alpha no yes yes yes
S/390 (32-bit) no no yes yes
S/390x (64-bit) yes no yes yes
OpenRISC 1000 (or1k) yes no no not upstream
Motorola 680x0 (m68k) yes yes no yes
MMU-less microcontrollers yes, elf/fdpic yes, bflt no no
Build environment comparison musl uClibc dietlibc glibc
Legacy-code-friendly headers partial yes no yes
Lightweight headers yes no yes no
Usable without native toolchain yes no yes no
Respect for C namespace yes LFS64 problems no LFS64 problems
Respect for POSIX namespace yes LFS64 problems no LFS64 problems
Security/hardening comparison musl uClibc dietlibc glibc
Attention to corner cases yes yes no too much malloc
Safe UTF-8 decoder yes yes no yes
Avoids superlinear big-O's yes sometimes no yes
Stack smashing protection yes yes no yes
Heap corruption detection yes no no yes
Misc. comparisons musl uClibc dietlibc glibc
License MIT LGPL 2.1 GPL 2 LGPL 2.1+ w/exceptions

Official benchmarks [1]

See also

Notes