diff --git a/NEWS b/NEWS index cbb6fa4..9d05dba 100644 --- a/NEWS +++ b/NEWS @@ -96,7 +96,15 @@ Bug fixes: Compatibility notes: + - The way the hashes are calculated has changed, so you won't get cache hits + for compilation results stored by older ccache versions. In fact, you might + as well clear the old cache directory if you want, unless if you plan to + keep using an older ccache version. + - The statistics counters "files in cache" and "cache size" now only include object files (previously, files containing cached standard error output were counted as well). Consequently, the "max file" and "max cache size" settings now specify thresholds for object files count and size. + + - Using ccache 3.0 and older ccache versions with the same cache directory + works OK, except that the statistics counters will be a bit messed up. diff --git a/ccache.c b/ccache.c index 9c29888..8d70a74 100644 --- a/ccache.c +++ b/ccache.c @@ -162,6 +162,15 @@ enum findhash_call_mode { FINDHASH_CPP_MODE }; +/* + * This is a string that identifies the current "version" of the hash sum + * computed by ccache. If, for any reason, we want to force the hash sum to be + * different for the same input in a new ccache version, we can just change + * this string. A typical example would be if the format of one of the files + * stored in the cache changes in a backwards-incompatible way. + */ +static const char HASH_PREFIX[] = "ccache3"; + /* something went badly wrong - just execute the real compiler */ @@ -708,15 +717,7 @@ static int find_hash(ARGS *args, enum findhash_call_mode mode) } hash_start(&hash); - - /* - * Let compressed files get a different hash sum than uncompressed - * files to avoid problems when older ccache versions (without - * compression support) access the cache. - */ - if (!getenv("CCACHE_NOCOMPRESS")) { - hash_buffer(&hash, "compression", 12); /* also hash NUL byte */ - } + hash_buffer(&hash, HASH_PREFIX, sizeof(HASH_PREFIX)); /* when we are doing the unifying tricks we need to include the input file name in the hash to get the warnings right */ diff --git a/test.sh b/test.sh index d3a5a4e..a689cc0 100755 --- a/test.sh +++ b/test.sh @@ -828,8 +828,7 @@ int test; EOF ################################################################## - # Check that compressed and uncompressed files get different hash sums in - # order to maintain forward compatibility of previous ccache versions. + # Check that compressed and uncompressed files get the same hash sum. testname="compression hash sum" $CCACHE $COMPILER -c test.c checkstat 'cache hit (direct)' 0 @@ -841,15 +840,10 @@ EOF checkstat 'cache hit (preprocessed)' 1 checkstat 'cache miss' 1 - CCACHE_NOCOMPRESS=1 $CCACHE $COMPILER -c test.c - checkstat 'cache hit (direct)' 0 - checkstat 'cache hit (preprocessed)' 1 - checkstat 'cache miss' 2 - CCACHE_NOCOMPRESS=1 $CCACHE $COMPILER -c test.c checkstat 'cache hit (direct)' 0 checkstat 'cache hit (preprocessed)' 2 - checkstat 'cache miss' 2 + checkstat 'cache miss' 1 } ######################################################################