Tired of recompiling our C++ libprotobuf and RocksDB every time you switch branches across commits to the
vendor submodule? ccache is for you!
ccache is a "compiler cache". It's a wrapper on top of all the C compilers that caches compiler output and speeds up subsequent invocations for compiling inputs it's seen before (by file hash). By God, it works! After you've compiled a RocksDB version once, future compilations of that version will be much faster.
brew install ccache and the prepend the path it tells you to your
$PATH. This is not the output of
which ccache. The pre-pending is important because the ccache wrappers need to be found in the PATH before the real compilers.
After installation, do a
make clean; make build to populate the cache. Then, to check its magic, do
make clean; make build again - this time it should be a lot quicker.
Some ccache FYIs:
By default, ccache will use up to 5GB of disk space to store compilation artifacts. You can see the current usage with
ccache -s or force an immediate cleanup with
ccache -c. There' alsos a config file you can use to adjust the cache size to your liking.
There are a few environment variables (
MACOSX_DEPLOYMENT_TARGET comes to mind) that affect compilation but are not include in ccache's cache key. On the whole, though, it's quite good at keeping track of everything (env vars, compiler flags, compiler versions, os versions) that might affect the compiled output.
If you do see a weird build failure that seems like it should be fixed by setting some env var or upgrading Xcode, it's probably
ccache caching the broken build. You can bite the bullet and drop the entire cache with