Repository navigation
ccache
ccache is a fast C/C++ compiler cache.
To set it up
- install it using your distributions package manager or any other method
- tune the settings
- configure your build to use ccache
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.
- You should at least adapt sloppiness, to make it faster (see https://wiki.archlinux.org/title/ccache):
ccache --set-config=sloppiness=file_macro,locale,time_macros, and - to share cache across different build directories set base_dir (see https://ccache.dev/manual/4.5.1.html#_configuration_options)
to point to the parent of your
BIN_DIRs, e.g.ccache --set-config=base_dir=/opt/cfsif you have builds in/opt/cfs/release_MKLand/opt/cfs/release_netlib
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!
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.