diff options
authorWolfgang Müller2022-02-05 19:30:29 +0100
committerWolfgang Müller2022-02-05 19:30:29 +0100
commit0cafe2653998a2ed5fe6fb483b543c1b71e53516 (patch)
parentd3cf8192a22895076c1dd162301e671b97923059 (diff)
content: Add new post: "Building the Linux kernel with clang and full LTO"
1 files changed, 42 insertions, 0 deletions
diff --git a/content/16/ b/content/16/
new file mode 100644
index 0000000..2cb12b3
--- /dev/null
+++ b/content/16/
@@ -0,0 +1,42 @@
+date = 2022-02-05T19:29:44+01:00
+title = "Building the Linux kernel with clang and full LTO"
+tags = ["experiments"]
+My main desktop PC tracks the latest LTS [release]( of the
+Linux kernel which very recently switched to the 5.15 line. Along with neat new
+features like the
+[NTSF3 driver](
+it also includes experimental support for
+[Link Time Optimization](
+through LLVM's
+[`clang` compiler](
+I'm not really one to shy away from weird experiments, so I decided to run a
+full LTO kernel for a while. If you have a recent version of `clang` and the
+[`lld` linker](, building one is as easy as toggling
+`CONFIG_LTO_CLANG_FULL` and exporting the right flags to `make`:
+ make CC=clang LLVM=1 menuconfig
+ make CC=clang LLVM=1
+Subsequent steps are the same as with a normal build:
+ sudo make install
+ sudo make modules_install
+Keep in mind, however, that any out-of-tree modules such as ZFS must also be
+built with `clang`. Here I ran into
+[this bug]( which should soon be
+[fixed upstream]( For now I
+backported that fix locally to ZFS 2.1.2 and am building it like so:
+ sudo CC=clang LLVM=1 emerge zfs-kmod
+Build times and memory usage when building are increased dramatically with full
+LTO. Optimizing `vmlinux.o` alone allocates about 3 to 4 GiB of memory. If you
+rely a lot on incremental builds, thin LTO might be the better option here.