Everything here is from my own builds. "Tested on" means I actually booted it.
Tip
You don't need to download any of these by hand. The
build scripts fetch the right one into ~/toolchains on
the first run. This page is for people building without a script, or who want
to know what their script is pulling.
To unpack one manually:
tar -xvf filename.tar.xz # or filename.tar.gzThis is the thing that confuses people the most, so, short answer:
| Your source | What you need |
|---|---|
| 4.9 up to 5.4, stock or OEM | Clang and a GCC cross compiler |
| 4.9 up to 5.4, AOSP or LineageOS | Usually Clang only, with LLVM=1 |
| 5.10 and newer | Clang only, with LLVM=1 |
On the old stock trees the build system still calls GCC tools like
aarch64-linux-gnu-ld to assemble and link, even though Clang compiles the C
code. From 5.10 onward LLVM=1 points every tool at the LLVM equivalent, so no
GCC cross compiler is downloaded or used at all.
The middle row is the one people miss. AOSP and LineageOS backport the newer LLVM
support into their old trees, so a 4.14 LineageOS kernel usually builds with Clang
alone even though a 4.14 stock kernel from the same era does not. That is why
there are two scripts for 4.14. If LLVM=1 fails on your tree, it was not
patched, so use the stock script instead.
What build_4.9.sh uses:
proton-12
and linaro-aarch64-7.5
- Tested on 4.9.227-309.
- Usage: build.sh from kernel_samsung_a01
Also works: clang-r416183b
-
Tested on 4.9.227.
-
This one ships its own
aarch64-linux-gnu-binaries, so point both variables inside it:CROSS_COMPILE=/path/to/clang-r416183b/bin/aarch64-linux-gnu- CC=/path/to/clang-r416183b/bin/clang
What build_4.14.sh uses (common 4.14, for devices like realme):
clang-r383902b
and arm-gnu-toolchain-14.2.rel1
What build_4.14_aosp.sh uses (AOSP and LineageOS sources):
neutron-clang
- Tested on Linux 4.14.355.
- Clang only. These trees carry the newer LLVM support, so no GCC is needed.
- Nothing special about this one, it is just what I had set up at the time. Any reasonably recent Clang should build these trees.
- Usage: build.sh from android_kernel_aosp_exynos9820
Samsung with Knox: clang-4639204-cfp-jopp and gcc-cfp-jopp-only
- Tested on Linux 4.14.113 (Galaxy S10x).
- Usage: build.sh from samsung_exynos9820_stock
Samsung without Knox: clang-4639204 and aarch64-linux-android-4.9
- Tested on Linux 4.14.113 (Galaxy M21).
What build_4.19.sh uses:
clang-r353983c
and arm-gnu-toolchain-14.2.rel1
- Tested on Linux 4.19.198, originally with aarch64-linux-android-4.9 as the cross compiler.
- Usage: build.sh from android_kernel_a047f_eur
Also works: clang-r383902 and the same ARM GNU toolchain
- Tested on Linux 4.19.191.
- Usage: build_kernel.sh from A346E_5G_Kernel
What build_5.4.sh and build_qGKI.sh use:
llvm-arm-toolchain-ship-10.0.9
and arm-gnu-toolchain-14.2.rel1
- Tested on Linux 5.4.249, originally with aarch64-linux-android-4.9-Linux-5.4 as the cross compiler.
Note
This Snapdragon toolchain is the one that needs libtinfo.so.5, which no
current distro ships. The build scripts work around it for you.
What build_5.10.sh uses:
clang-r416183b
- Tested on Linux 5.10.198.
- Clang only. The script still passes
CROSS_COMPILE=aarch64-linux-gnu-, but that is only a target triple for Clang, not a path to any GCC. - Usage: build_kernel.sh from android_kernel_s23fe
What build_5.15.sh uses:
clang-r450784e
- Tested on Linux 5.15.123 to 5.15.149.
- Clang only, no
CROSS_COMPILEat all. 5.15 works out its own target.
What build_6.1.sh uses:
clang-r510928
- Clang only, no
CROSS_COMPILE. - This same toolchain builds 5.15 too, so if you only want to keep one Clang around for the modern kernels, keep this one.
Note
There is no rule that says you must use a particular Clang here. Any recent AOSP Clang works on 6.1 and newer, and so do the community builds. I use the AOSP ones because Google builds them for exactly these kernels.
-
On MediaTek kernels from the 4.9 to 5.4 era, use the ARM GNU toolchain alongside a proper Clang to make the kernel boot :)
-
The other MediaTek gotcha, on any version, is that they usually cannot boot a raw
Image. BuildImage.gzinstead. In the build scripts that isKERNEL_IMAGE="Image.gz". -
Since March 21, 2025 the scripts for 4.9 up to 5.4 use the ARM GNU toolchain as their
CROSS_COMPILE. Reference: build_kernel.sh from android_kernel_a042f