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