[cfe-dev] Fwd: Clang builds a working Linux Kernel (Boots to RL5 with SMP, networking and X, self hosts)

Bryce Lelbach admin at thefireflyproject.us
Thu Oct 28 23:41:38 PDT 2010


Quick update on this, for those interested:

Clang can now compile the majority of drivers and all of the kernel (save Xen)
without problem. The Debian default kernel configuration compiles and boots. We
are still having some intermittent issues (functions omitted by clang because they
are only called in inline asm), but I think these will be worked out in a few
days.

A Debian package is available on github, with a Clang compiled kernel. The kernel
is a no-preemption build, with a complete network stack, crypto API, SELinux,
SMP, KVM, etc (the only thing missing is Xen, basically). The package includes 
about 80% of the drivers shipped with Linux, mostly compiled as loadable kernel
modules (2390 loadable kernel modules in total in this build). Basically, once we
get the remaining omitted function issues worked out, you'd be able to use a 
binary Clang Linux kernel such as this one as a stand-in replacement for just
about any typical Linux distro's shipped kernel.

http://github.com/brycelelbach/lll/downloads

Install at your own risk. If you get any kernel oops (you'll know if you do), 
write down/record the RIP address and the kernel symbol associated with the oops.

I had to hack the following drivers to get them to compile, so take extra caution
if you're considering trying this out on a box with any of these:

  * pmcraid
  * et131x
  * Thinkpad laptops
  * wimax i2400m

Instructions for building from source are available at the github referenced
above. I would advise against it; the process takes two to two and a half hours
on relatively modern machines. You need to do "git submodule init" and then
"git submodule update" after checking out the repository (or something like that).

The Clang and LLVM forks merge changes from the Clang and LLVM git mirrors every
three days (well, I merge the changes by hand, but the point is, it happens every
three days, more or less). The Clang and LLVM git mirrors are updated daily.
I merge changes from upstream Linux whenever I feel like having a migraine.

ATM, extensively benchmarking/regression testing is not really an option; I simply
don't have the CPU power to be able to work on this and run benchmarks. The fastest
of my three machines compiles a full Kernel + drivers in about an hour with Clang,
and it's a good bit longer with GCC.

Big thanks to PaX team and Alp Toker/Nuanti for all the work they've put into this
and their willingness to share it with me.

-- 
Bryce Lelbach aka wash
http://groups.google.com/group/ariel_devel



More information about the cfe-dev mailing list