In case you are unfamiliar with ccache, its a “compiler cache”. Compiling is primarily CPU intensive task. So, ccache caches compiled objects - so next time we compile same code, it reuses these objects thereby significantly speeding-up compilation.
I need to recompile Linux kernel usually several times a day, with different permutations of config settings. This almost forces a ‘make clean’ or ‘make mrproper’ which deletes all compiled objects in build tree and then we have to rebuild everything all over again. This takes enormous amount of time. ccache comes to rescue! I’m surprised why I didn’t use it earlier.
To use ccache to speedup Linux kernel compile, all I had to do was ‘yum install ccache’ on Fedora10 system. This automatically created all needed symlinks and PATH setting. After this do make O=build bzImage; make O=build modules as usual. First time you won’t notice any speed gain as ccache is simply building up its cache. Subsequently doing a rebuild ‘make clean; make’ will be significantly faster To monitor ccache stats, do:
cache directory /home/ngupta/.ccache cache hit 521 cache miss 729 called for link 37 preprocessor error 1 not a C/C++ file 895 autoconf compile/link 131 no input file 766 files in cache 1458 cache size 92.7 Mbytes max cache size 976.6 Mbytes
(Ah! how to stop blogger from messing with formatting!)
If you see cache hits not increasing while you are compiling (and this is not the first compile), this might mean that ccache currently contains useless compiled objects. In such cases, if cache size is already near max cache size, its better to clean-up ccache with:
and reset stats with:
and lastly, you can set limit on disk size used by ccache using:
e.g. ccache -M 1G sets max size to 1 GB – similarly you can use K, M or G suffix to specify size.
UPDATE On Fedora-13 system, the PATH is not automatically set after ‘yum install ccache’. However, symlinks from ccache to compiler names are still created. So, you just need to add /usr/lib64/ccache to your PATH manually.