User Tools

Site Tools


qLinux
… a distribution study


<< Prev
Preparations

Next >>
Musl-1.2.2


Build the Cross-Toolchain

Before continue: Check twice that you are NOT root! (Especially before each 'make install')

The chapter 5 of the book can be skipped. Instead we build a musl based cross toolchain. There are 2 alternatives: musl-cross-make and mussel. The latter is more up-to-date, thus it's the recommended choice. Download it and extract it in the home of the lfs user. Change into the directory (usually called  mussel-master ). Run  ./check.sh  and install the missing packages. Then open  ./mussel.sh  in an editor and change the value of the following two variables to:

MPREFIX="/_tools"
MSYSROOT="/_tools"

Alternative apply this patch. Then build and install it with

sudo ./mussel.sh x86_64 -l -o

This takes a while. If finished change ownership of the top level directory to the lfs user, move it to the $LFS directory and create a symlink:

chown -R lfs.users /_tools
mv /_tools $LFS/_tools
sudo ln -s $LFS/_tools /_tools

This installs the mussel toolchain in  /_tools  with an absolute pathe. The tools are required in the chroot later on too. The move and the symlink makes sure that we refer to the same absolute path always.

The new cross compiler has built-in specs which refer to the musl dynamic loader  /lib/ld-musl-x86_64.so.1 . We have to adjust this to reflect the filesystem layout of the target system which is  /qlnx/lib/ld-musl-x86_64.so.1 . This will be reached by creating a modified  specs  file in the proper location:

/_tools/bin/x86_64-linux-musl-gcc -dumpspecs | sed 's/\/lib\/ld-musl/\/qlnx\/lib\/ld-musl/g' > /_tools/lib/gcc/x86_64-linux-musl/11.2.0/specs

Now it have to verified that all works like expected.

Test It

$> cd $LFS
$> printf "#include <stdio.h>\nint main(){}\n" > dummy.c
$> $LFS_TGT-gcc dummy.c
$> readelf -l a.out | grep ld

The output HAVE TO be:

      [Requesting program interpreter: /qlnx/lib/ld-musl-x86_64.so.1]

Otherwise stop here and investigate. If everything is ok delete  a.out .

Install Header Files

We can use the “fresh” header files “created” by  mussel.sh . It doesn't make any significant difference to extract and install them again. Copy the headers from the mussel toolchain:

cp -vr /_tools/usr/include /qlnx/inc

<< Prev
Preparations

        

Next >>
Musl-1.2.2