6.11. Musl-0.9.12

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.11.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.11.2. Dynamic Linking

To allow for dynamic linking we need to complete two additional steps, the first ensures a link between the C library and the linker.

 
  
  ln -f ${CLFS}/lib/libc.so `ls ${CLFS}/lib/*musl*` 
  
  

The second step is to ensure that the correct library is pointed two:

 
  
  cd  ${CLFS}/cross-tools/lib/gcc/${CLFS_TARGET}/4.6.0
  
  newInterperter=$(basename `ls ${CLFS}/lib/*musl*` )
  
    echo 'main(){}' > dummy.c
    ${CLFS_TARGET}-gcc dummy.c
    oldInterperter=`readelf -l a.out | grep ': /lib' | cut -d/ -f3 | cut -d] -f1`
    rm dummy.c a.out
  
  ${CLFS_TARGET}-gcc -dumpspecs >specs
  
  sed -i -e"s#${oldInterperter}#${newInterperter}#g" specs
  
  

6.11.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