musl
Prepare
Section titled “Prepare”- Depends on
mawk - Does not depend on
linux-headers - Removing
memcpy.sandmemmove.sforcesmuslto use theCimplementations
Configure
Section titled “Configure”exec_prefixis defined beforeprefixand should be explicitly specified aftermakeformusl-headers--syslibdir=/usr/libbreaks the ABI, we set it regardless as/lib/ld-musl-x86_64.so.1still gets hardcoded in the binaries “for the sake of being able to share binaries between systems” (check withreadelf -p .interp /bin/toybox)- The dynamic linker needs to reside at
../etcrelative tosyslibdir --enable-optimize=sizebuilds everything with-O2:
checking for optimization settings... minimize size--enable-optimizeand--enable-optimize=yesare identical and they only buildinternal/*,malloc/*andstring/*with-O3and the rest with-O2:
checking for optimization settings... customcomponents to be optimized for speed: internal malloc string--enable-optimize=*globs and builds everything with-O3(injects-O3overriding the initial-O2):
checking for optimization settings... customcomponents to be optimized for speed: *--enable-optimize=perf,--enable-optimize=performanceand--enable-optimize=speedglob nothing- Explicitly set
--enable-sharedand--disable-staticasconfiguresetsshared=autoandstatic=yesby default
- Do not build with
lto
Package
Section titled “Package”- Install
musl-headersafterlinux-headersto prevent collisions install-toolsis for the wrappermusl-gcc- The dynamic linker searches for shared libraries at run time under directories listed in
/etc/ld-musl-$ARCH.pathseparated by colons or newlines
DT_RELRsupport (-z pack-relative-relocs) has been upstreamed, and reduces size by 5 - 8%- If
LANGandLC_*are unset,setlocale(LC_ALL, "")defaults toC.UTF-8undermuslunlikedglibcwhich defaults toC - If
MUSL_LOCPATHis unset orsetuid/setgidare set, locale files are not loaded and only theClocale is available musldefines__STDC_ISO_10646__as201206Lsince1.1.15instdc-predef.hwhichgccincludes by default unlikeclangmusldoes not provide__gnuc_va_list; use__isoc_va_listinsteadmusldoes not provide legacyucontext_tfunctions likegetcontext,setcontext,makecontextandswapcontext(no longer POSIX)musldoes not providelibiconv,libintlandlibxcryptunlikeglibcmusldoes not providenssto avoiddlopen; use/etc/hostsand/etc/resolv.confinsteadmusldoes not providestrndupamusldoes not supportdnsfor non-ascii domains (idn)musldoes not support symbol versioning; use--disable-symversfor other packagesmusllackscdefs.h,error.h,queue.h,stab.handtree.h; patch software to remove these headersmuslprovides emptycrti.oandcrtn.ofor legacy.initand.finisupport; use.init_arrayand.fini_arrayinsteadmuslprovidessspvia__stack_chk_guardand__stack_chk_failandlibssp_nonshared.ais only required on 32-bit orpowerpcmuslprovidestimer_create()muslqueries nameservers in/etc/resolv.confin parallel (unlikeglibc) and accepts the first valid response and network load is mitigated by only supporting three nameserversMAXNS 3- caching nameserver on localhost (near-zero latency / smallest cache size / slowest for queries not from cache)
ispnameserver (low latency for cached results / moderate cache size / moderate performance for queries not from cache)8.8.8.8(higher latency / caches the whole DNS tree)
musldoes not build withgoldwithoutpie; glaucus useslldandllvm binary utilitiesinsteadmuslparses POSIX timezoneTZ="NFT-1DST,M3.5.0,M10.5.0"; however,tzdatais needed to parse geographical namesAsia/Damascusmuslrelies oncompiler-rt(orlibgcc) only for the__muldc3,__muldxc3,__mulsc3and__powidf2symbolsmusl’s default allocatormallocngwas inspired byopenbsd mallocandhardened_mallocand is good enoughmusl’s dynamic linker ignoresLD_PRELOADandLD_LIBRARY_PATHwhensetuid/setgidare setmuslsilently discards log messages if/dev/logis absentmusltreats all text asutf8and all non-ascii characters as first-class; no external locale files or conversion modules are needed- No need to remove
intl.h/libintl.hasgettext-tinydoesn’t provide them andlibintl.awhen configured withLIBINTL=NONE - Rich Felker advises against patching
configureto support--fast-mathas it breaks the ABI
References
Section titled “References”- https://blog.z3bra.org/2015/08/cross-compiling-with-pcc-and-musl.html
- https://brightrain.aerifal.cx/~niklata/PORTING
- https://codeberg.org/hoatzinx/musl-clang
- https://crux.nu/Wiki/MuslOverlay
- https://github.com/AppImage/type2-runtime/issues/116
- https://github.com/bell-sw/alpaquita-aports/blob/stream/core/musl-perf
- https://github.com/chimera-linux/cports/tree/master/main/musl
- https://github.com/jopamo/musl-bsd
- https://github.com/richfelker/musl-cross-make/blob/master/README.md
- https://github.com/richfelker/musl-cross-make/issues/101
- https://github.com/richfelker/musl-cross-make/issues/102
- https://gitlab.alpinelinux.org/alpine/tsc/-/issues/58
- https://git.musl-libc.org/cgit/musl/tree/INSTALL
- https://git.musl-libc.org/cgit/musl/tree/WHATSNEW
- https://maskray.me/blog/2021-11-07-init-ctors-init-array
- https://musl.libc.org/about.html
- https://musl.libc.org/manual.html
- https://musl.libc.org/releases.html
- https://openwall.com/lists/musl/
- https://rfc.archlinux.page/0023-pack-relative-relocs/
- https://wiki.debian.org/musl
- https://wiki.gentoo.org/wiki/Hardened/Toolchain
- https://wiki.gentoo.org/wiki/Musl
- https://wiki.gentoo.org/wiki/Musl_porting_notes
- https://wiki.gentoo.org/wiki/Musl_porting_notes/1.2.4
- https://wiki.gentoo.org/wiki/Project:Musl
- https://wiki.musl-libc.org/
- https://wiki.musl-libc.org/abi-cheat-sheet
- https://wiki.musl-libc.org/abi-manuals
- https://wiki.musl-libc.org/alternatives
- https://wiki.musl-libc.org/bugs-found-by-musl
- https://wiki.musl-libc.org/compatibility
- https://wiki.musl-libc.org/design-concepts
- https://wiki.musl-libc.org/environment-variables
- https://wiki.musl-libc.org/faq
- https://wiki.musl-libc.org/functional-differences-from-glibc
- https://wiki.musl-libc.org/future-ideas
- https://wiki.musl-libc.org/getting-started
- https://wiki.musl-libc.org/guidelines-for-distributions
- https://wiki.musl-libc.org/open-issues
- https://wiki.musl-libc.org/roadmap
- https://wiki.musl-libc.org/supported-platforms
- https://youtube.com/watch?v=NoU0y8et6Zc