6.10. Musl-0.9.13

The Musl package contains the 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.

6.10.1. Installation of Musl libc

It should be noted that compiling Musl in any way other than the method suggested in this book puts the stability of the system at risk.

Prepare Musl libc for compilation:




CROSS_COMPILE=${CLFS_TARGET}-  ./configure --prefix=${CLFS} --disable-gcc-wrapper \
    --target=${CLFS_TARGET} --build=${CLFS_HOST} --syslibdir=${CLFS}/lib --includedir=${CLFS}/usr/include
    
    

The meaning of the new configure options:

CROSS_COMPILE=${CLFS_TARGET}-

This sets Musl to use the cross-tools that have been built.

--disable-gcc-wrapper

This option is to disable the default situation where Musl is not the only library on the system.

--syslibdir=${CLFS}/lib

This set location for library.

--includedir=${CLFS}/usr/include

This sets location for header files.

Compile the package:

make 

Install the package:

make install

Add additional header files:



cp ${CLFS}/usr/include/linux/if_slip.h ${CLFS}/usr/include/net/if_slip.h
cp ${CLFS}/usr/include/net/if_arp.h ${CLFS}/usr/include/linux/if_arp.h 


6.10.2. Dynamic Linker Configuration

The Musl package is also a dynamic linker. The GCC tool chain point to /lib/ld-musl-${ARCH}.so.1 as the dynamic linker. This is actually just a link to libc.so. The linker will scan certain directories to search for the required library. The following configuration file will direct the linker as to which directories to search:

cat > ${CLFS}/etc/ld-musl-${CLFS_ARCH}.path << "EOF"
/lib:/usr/lib
EOF

The Musl package is also a dynamic linker. The GCC tool chain point to /lib/ld-musl-${ARCH}.so.1 as the dynamic linker. This is actually just a soft link to libc.so. To ensure the link works after being copied to a new file system we need to replace it with a hard link as follows:


ln -f ${CLFS}/lib/libc.so  ${CLFS}/lib/ld-musl-${CLFS_ARCH}.so.1 

6.10.3. Contents of Musl

Installed Programs: To be written...
Installed Libraries: To be written...
Installed Headers: To be written...

Short Descriptions

ld

The dynamic linker / loader

libc

The C library

libcrypt

The cryptographic library

libdl

The dynamic linker / loader library

libm

The math library

libpthread

The POSIX thread library

librt

The clock and timer library