ccache - a fast compiler cache
Go to file
2002-03-27 05:53:05 +01:00
args.c added some docs and comments ... 2002-03-27 00:58:31 +01:00
ccache.c handle -S with -c (it changes the default extension) 2002-03-27 05:53:05 +01:00
ccache.h made default CCACHE_DIR $HOME/.ccache to avoid some potential /tmp races 2002-03-27 04:53:22 +01:00
COPYING added some docs and comments ... 2002-03-27 00:58:31 +01:00
execute.c make the compile as atomic as possible 2002-03-27 01:39:06 +01:00
hash.c added some docs and comments ... 2002-03-27 00:58:31 +01:00
Makefile first version of C compilercache 2002-03-26 15:46:43 +01:00
mdfour.c added some docs and comments ... 2002-03-27 00:58:31 +01:00
mdfour.h first version of C compilercache 2002-03-26 15:46:43 +01:00
README made default CCACHE_DIR $HOME/.ccache to avoid some potential /tmp races 2002-03-27 04:53:22 +01:00
util.c handle a race in directory creation 2002-03-27 04:29:42 +01:00

This is a re-implementation of "compilercache" in C

The original compilercache scripts were by Erik Thiele
(erikyyy@erikyyy.de) and I would like to thank him for an excellent
piece of work. See http://www.erikyyy.de/compilercache/ for the
original shell scripts.

I wrote ccache because I wanted to get a bit more speed out of a
compiler cache and I wanted to remove some of the limitations of the
shell-script version.

Installation
------------

To install ccache first compile it, then place the "ccache" somewhere
in your path. You then need to create symbolic links from the ccache
executable to symlinks of the same name as your compiler. These
symlinks must come before the location of your real compiler in your
PATH.

For example the following will work on many systems:

  make ccache
  cp ccache /usr/local/bin
  ln -s /usr/local/bin/ccache /usr/local/bin/gcc
  ln -s /usr/local/bin/ccache /usr/local/bin/cc

This will work as long as /usr/local/bin comes before the path to gcc
(which is usually in /usr/bin). After installing you may wish to run
"rehash; type gcc" to make sure that the correct link is being used.

Configuration
-------------

Configuration of ccache is done via a number of environment
variables. In most cases you won't need any of these as the defaults
will be fine.

   CCACHE_DIR

   the CCACHE_DIR environment variable specifies where ccache will
   keep its cached compiler output. The default is "$HOME/.ccache". 


   CCACHE_LOGFILE

   If you set the CCACHE_LOGFILE environment variable then ccache will
   write some log information on cache hits and misses in that
   file. This is useful for tracking down problems.


   CCACHE_PATH

   You can optionally set CCACHE_PATH to a colon separated path where ccache will
   look for the real compilers. If you don't do this then ccache will
   look for the first executable in the normal PATH that isn't a link
   to ccache itself.


Differences
-----------

The biggest differences between Erik's compilercache script and ccache
are:

- ccache is written in C, which makes it a bit faster (calling out to
  external programs is mostly what slowed down the scripts).

- ccache can automatically find the real compiler on Linux

- ccache can cache compiler output that includes warnings. In many
  cases this gives ccache a much higher cache hit rate.

- ccache can handle argument lists with spaces

Note however that ccache is a very new piece of code (as of March
2002) whereas Erik's scripts have had a *lot* more testing. 

The overall speedup compared to compilercache is quite dramatic. For
compiling rsync I get:

  compilercache uncached 28.9 seconds
  compilercache cached 10.5 seconds

  ccache uncached 24.6 seconds
  ccache cached 4.6 seconds


How it works
------------

The basic idea is to detect when you are compiling exactly the same
code a 2nd time and use the previously compiled output. You detect
that it is the same code by forming a hash of:

  - the pre-processor output from running the compiler with -E
  - the command line options
  - the real compilers size and modification time
  - any stderr output generated by the compiler

===================
tridge@samba.org
March 2002

PS: I get far too much email to answer, so don't be surprised if you
have a hard time getting hold of me. You might try the
#samba-technical IRC channel on irc.openprojects.net if you need me
quickly.