DNA Cafe | Download | FreeSoftware | Java | Links
ccache is a compiler cache. It speeds up re-compilation of C/C++ code by caching previous compiles and detecting when the same compile is being done again.
There is just to prefix your compile commands with "ccache".
$ make CC="ccache cc"
You can change cc if you need.
When the same compilation is done a second time ccache is able to supply
the correct compiler output from the cache.
For example,
$ make CC="ccache cc" # 1st time
$ make CC="ccache cc" clean
$ make CC="ccache cc" # 2nd time
You just set the environment variable CCACHE_PREFIX to "distcc".
$ make CCACHE_PREFIX="distcc" CC=ccache
These options only apply when you invoke ccache as "ccache".
Statistics summary:
$ ccache -s
To clean cache and re-calculate:
$ ccache -c
To clear the entire cache:
$ ccache -C
To management cache size:
$ ccache -F size -M number_of_files_limits
By default ccache has a one gibibyte limit on the cache size and no maximum number of files.
A group of developers can increase the cache hit rate by sharing a cache directory.
To share a cache, the fllowing conditions need to be met:
For example,
$ groupadd -g 1234 ccache
$ vigr
ccache:*:1234:user
$ mkdir common_directory
$ chgrp ccache common_directory
$ chmod g+s common_directory
Now, you can use it. Use the same CCACHE_DIR environment variable setting, and the CCACHE_UNMASK sets the umask to share cache with other users. The CCACHE_LOGFILE is useful for tracking down proglems.
$ CCACHE_DIR=common_directory
$ CCACHE_UNMASK=002
$ CCACHE_LOGFILE=logfile
$ export CCACHE_DIR CCACHE_UNMASK CCACHE_LOGFILE
$ make CC="ccache cc"
distcc is a very useful program for distributing compilation across a range of compiler servers. It is often useful to combine distcc with ccache. To share a cache with distcc, the fllowing conditions need to be met:
You just need to set the environment variable CCACHE_PREFIX to 'distcc'.
$ export DISTCC_HOSTS="host_to_use_for_compilation ..."
$ export CCACHE_DIR=common_directory
$ export CCACHE_UMASK=002
$ export CCACHE_PREFIX=distcc
$ export CCACHE_LOGFILE=logfile
$ make -j4 CC="ccache cc"
Please refer to distcc note for the -j value.