The Musl Package contains an alternative main C library. This library provides the basic routines for allocating memory, searching directories, opening and closing files, reading and writing files, string handling, pattern matching, arithmetic, and so on.
The malloc implementation used by Musl is slow. Apply the following patch to use rpmalloc as a faster alternative:
patch -Np1 -i ../musl-1.2.5-rpmalloc.patch
Patch some vulnerabilities:
patch -Np1 -i ../musl-1.2.5-iconv-fix.patch
Prepare Musl for compilation:
./configure --prefix=/usr --with-malloc=rpmalloc
The meaning of the configure options:
--with-malloc=rpmalloc
This makes Musl use the just-patched rpmalloc implementation
Compile the package:
make
Install the package:
make install
The /etc/nsswitch.conf file needs
to be created because the Glibc defaults do not work well in a
networked environment.
Create a new file /etc/nsswitch.conf by running the following:
cat > /etc/nsswitch.conf << "EOF"
# Begin /etc/nsswitch.conf
passwd: files
group: files
shadow: files
hosts: files dns
networks: files
protocols: files
services: files
ethers: files
rpc: files
# End /etc/nsswitch.conf
EOF
By default, the dynamic loader (/lib/ld-musl-x86_64.so.1) searches through /usr/lib for dynamic libraries that are needed by programs as they are run. However, if there are libraries in directories other than /usr/lib, these need to be added to the /etc/ld-musl-x86_64.path file in order for the dynamic loader to find them. Two directories that are commonly known to contain additional libraries are /usr/local/lib and /opt/lib, so add those directories to the dynamic loader's search path.
Create a new file /etc/ld-musl-x86_64.path by running the
following:
cat > ld-musl-x86_64.path << "EOF"
# Begin /etc/ld.so.conf
/usr/lib
/usr/local/lib
/opt/lib
EOF
Add the ldd program as a symlink to libc.
case $(uname -m) in
i?86) ln -sfv ../lib/ld-musl.so.1 /usr/bin/ldd
;;
x86_64) ln -sfv ../lib/ld-musl-x86_64.so.1 /usr/bin/ldd
;;
esac