且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何加速linux内核编译?

更新时间:2022-06-24 03:07:01

对于你对源代码做的每一个改变,不要做 make menuconfig ,因为它会触发一切,无论你的改变是多么微不足道。这只需要内核的配置选项更改,并且应该在您的开发期间发生。

Do not do make menuconfig for every change you make to the sources, because it will trigger a full compilation of everything, no matter how trivial your change is. This is only needed when the configuration option of the kernel changes, and that should sheldom happen during your development.

只需执行:

make

汇编:

make -j4

$ b $

然后, make install 等等。当然,部署最近构建的二进制文件可能需要用到。

Then the make install, etc. may be needed for deploying the recently built binaries, of course.

另一个诀窍是将内核配置为测试所需的最小内存。我发现对于许多任务,UML编译(用户模式Linux)是最快的。您还可以找到有用的 make localmodconfig 而不是 make menuconfig

Another trick is to configure the kernel to the minimum needed for your tests. I've found that for many tasks a UML compilation (User Mode Linux) is the fastest. You may also find useful make localmodconfig instead of make menuconfig to start with.