Linux 7.4 has started pulling in patches meant to speed up the kernel build, according to Phoronix. That matters if you compile kernels to bisect, test release candidates, or tune a custom config. But the Phoronix report gives no patch details and no benchmark numbers, so this guide does not guess at what the patches do or how much time they save.
You can shorten builds today with levers that work on current kernels. Each step below lists prerequisites, a command, what to expect, a way to verify, and a way back if something breaks. These commands are not benchmarked here, so record your own numbers.
Set up a baseline before you change anything
A speedup you did not measure is a rumor. Build once with your current setup and keep the result.
Prerequisites: a kernel source tree and the build dependencies.
- Debian or Ubuntu:
build-essential flex bison libssl-dev libelf-dev bc - Fedora: the development tools group, plus
openssl-develandelfutils-libelf-devel - Arch or Manjaro:
base-develandbc
cp /boot/config-$(uname -r) .config
make olddefconfig
make clean
time make -j$(nproc) > build.log 2>&1
The config path varies by distro. Arch, for example, can expose the running config at /proc/config.gz instead.
The time command prints three lines: real, user, and sys. Compare real between runs, since that is the wall-clock wait you feel. Fill in this template with your own results:
| Run | Change applied | Kernel version | Toolchain | real | user | sys | |---|---|---|---|---|---|---| | 0 | Baseline | | | | | | | 1 | | | | | | |
Two habits keep the comparison honest. Use the same .config and the same source commit for every run, and note whether the machine was idle. For a cold-cache run, execute sync; echo 3 | sudo tee /proc/sys/vm/drop_caches first. Run each configuration at least twice, because the second run benefits from a warm page cache.
The 7 fixes
- Use all your cores with make -j.
- Trim the config with localmodconfig.
- Turn off debug info you do not need.
- Cache compiles with ccache.
- Try the LLVM toolchain with lld.
- Build on tmpfs or fast storage.
- Build out-of-tree with O=.
1. Use all your cores with make -j
Prerequisite: a working build. If you have been running plain make, start here.
time make -j$(nproc)
Expect: interleaved compile lines and much higher CPU load in top or htop.
Verify: compare real against your baseline. On a laptop with limited RAM or thermal headroom, -j$(nproc) can cause swapping or throttling. Try -j$(( $(nproc) / 2 )) and compare.
Rollback: drop the flag. Nothing persists.
2. Trim the config with localmodconfig
A distro config builds thousands of drivers you will never load. localmodconfig disables module options that do not match what is currently loaded.
Prerequisite: a starting .config and a machine in the state you want to support. Plug in your USB devices, mount your filesystems, and connect your VPN first, because only loaded modules survive.
cp .config .config.full
make localmodconfig
time make -j$(nproc)
Expect: the tool may prompt about new options. You can usually press Enter to accept the defaults.
Verify: grep -c '=m' .config.full .config shows how many modules each config still builds. Then compare timings. We cover related ground in how to check laptop linux kernel support before 7.4 explained.
Rollback: cp .config.full .config && make olddefconfig. If the trimmed kernel fails to boot or lacks a device, boot your old kernel, load the missing hardware, and rerun the step. Skip this trim if you test kernels across several machines.
3. Turn off debug info you do not need
Debug information makes compilation and linking heavier. If you do not plan to use debuggers or crash analysis on this build, disable it.
Prerequisite: the scripts/config helper that ships in the kernel tree. Option names can differ between kernel versions, so confirm them in make menuconfig under the Kernel hacking section.
scripts/config --enable DEBUG_INFO_NONE
make olddefconfig
grep DEBUG_INFO .config
Expect: CONFIG_DEBUG_INFO_NONE=y in the output.
Verify: time the build.
Rollback: restore your saved .config. Keep debug info on when you chase a bug that needs symbols.
4. Cache compiles with ccache
ccache pays off when you rebuild similar trees repeatedly, such as when bisecting or rebasing. A single clean build gets nothing from it.
Prerequisite: install ccache from your package manager (apt, dnf, or pacman).
ccache -z
make CC="ccache gcc" -j$(nproc)
ccache -s
Expect: the first run fills the cache with misses, so it may run no faster, or slightly slower. A second build after make clean should show hits in ccache -s.
Verify: compare the second-run time against baseline run 0, and check that the hit count climbs.
Rollback: omit the CC= override. To reclaim disk, run ccache -C.
5. Try the LLVM toolchain with lld
Clang and lld are a supported way to build the kernel, selected with a single flag. Whether they beat GCC and GNU ld on your machine is a measurement question, so do not assume.
Prerequisite: install clang, lld, and llvm for your distro. Use a separate build directory, or back up .config and run make mrproper. Mixing toolchains in one tree causes confusing errors.
make LLVM=1 O=../build-llvm olddefconfig
time make LLVM=1 O=../build-llvm -j$(nproc)
Expect: compile lines that reference clang, and a normal finish.
Verify: time it against the GCC build of the same config, and check the toolchain version with clang --version. For more on this, see full coverage of linux kernel ai-generated code policy: can you submit it?.
Rollback: delete the build directory and build with your default compiler. If a particular config fails under LLVM, fall back to GCC and check the kernel's documentation for supported compiler versions.
6. Build on tmpfs or fast storage
Compiling writes many small object files. RAM-backed or NVMe storage removes disk waits, though on a machine with a fast SSD and plenty of cache the gain may be small.
Prerequisite: enough free RAM for the output tree, plus headroom. The tree size varies widely by config, so run du -sh after a build on disk to find yours.
sudo mkdir -p /mnt/kbuild
sudo mount -t tmpfs -o size=20G tmpfs /mnt/kbuild
df -h /mnt/kbuild
Expect: an empty 20G mount that consumes RAM only as files land.
Verify: build into it (see the next step) and compare.
Rollback: sudo umount /mnt/kbuild. Everything on it vanishes at unmount or reboot, so copy out the kernel image and modules you want to keep. If the system starts swapping, shrink the tree or return to disk.
7. Build out-of-tree with O=
The O= option sends all build output to a separate directory. It keeps your source tree clean and lets you hold GCC and LLVM builds side by side. It also pairs naturally with the tmpfs mount above.
Also read: context: run local ai on ubuntu 26.10: ollama setup for beginners
make O=/mnt/kbuild/gcc olddefconfig
time make O=/mnt/kbuild/gcc -j$(nproc)
Expect: .config, object files, and vmlinux in the output directory, with the source tree untouched. Pass the same O= value to every later make command, including modules_install.
Verify: git status in the source tree stays clean.
Rollback: rm -rf /mnt/kbuild/gcc.
What the Linux 7.4 patches mean for your timings
Phoronix reports that Linux 7.4 is beginning to land patches that speed up the kernel build. The report does not say how they work, and neither does this guide. Before you decide whether to wait, read the actual pull request on the kernel mailing list and the Kbuild commit history on kernel.org, then check any quoted figures.
You do not need to wait. The seven levers above are independent of those patches.
To separate your gains from upstream's, build the same .config with the same compiler on an older tree and on a 7.4 tree, using olddefconfig to carry the config over. Any difference with the setup held constant comes from the kernel. Everything else comes from your setup.
Rollback and recovery checklist
Before your first experimental build, protect your known-good system.
Keep at least one working kernel installed and visible in the bootloader. If a new build fails to boot, pick the older entry from the GRUB advanced menu or your bootloader's equivalent. Set a distinct suffix, for example scripts/config --set-str LOCALVERSION "-test", so make modules_install does not overwrite the modules of a kernel you can boot.
Save every config you care about with cp .config .config.$(date +%F).
To clean a tree, remember the difference between the two targets. make clean removes most build products and keeps .config. make mrproper also deletes .config, so back it up first. With O=, remove the output directory instead.
If a toolchain switch produces strange errors, do not debug them in a dirty tree. Delete the output and start fresh.
What to expect next
A filled-in timing table shows which levers matter on your hardware. When Linux 7.4 or a later release candidate arrives, rerun your baseline command on the new tree and add a row. If the upstream pull request lists measured gains, you can compare them against your own numbers instead of taking a headline on faith.



