From: Joel Rosdahl Date: Sun, 21 Feb 2010 09:03:42 +0000 (+0100) Subject: Force new hash sums X-Git-Tag: v3.0pre0~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ea294ef76877ed90e3695ab0eff323ea0db1489;p=thirdparty%2Fccache.git Force new hash sums All hash sums will from now on be different from those calculated by ccache 2.4, instead of only hash sums for compressed files. This makes hash sums for compressed and uncompressed files equal again, which reopens for conversion between compressed and uncompressed files, should the need arise. --- diff --git a/NEWS b/NEWS index cbb6fa414..9d05dba34 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 9c29888de..8d70a74f5 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 d3a5a4e21..a689cc04a 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 } ######################################################################