Ccache is a compiler cache which speeds up the compilation by caching the result of the previous compilation. If the same compilation is being done again it will retrieve the cached object files from the cache and it will use them without recompiling the code again. Potentially faster compilation times can be achieved when using ccache with TITAN. TITAN generates c++ code and ccache can cache the object files of the generated c++ code. It is advised to use ccache on development builds.
Installing ccache
On an Ubuntu 16.04 operating system the following command will install ccache:
sudo apt-get install ccache
or ccache can be built from source.
The source can be downloaded form https://ccache.samba.org/download.html
Configuring ccache
After installing ccache some configuration needs to be done to successfully use ccache.
1. The path of ccache needs to be added to the PATH variable:
export PATH="/usr/lib/ccache:$PATH
By adding the path of ccache to the beginning of the PATH variable, when g++ or gcc is called ccache will be called too. This way the makefiles does not need to be modified.
2. Set time_macros sloppines in ccache to achieve better results:
ccache --set-config=sloppiness=time_macros
This is needed because in the generated code the __DATE__ and __TIME__ macros are used and with the sloppiness ccache will ignore theese macros.
3. There is an option (-D) in the TITAN compiler which disables generation of user and time information into the files. This way the same c++ will be generated for the same TTCN3 project regardless of time and user. The makefiles has to be edited to use the -D flag in the COMPILER_FLAGS variable. The usage of this option is highly recommended.
After the configuring is done the project can be built the same as before. The invokation of g++ or gcc will also invoke ccache and the compilation time will be reduced from the second compilation.
Ccache keeps statistics about the performance of ccache. The ccache -s command outputs the statistics. This includes the number of cache hits, cache misses, unsupported compiler options and a lot more useful information.