How it works?
How to install it?
Easy on Ubuntu:
$ sudo apt-get install ccache
Then change you PATH to point to the Ccache gcc (not just gcc) version:
$ export PATH="/usr/lib/ccache:$PATH"
$ which gcc
How can I know if it works?
You can re-compile something and check if CCache is working with ccache -s command, you should have some cache hits:
$ ccache --max-size=5G
Troubleshooting: Re-compiling Linux kernel never hit the cache?
Check if the flag CONFIG_LOCALVERSION_AUTO is set in you menuconfig, disable it and try again.This flag seems to change a core header file as it appends the git version to the version string automatically, forcing CCache to recompile almost it all.
CCache with Icecc (edited):
If you want to use CCache with Icecc (that I'll explain about it in another post) to speed up even more your compilation time, use CCACHE_PREFIX=icecc (thanks Joel Rosdahl who commented about this)
NOTE: You don't need to add icecc
/usr/lib/icecc/bin in your PATH