[ccache] [PATCH] Better cache reuse across builds in separate trees

Steve Bennett steveb at snapgear.com
Thu Apr 21 06:57:49 GMT 2005


Hi,

I use ccache here to speed up nightly builds across multiple similar
products with multiple versions.

One problem I found was that cache objects would not be reused when
building the same source file with the same options but in different
directory trees. It turned out that the problem was the use of __FILE__
in header files along with the use of absolute path names in
-I directives.

What happens is that the preprocessor output contains strings which
vary based on the location of the file being included. CCACHE_UNIFY
doesn't help here because the code really is different.

One solution is to use relative path names with -I, however this is not
possible in our build environment, unfortunately.

My solution was to make a small patch to cache which takes effect only
when CCACHE_UNIFY is enabled to convert include file paths from absolute
to relative just before running the preprocessor. This improved my cache
hit ratio dramatically with the added benefit of removing potentially
sensitive full path names from the resultant object code.

The patch is included here from your consideration. This is against 2.3,
but applies cleanly against 2.4

Regards,
Steve


More information about the ccache mailing list