Skip to content

Instantly share code, notes, and snippets.

@lidgnulinux
Last active April 11, 2025 09:41
Build LFS with Musl, Libressl and Eudev.

Build LFS with Musl, Libressl and Eudev.

Prerequisite.

We need some stuffs to be prepared, like :

  • Musl-based linux distro as host. I used dragora GNU/Linux. We may use alpine as well.
  • Compiler, I use gcc 14.
  • LFS book, just ignore everything about the glibc, openssl and eudev part.
  • Mussel to build cross compilers.
  • Time and patient.

Note : We won't cover everything and just some needed steps.

Steps.

  1. Do everything before Chapter 5.

  2. For chapter 5 :

    • skip binutils pass 1 and gcc pass 1 ! Replace them with mussel, just clone and run the script (e.g. mussel -k -l -o -p) ! Move the result build to lfs tools directory !
    • Replace glibc at 5.5 with musl !
    • Enter libstdc++-v3 directory from previous mussel gcc build ! Run make DESTDIR=$LFS install !
  3. For chapter 6 :

    • Build everything normally !
    • After gcc pass 2 build is done, you need to copy libzstd.so from host to $LFS/usr/lib in order to make gcc pass 2 works. Somehow some binaries under $LFS/usr/libexec/gcc/x86_64-pc-linux-musl/14.2.0/ still linked to libzstd.so library from host.
  4. For chapter 7 :

    • Perl need to be built out of tree, make a directory outside source code and run sh /path/to/Configure -Dmksymlinks -D blablabla followed by make and make install.
  5. For chapter 8.

    • Build musl instead of glibc !
    • Avoid to build libxcrypt, since it will replace some stuffs from musl (e.g crypt.h header).
    • Build binutils and add --disable-gprofng or --enable-gprofng=no option !
    • Perl need to be built out of tree, make a directory outside source code and run sh /path/to/Configure -Dmksymlinks -D blablabla followed by make and make install.
    • Build libressl 4.0.0 instead of openssl !
    • Kmod 33 need some patches on musl, please check on alpine linux APKBUILD. Kmod 34 works without patch on musl.
    • Before build libelf / elfutils, you need to build musl-obstack, musl-fts, and argp-standalone.
    • Python need some patches for libressl's compatibility. Check at openbsd port for the patches !
    • Build eudev instead of udev !

Notes.

  • If some packages are failed to build, just apply patches from alpine linux !
@Ayush-pbh
Copy link

noice, thanks!

@CatRyBouReal
Copy link

I'm a little confused by what you mean by "Enter libstdc++-v3 directory from previous mussel gcc build", especially given that there is no Makefile in that directory to run make DESTDIR=$LFS install. Could you please clarify?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment