Speedup GNU make build process - Parallelism?
I build a huge project frequently and this takes long time (more than one hour) to finish even after configuring pre-comp开发者_开发百科iled headers. Are their any guidelines or tricks to allow make work in parallel (e.g. starting gcc in background, ...etc) to allow for faster builds?
Note: Sources and binaries are too large in size to be placed in a ram file system and I don't want to change the directory structure or build philosophy.
You can try
make -j<number of jobs to run in parallel>
make -jN
is a must now that most machines are multi-core. If you don't want to write -jN
each time, you can put
export MAKEFLAGS=-jN
in your .bashrc
.
You may also want to checkout distcc.
If your project is becoming too big for one machine to handle, you can use one of the distributed make replacements, such as Electric Cloud.
If you want to run your build in parallel,
make -jN
does the job, but keep in mind:
N
should be equal to themaximum number of threads your machine supports
, if you enter a number greater than that,make
automatically makesN=maximum number of threads your machine supports
make
doesn't support parallel build using-jN
inMSDOS
, it just does a serial build. If you specify -jN
, it will downgradeN=1
.
Read more here, from the make
source: http://cmdlinelinux.blogspot.com/2014/04/parallel-build-using-gnu-make-j.html
精彩评论