首先看一下-j
选项在make
命令中的含义:
-j [jobs], --jobs[=jobs]
Specifies the number of jobs (commands) to run simultaneously. If there is more than one -j
option, the last one is effective. If the -j option is given without an argument, make will not
limit the number of jobs that can run simultaneously.
也就是-j
指定并行工作的job
数量,例如make -j4
。如果-j
选项后面没有参数,则不会限制job
数。
再参考《Linux kernel development》:
By default, make spawns only a single job because Makefiles all too often have incorrect dependency information.With incorrect dependencies, multiple jobs can step on each other’s toes, resulting in errors in the build process.The kernel’s Makefiles have correct dependency information, so spawning multiple jobs does not result in failures.To build the kernel with multiple make jobs, use
$ make -jn
Here, n is the number of jobs to spawn. Usual practice is to spawn one or two jobs per processor. For example, on a 16-core machine, you might do
$ make -j32 > /dev/null
可以看到指定job
数是系统core
数量2
倍是一种推荐的做法。