Waiter: "Tea or coffee, gentlemen?" 1st customer: "I'll have tea." 2nd customer: "Me, too -- and be sure the glass is clean!" (Waiter exits, returns) Waiter: "Two teas. Which one asked for the clean glass?"
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++ code and the next time those parts are needed it copies them back into place, so that that part doesn't have 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 studioware chroot has 12G of max cache, with 11G used at the current time.
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.
Some code will from time to time not compile with ccache enabled. To turn it off temporarily, use 'CCACHE_DISABLE=1 make', or for whatever the compiler command you are using is. It rarely happens that code fails to build with it, but it can happen. See 'man ccache' for more options and environmental variables.