To be is to do.
-- I. Kant To do is to be.
-- A. Sartre Yabba-Dabba-Doo!
-- F. Flinstone
Setting up CCache
Compiling can be a bit of a slog, and if you find yourself compiling the same code with little or no changes, or perhaps re-running a SlackBuild that failed on some trivial part, then ccache is probably for you.
What it does
Like the name suggests, ccache caches compiled C and C++ objects and the next time those parts are needed it copies them back into place, so that they don't need to be recompiled from scratch again. This can be an immense time-saver, but of course the extra speed comes at the expense of the extra HDD space needed for the cache.
The cache is located in ~/.ccache for each user that uses it. Therefore, for SlackBuilds, since they tend to be run by root it will be /root/.ccache. The size of the cache can be set using 'ccache -M', while -s will tell you some statistics. Note that the commands must be given by the user using it. I like a lot of cache - my build chroots have 15G of max cache at the moment.
Setting it up
Setting up ccache is very simple. We just need to symlink our C compilers to it. As root:
cd /usr/local/bin ln -s /usr/bin/ccache cc ln -s /usr/bin/ccache c++ ln -s /usr/bin/ccache gcc ln -s /usr/bin/ccache g++
Why /usr/local/bin? Because that is by default in our $PATH before /usr/bin, so that calls to the compilers will find our symlinks first.
That's pretty much it. Now sit back and forget about it, but keep a watch on the size of the cache used from time to time.
You may find code that will not compile with ccache enabled. To turn it off temporarily, use 'export CCACHE_DISABLE=1' before running make (or whichever build command you are using.) It rarely happens that code fails to build with it these days, but it has happened to me in the past.
See 'man 1 ccache' for more options and environmental variables.