freenode
Kernel & Low-Level

Kbuild series slashes kernel build times by up to 36%

Lorenzo Stoakes targets single-threaded make, modpost, objtool, and Rust bottlenecks that dominate large and incremental builds.

A 23-patch series from Lorenzo Stoakes of ARM aims to cut Linux kernel build times sharply by attacking single-threaded bottlenecks that leave modern multi-core machines idle for long stretches of a typical make run.

On allmodconfig builds, Stoakes reports full rebuilds up to 36% faster, incremental rebuilds around 70% faster, and no-op rebuilds (nothing changed) up to about 90% faster. Gains held across gcc and clang on a 64-core Threadripper, a 256-core dual-socket EPYC system, and an 8-core Apple M2 laptop. Defconfig full builds improved by roughly 17% to 34% depending on compiler and machine.

The work spreads across several choke points. Dependency checking for large trees, once a long single-threaded make parse of huge .cmd files, moves into a small C helper that does far less work when little has changed. Repeated compiler and linker feature probes become one-time Kconfig results. Modpost, which sits on the serial tail of every vmlinux link, gets faster source hashing, cached section-mismatch checks, parallel file hashing, and module descriptors emitted as assembly instead of thousands of tiny C compilations. Module finalisation is split into parallel chunks so make is not crushed under tens of thousands of millisecond jobs. Objtool gains relocation and dead-end caches plus multi-threaded instruction decode. Rust crate builds can use rustc threading and no longer stall the start of every clean CONFIG_RUST build behind a serial prepare step. When pigz is installed, it becomes the default compressor for the final vmlinux.bin gzip step.

Stoakes states that generated outputs were checked byte-for-byte identical where it matters (modules, objtool results, Rust and C objects), with the usual caveat that pigz and gzip streams differ, so reproducible builds still need a fixed tool set. The series is aimed at developers and CI systems that rebuild the kernel constantly: the largest wins show up precisely where frustration is highest, wide allmodconfig trees and the near-instant no-op and touch-one-file cases that still used to burn many seconds in serial make and post-processing.