How to build the kernel faster?

I’d like to do some kernel patch testing and bisecting, in other words, I want to rebuild the kernel 20 times in a row.

My CPU is AMD Ryzen 7 7840U, so not the worst out there, but the build takes like half an hour, which, I think, is kinda insane, and I am not really sure why. Am I right in thinking that the default NixOS config is just really heavy and builds way too many modules? I was expecting it to take a couple of minutes.

Is there some best-practice / guide on making the kernel build fast? I think I am inclined to simply start from a defconfig and tweak it to make sure it runs on my hardware.

it answers “m” if possible

So yes.

But indeed you can pass your own configfile

See this:

3 Likes

You can use CCache using an overlay, and it will cache partial build products between runs. This may speed up kernel bisects.

There’s also this thread discussing how to get it working for kernel builds.