8.4 Using Ccache

Another excellent way of accelerating builds is to use the compiler cache, ccache. To use ccache support, you must first create a tar file with ccache and various symlinks within a opt/ directory. Your tarball contents should be:

opt/gcc -> ccache
opt/cc -> ccache
opt/g++ -> ccache
opt/c++ -> ccache

Tip: If ccache is installed on the Tinderbox host machine, ccache.tar is available in ${PREFIX}/share/ccache/.

This tarball must be called ccache.tar, and be placed in the Jail directory for each Jail that will use ccache (e.g. ${pb}/jails/9.2).

Note: If Tinderbox is configured to run builds for multiple versions of FreeBSD and/or multiple architectures (for example, i386 on amd64), it may be preferable to build the Tinderbox host ccache as a statically-linked binary. Otherwise, it will be necessary to ensure the ccache.tar contents are compiled for each architecture and FreeBSD version.

Once the tarball is created, run:

# ./tc configCcache -e -c /ccache -s 2G

Valid arguments for configCcache are:

Table 8-1. configCcache Options

-eEnable ccache
-dDisable ccache
-c /path/to/ccache/srcThe location relative to ${pb} where ccache data should be stored
-s [size]Maximum ccache cache size
-jPer-jail ccache
-JPer-build ccache
-l /path/to/logfilePath relative to ${pb} where ccache should log
-LDisable ccache logging

Then run your builds as you normally would. To debug ccache, add -l /ccache.log switch to the command.

Then, in the root of each build directory, there will be a ccache.log that will let you know if the cache is working.