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.
arm64
)s390
)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.
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.
Past releases, checksums, and file sizes can be viewed under the files subdirectory.
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
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.
Arch Linux
gcc-libs
glibc
icu
libxml2
xz
zlib
zstd
Debian (stable)
libc6
libgcc-s1
libicu67
liblzma5
libstdc++6
libxml2
libzstd1
zlib1g
There may be newer versions of those libraries available (like libicu72
instead of libicu67
) but they will likely still work.
Fedora
glibc
libgcc
libstdc++
libxml2
libzstd
xz-libs
zlib
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.