Skip to content
Florian Toth edited this page Feb 13, 2022 · 2 revisions

ccache is a fast C/C++ compiler cache.

To set it up

  1. install it using your distributions package manager or any other method
  2. tune the settings
  3. configure your build to use ccache

settings

Settings can be configured by config file or environment variables. To set values in /home/$USER/.ccache/ccache.conf run ccache --set-config=KEY=VALUE.

configure CFS to use ccache

One option to activate ccache is to put symlinks to it (e.g. ln -s ccache /usr/local/bin/gcc) into your PATH such that ccache is called instead of the compilers, see https://ccache.dev/manual/4.5.1.html#_run_modes. Then cleanly configure (into an empty build dir) to activate ccache.

When using cmake there is another option: configure with -DCMAKE_CXX_COMPILER_LAUNCHER=ccache, see CMake docs. Attention: This option is only read on first configure!

Tips for usage

The first run will not be faster, but once the cache is built you can expect a significant boost. To try it out run

cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ~/openCFS/CFS
make
make clean
make

The second make should be way (factor 10) faster.

To check if ccache is working you can show the stats of ccache with ccache -s. Look for the number of _cache hit_s, it should increase on the second run.

Different generators do not seem to share the cache well, e.g. cache generated when building with GNU make cannot efficiently used on a subsequent run with Ninja.

Clone this wiki locally