ccache-1.9: description + notes


ccache is a compiler cache. It acts as a caching pre-processor to C/C++ compilers, using the -E compiler switch and a hash to detect when a compilation can be satisfied from cache. This often results in a 5 to 10 times speedup in common compilations.

The idea came from Erik Thiele wrote the original compilercache program as a bourne shell script. ccache is a re-implementation of Erik's idea in C with more features and better performance.

Latest release

The latest release is ccache 1.9. This release adds: You can get this release from the download directory

Why bother?

Why bother with a compiler cache? If you ever run "make clean; make" then you can probably benefit from ccache. It is very common for developers to do a clean build of a project for a whole host of reasons, and this throws away all the information from your previous compiles.

By using ccache you can get exactly the same effect as "make clean; make" but much faster. It also helps a lot when doing RPM builds, as RPM can make doing incremental builds tricky.

I put the effort into writing ccache for 2 reasons. The first is the Samba build farm ( which constantly does clean builds of Samba on about 30 machines after each CVS commit. On some of those machines the build took over an hour. By using ccache we get the same effect as clean builds but about 6 times faster.

The second reason is the autobuild system I run for Quantum. That system builds our whole Linux based OS from scratch after every CVS commit to catch compilation problems quickly. Using ccache those builds are much faster.

Is it safe?

Yes. The most important aspect of a compiler cache is to always produce exactly the same output that the real compiler would produce. The includes providing exactly the same object files and exactly the same compiler warnings that would be produced if you use the real compiler. The only way you should be able to tell that you are using ccache is the speed.

I have coded ccache very carefully to try to provide these guarantees.



See the manual page


Here are some results for compiling Samba on my Linux laptop. I have also included the results of using Erik's compilercache program (version 1.0.10) for comparison.

ccache compilercache
normal 13m 4s 13m 4s
uncached 13m 15s 15m 41s
cached 2m 45s 4m 26s

How to use it

You can use ccache in two ways. The first is just to prefix your compile commands with "ccache". For example, you could change the "CC=gcc" line in your Makefile to be "CC=ccache gcc".

Alternatively, you can create symbolic links from your compilers name to ccache. This allows you to use ccache without any changes to your build system.

To auto-install this package, go back and click on the respective install icon.