- Make sure you have
ccache
installed and configured. As the name suggests,ccache
dramatically speeds up subsequent compilations by caching the object files. In most new Fedora distros, its enabled by default. You can check it by doing$which gcc
. If it says something like/usr/lib/ccache/gcc
, you are all set up. If not, try google, :)
You can see see its status by issuing command$ccache -s
. Its good to set the cache amount a bigger than default, so$ccache -M 2G
will set the cache to 2GB which is enough for everyone. - Use
gcc
option-pipe
whenever possible. Self explanatory, it uses pipes instead of temporary files. - If you have dual core or quad core processor and a lot of RAM, you'll notice that while compiling, only a fraction of your processor and RAM gets used. This is because there is only one compile process running at a time. You can specify multiple
make
jobs by passing parameter like this$make -j 2
. Here, make will run at most 2 jobs at a time, taking full advantage of your multi-core CPU and RAM. Some argue on setting higher value, but I do not recommend it, as it likely to have negative effect because of the large amount of context switched in the CPU. People say that this approach leads to race conditions but I haven't bumped into any of that yet. - For Linux Kernel compilation, make sure you have
CONFIG_DEBUG_KERNEL
unset in.config
file. If set, this builds your kernel with debugging symbol making your kernel a lot bigger and significantly longer to build. It will make kernel debugging impossible though, but when you are in a hurry, this really makes more sense. Also strip the.config
file from any unnecessary drivers/modules you don't require, but this will require you to have a thorough knowledge about both your PC and running kernel. - For those with high speed network (ethernet or more), give a try to
distcc
, that distributes the compilation among multiple machine. The configuration is quite straight forward. Check the references section for details. - Try
tmpfs
. It enables you to mount any folder in your file system in RAM, so theoretically speeding up the compilation. Try mounting your build folder withtmpfs
like this$sudo mount -t tmpfs -o size=500M,mode=0777 tmpfs /usr/src/linux-build
.
References:
https://help.ubuntu.com/community/Kernel/Compile
http://www.linux.org/docs/ldp/howto/Modules/speedup.html
http://en.gentoo-wiki.com/wiki/Portage_TMPDIR_on_tmpfs
http://www.ibm.com/developerworks/linux/library/l-distcc.html