[ccache] Feature request: Hash the compiler by version and machine

Alexander Block ablock at blocksoftware.net
Tue Oct 28 14:55:24 GMT 2008


I'm currently working on a project that recompiles gcc before even 
starting with the actual project source. This means that in every 
rebuild, large parts of the project are compiled with a freshly compiled 

ccache currently checks differences in the used compiler version by 
either doing a size/modification-date hash or a full hash of the 
compiler binary (undocumented feature that I found). Both ways result in 
a cache miss for every source file when doing a full rebuild of our project.

A solution to this would be to add a new hashing mechanism that uses the 
output of "gcc -dumpversion" and "gcc -dumpmashine" to has the compiler 

A maybe more secure way (to avoid wrong cache hits) would be to use the 
output of "gcc --v", because it also includes the configure options used 
when compiling the gcc package. Problem with this is, that the output of 
--v includes absolute pathes (e.g. the --prefix option), which would 
again lead to cache misses if the whole project is recompiled in a 
different place. To avoid this, ccache could filter out all pathes from 
the output of --v...but this again could lead to wrong cache hits in 
special situations.

My suggestion would be to implement both solutions and use environment 
variables (as usual in ccache) to switch between the used hashing 
method. Also an option that enables/disables filtering of --v would be 

To Andrew (or other ccache developers):
Would you consider implementing these features? I'd be happy to do it by 
myself, but I would need to know if you generally accept patches and 
features from other developers.

To everyone:
Maybe you know a better way to fix problems like I've described above? 
Either by using existing features/options or new features/options.

Thanks and greetings,

More information about the ccache mailing list