Slim LLVM toolchains for building the Linux kernel

There are times where you may need access to different versions of LLVM for building the kernel instead of the one available through your distribution, such as reproducing an issue only visible with specific versions or gaining access to a feature only available in a newer version. These toolchains have been built from the llvmorg-<version> tags in the llvm-project repository and optimized with profile guided optimization (PGO) via tc-build to improve the speed of the toolchain for building the kernel, meaning they should be quicker than your distribution's version of clang, unless they use PGO as well. These toolchains aim to be fairly minimal by just including the necessary tools to build the kernel proper to reduce the size of the installation on disk; it is possible things are missing for the selftests and other projects within the kernel.

The following LLVM backends are enabled, which means a single clang binary can generate object files for any of the following architectures.

NOTE: clang has an integrated assembler and ld.lld can generally replace ld.bfd but certain architectures and configuration combinations may still need GNU binutils to work fully. Generally, distribution versions of those should work fine in combination with these toolchains.

Downloads

These toolchains are available for aarch64 and x86_64 machines. If you are unsure which one you have, run uname -m.

Versions that have an -rc in them are prerelease versions, meaning the LLVM community is in the process of qualifying them for the formal stable release, much like Linux -rc releases. Please consider reporting any issues found with them using the instructions in the "Support" section below so that any issues can potentially be addressed before the final release.

aarch64 x86_64
19.1.5 .tar.gz
.tar.xz
.tar.gz
.tar.xz
18.1.8 .tar.gz
.tar.xz
.tar.gz
.tar.xz
17.0.6 .tar.gz
.tar.xz
.tar.gz
.tar.xz
16.0.6 .tar.gz
.tar.xz
.tar.gz
.tar.xz
15.0.7 .tar.gz
.tar.xz
.tar.gz
.tar.xz
14.0.6 .tar.gz
.tar.xz
.tar.gz
.tar.xz
13.0.1 .tar.gz
.tar.xz
.tar.gz
.tar.xz
12.0.1 .tar.gz
.tar.xz
.tar.gz
.tar.xz
11.1.0 .tar.gz
.tar.xz
.tar.gz
.tar.xz

Past releases, checksums, and file sizes can be viewed under the files subdirectory.

Use

To use these toolchains, download and extract them somewhere on your hard drive using tar -axf. For the following examples, I will assume they are installed within the root of your kernel source.

For kernels that include e9c281928c24 (i.e., 5.18+), LLVM=<prefix>/bin/ can be used like so:

$ make LLVM=$PWD/llvm-15.0.7/bin/ ...

For prior versions, PATH must be used.

$ export PATH=$PWD/llvm-15.0.7/bin:$PATH
$ make LLVM=1 ...
or
$ PATH=$PWD/llvm-15.0.7/bin:$PATH make LLVM=1 ...

For more information about building the Linux kernel with LLVM, please see the official documentation and the ClangBuiltLinux homepage

Dependencies

These toolchains have been built in a Debian 10 (Buster) container, which means they should run on Linux systems with glibc 2.28 or newer. For some common distributions, I have included a list of the packages that should satisfy the dynamic dependencies to run these toolchains.

Support

If you encounter an issue while using these toolchains, either open an issue on the ClangBuiltLinux issue tracker or send an email to nathan@kernel.org and llvm@lists.linux.dev. Please include the kernel configuration you experience the issue with, the architecture you are building, and information about your distribution such as version.