Wong's Cafe
2022-04-27 (Updated 2023-06-10)
I recently found out that you can optimize linux kernel even more by using clang-fullLTO, and here's how I did it with the help of kernel.org.
The Linux kernel has always traditionally been compiled with GNU toolchains such as GCC and binutils. Ongoing work has allowed for Clang and LLVM utilities to be used as viable substitutes. Distributions such as Android, ChromeOS, and OpenMandriva use Clang built kernels. LLVM is a collection of toolchain components implemented in terms of C++ objects. Clang is a front-end to LLVM that supports C and the GNU C extensions required by the kernel, and is pronounced “klang,” not “see-lang.”
LLVM=1
arg to make
LTO_CLANG_FULL
in make nconfig
$PATH
aka. which clang
returns a valid path.On x86 and arm{,64}, you set LLVM=1
, on other archs, please refer to kernel.org
I automate these steps by adding the arg and path to clang into my and (2024-12-13 update: the repo is not public anymore)
make
will call default shell in /etc/passwd
which in my case isn't bash.)make LLVM=1 nconfig
to enable LTO_CLANG_FULL
-> General architecture-dependent options
-> Link Time Optimization (LTO) (<choice> [=y])
LLVM=1