Main Page

LLVMLinux Project Overview

This project aims to fully build the Linux kernel using Clang which is the C front end for the LLVM compiler infrastructure project. Together Clang and LLVM have many positive attributes and features which many developers and system integrators would like to take advantage of when developing and deploying the Linux Kernel as a part of their own projects.

The hope is that this project will help reduce duplicate work, as well as concentrate, and accelerate efforts around this subject matter in order to allow Linux Kernel developers, and system integrators to have the choice of a Clang compiled Linux kernel. The goal is for this project to be a testing/proving ground for these updates and to get patches that make this possible upstream to their respective projects.

The LLVMLinux project consolidates the work of the lll-project, the PAX team, and Mark Charlebois' work on the ARM kernel.

There have been several presentations and articles on this topic if you wish to learn more about the reasons for this project.

Currently the work is centred around the ARM, x86, x86_64, and MIPS architectures but contributions to support other architectures are welcome. Patches accepted!

Interested parties will be holding a Bi-weekly Google Hangout to discuss project status and goals.

Show me the code!

By popular demand, here are the coles-notes version of how to build a kernel with clang.

  1. Get the latest SVN version of clang (v3.5 or higher: You need named register support which isn't in v3.4)
  2. Patch your kernel source (not all required patches are upstream yet)
  3. Build your kernel, making sure to set HOSTCC/CC and optionally ARCH/CROSS_COMPILE.
    • For native compiling (like for x86_64): make HOSTCC=clang CC=clang
    • For cross: make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- HOSTCC=clang CC=clang
    • For cross: make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- HOSTCC=clang CC=clang
    • You may find you need to set GCC_TOOLCHAIN=<path-to-your-gcc-cross-toolchain> if the above doesn't work.

Yes, there is still a dependancy on parts of the gcc toolchain. Most notably ld, as, and sometimes libgcc.

Little 'm' makefile

And to make things simpler to choose clang as your compiler, you can use the following makefile.

  1. Patch your kernel tree with the above patches (or use the pre-patched kernel tree)
  2. download makefile and put it in the top level kernel directory (notice it starts with a lower case "m")
  3. GNU make will actually use the makefile in this case to drive the kernel Makefile
  4. Edit makefile to suit your particular PATHs or settings
  5. Otherwise, use make as normal to build the kernel

Current Patch Statistics

Number of patches: 41
    all: 21  submitted:  9  acked:  3  accepted:  2
aarch64:  3  submitted:  0  acked:  0  accepted:  0
    arm:  7  submitted:  3  acked:  1  accepted:  0
   mips:  6  submitted:  0  acked:  0  accepted:  0
    x86:  4  submitted:  0  acked:  0  accepted:  0
 totals: 41  submitted: 12  acked:  4  accepted:  2
completed or obsoleted: 129

Headline text


2014.04.07 Jan-Simon Möller will be giving a talk during EuroLLVM in Edinburgh. See the programme page.

2014.02.02 A patchset for the stable kernel will be available for kernel v3.13 soon.

2014.02.01 Jan-Simon will be giving talks during FOSDEM. Join us in the LLVM devroom !

2013.09.18 Behan and Mark will be leading the LLVM microConference at Linux Plumbers Conference.

2013.02.20 Behan Webster will be presenting a talk at Embedded Linux Conference: LLVMLinux: Compiling the Linux Kernel with LLVM slides Video

2013.02.18: Behan Webster will be presenting a talk at Android Builders Summit: LLVMLinux: Compiling Android with LLVM slides

2013.02.02: Jan-Simon Möller will be presenting a lightning talk at FOSDEM: The Linux Kernel with Dragon Wings

2012.08.16: Bryce Adelstein-Lelbach will be giving a talk on LLVM-compiled Linux for the Real World at LinuxCon NA

2012.08.16: An LLVM micro-conference has been added to this year's Linux Plumbers Conference. Mark Charlebois and Behan Webster will talking about LLVM Toolchain - Update and State of Building Linux with LLVM and Jan-Simon Moeller will be talking about LLVM/Clang x86 Kernel Build.

2012.08.13: A LLVM microconference has been setup for this year's Linux Plumbers Conference. Several project contributors will be giving talks during the microconference.

2012.07.14 Demo of a clang built kernel running on an i7 laptop!

2012.06.12: New targets! x86_64 and i586 are now available beside the ARM targets msm and vexpress.

Why use Clang/LLVM with the Linux Kernel?

  • Fast Compiles (making you able to work faster)
  • LLVM/Clang is a fast moving project with many things fixed quickly and features added.
  • LLVM is a family of tools used in many problem domains leading to one code base being able to build tools to work on just about anything you need: one place to add features, or fix bugs.
  • BSD License (some people prefer this license to the GPL)
  • Built in static analyzer
  • Great error reporting and Fix-it hints
  • LLVM technology can be embedded into many tools (even yours!)
  • Already in wide used in OSS projects and in industry

Project Status


Project Roadmap/Todos


Project Bug Status

Current State of the LLVMLinux project

  • A build framework which downloads and builds LLVM, Clang, QEMU, and cross-compiles the linux kernel, and LTP
  • Work is currently centering around the ARM, i586, x86_64, and MIPS architectures (it would be great to see contributions to other architectures such as PowerPC, etc)
  • The x86_64 patches from the lll-project have been rolled into the LLVMLinux code base. The targets for i586 and x86_64 allow you to build working kernels. However, not for production use yet.
  • An SD image has been constructed using Linaro upon which we add the latest Linux Test Project (LTP) for testing ARM targets in QEMU. In future we hope to extend this testing to other architectures as well.
  • Built kernel are booted using QEMU with the aforementioned SD image, which executes the LTP in an effort to see whether the kernel has been compiled properly with Clang/LLVM.
  • Buildbot boot-tests patched ARM kernels compiled with both Clang and gcc, as well as nightly LTP runs on both kernels.
  • The above process is executed by buildbot, which provides continuous integration for all the associated code bases, and posts build statuses to the #llvmlinux IRC channel on OFTC
  • Any issues which are found through these processes will be fixed, and patches submitted upstream to the kernel and LLVM/Clang projects.
  • A list of broken kernel options can be found here.

How Can I Get Involved?

Who Else is Using Clang/LLVM?

Project Hosting

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More about the foundation...