2

Firstly, this isn't my first attempt at building an LFS system - I've already successfully built LFS 7.8 and LFS 7.8-systemd.

I would like to replace GCC+GlibC with ELLCC, which is Clang/LLVM+musl.

It has a few limitations - the most notable of which is that it currently lacks support for dynamic linking - but the intended end is a cross-compiled (or better yet, compiled on-device) armhf LFS build, as part of an experiment in replacing Android completely with Linux on an old device of mine, so the efficiency of the binaries produced matters (hence the reason I'm interested in using ELLCC.)

The real question is, how would I go about doing this? Simply replacing GCC and GlibC with ELLCC won't even let me get past installing the Linux API headers. I can compile some of the programs from source separately, but they always end up relying on the host system in one way or another.

  • I suggest you to add musl to the question tags. – user140866 Jan 29 '16 at 4:21
  • Just stumbled on this question today. Strangely enough I posted this about building a small bootable Linux for the Raspberry Pi using ELLCC on Jaunary 13th: ellcc.org/blog/?p=26628 – Richard Pennington Aug 20 '16 at 21:27
2

You're right - simply swapping toolchains will not magically make it work.

As an experienced musl user I can say this will not work "out of the box". Many, many programs still require special cases glibc only provides which are even not in musl, and especially many GNU project programs will not even compile without glibc presence.

The big work of fixing popular, but broken programs currently is in progress, and you can monitor and participate if you want. There are projects like sabotage linux which generate patches for such programs to make them work with musl (and other less known libcs as well), so if you are brave enough, you can try to fix major build breakages with help of those projects.

To make plain LFS work you will end up probably massively hacking the book. (Back into 2009 when I've built LFS last time I remember there were still unexplained instructions which worked around some glibc special cases)

As an alternatives, you can try:

  • CLFS embedded, which had replaced glibc with musl. You can merge both books to make something that will work in your situation. Although it completely omits classical GNU software.
  • Use one of those new musl-based Linux distributions available. As an examples, I can name sabotage and alpine, but musl wiki names more. At least you can build binaries on host and them try to import them to your device.

Since you are trying to build binaries for embedded platform, I highly suggest you not to mess up with GNU software, but try lightweight alternatives instead.

  • This is a wonderful answer, thanks for sharing. – JoshuaRLi Jan 20 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.