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.
This commit is contained in:
Joel Rosdahl 2010-02-21 10:03:42 +01:00
parent ce92d74175
commit 5ea294ef76
3 changed files with 20 additions and 17 deletions

8
NEWS
View File

@ -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.

View File

@ -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 */

10
test.sh
View File

@ -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
}
######################################################################