Advanced building options
The kernel build system allows you to do many more things than just build the full kernel and modules. Chapter 10 includes the full list of options that the kernel build system provides. In this section, we will discuss some of these advanced build options. To see a full description of how to use other advanced build options, refer to the in-kernel documentation on the build system, which can be found in the Documentation/kbuild/ directory of the sources.
Building faster on multiprocessor machines
The kernel build system works very well as a task that can be split up into little pieces and given to different processors. By doing this, you can use the full power of a multiprocessor machine and reduce the kernel build time considerably.
To build the kernel in a multithreaded way, use the
-j option to the make program. It is best to give a number to
the -j option that corresponds to twice the number of
processors in the system. So, for a machine with 2 processors present,
use:
$ make -j4and for a machine with four processors, use:
$ make -j8
If you do not pass a numerical value to the -j option
$ make -j
the build system will create a new thread for every subdirectory in
the kernel tree, which can easily cause your machine to become
unresponsive and take a much longer time to complete the build.
Because of this, it is recommended that you always pass a number to
the -j option.
Building only a portion of the kernel
When doing kernel development, sometimes you wish ...