[ccache] ccache direct mode

Joel Rosdahl joel at rosdahl.net
Thu Jan 7 12:41:04 MST 2010


On Thu, 7 Jan 2010 09:37:58 +1100
tridge at samba.org wrote:

>  > The basic idea of how to achieve this is finding out which files were
>  > included by the preprocessor and then storing the hash sums of those
>  > files in a file associated with the input file and compiler arguments.
> 
> How dependent is this on the compiler? Is the format of the include
> file names on different compilers (eg. sun compiler) consistent enough
> for this to be reliable?

If you mean the format used in the preprocessor output to indicate from
which files code comes from, then I don't know. I haven't investigated
other compilers than GCC, and I've only checked versions 3.3-4.3, so
earlier versions are left to check as well.

On the other hand, is ccache supposed to work with compilers that don't
behave like GCC? If so, I guess it should be possible to detect
GCC-ness in some way and select features accordingly.

> Also, does the hashtable used for included_files preserve the
> ordering? (the order of includes is also vital). Or do you rely on the
> hash of the file that does the #include changing for that?

The hashtable is unordered, and yes, I rely on the hash of the input
file to keep track of the ordering, and also of course on the include
file hashes. For a given manifest, the source file (and
therefore the order of the first level of include files) is known since
the manifest is looked up given the hash of the input file (and some
more information), and all other levels of include files are taken
care of using the same kind of reasoning. In other words, if the
include file order changes in some file, then the hash of that file
changes too, which leads to a cache miss. Which include files the
preprocessor reads is of course also a function of compiler options
like -I, but that is handled by also hashing those options when
computing the hash in direct mode. Do you see any potential problem
here?

Regards,
Joel


More information about the ccache mailing list