After the release of glibc 2.43, the first stable glibc to support compilation with clang (but only on x86_64 and arm64), I thought about a glibc-based GNU/Linux fully bootstrapped with clang. Is it possible? Short aswer: yes. I almost finished LFS bootstrapped entirely (except i686 glibc) with clang.
I eventually switched to glibc's master branch (more specifically, commit https://gitlab.com/gnutools/glibc/-/commit/e10977481f4db4b2a3ce34fa4c3a1e26651ae312) instead of stable 2.43 because they added support for compiler-rt and libunwind instead of libgcc_s.
I think system like this is very similar to LLVM/Musl LFS, so I'm not inventing a wheel here, but I still think its worth posting.
So, here are the changes I made compared to "vanilla" LFS:
- I fully used clang instead of gcc in boostrapping process. That means I first compiled static clang-pass1 pointing to LFS dir instead of host dirs and used "toolchain" file for cmake to prevent using host libs in 4 stage (yep i needed 4 stages instead of 3) clang-pass2.
- Almost everything (including x86_64 glibc) compiled with clang + compiler-rt (with builtin atomics) + libunwind. The only thing that required gcc (and libgcc_s) was multilib glibc (all other multilib stuff compiled with clang). Ofc this is not a problem if you running x86_64-only.
- No Binutils. I created symlinks from LLVM tools to replace them.
- GCC bootstrapped with clang, installed in custom path to prevent stuff like cmake from using it and its libs by default. Also I patched it a little bit to use "clang -x assembler" instead of GNU as (which is part of binutils).
- dpkg + apt as package manager.
- Maybe some small differences I forgot to mention.
Why Im posting this before I 100% done LFS, compiled kernel and booted it? Well, I think I done the "hard" part, so all remaining is to just install stuff like python modules, meson, ninja.. I will post more details about bootstrap process and patches I done if anyone interested.
P.S: Forgot to mention that I have nothing against GCC, Binutils or any other projects of GNU, this is mostly just proof-of-concept and just a fun "project" I decided to do.
I also wanted to point out that clang support in Glibc is still experimental, and that I haven't done a "make check" on most programs yet, so all this should be taken with a grain of salt.