diff options
author | Joel Rosdahl <joel@rosdahl.net> | 2010-01-05 20:43:18 +0100 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2010-01-06 22:23:10 +0100 |
commit | 42273c937f72802ad3b21abcd8886b5d5012368c (patch) | |
tree | c0e6bdbf674d55ed3a773c8c9aa2c2197485bf28 | |
parent | f98719bc9048dc72072c55cd5b5432493cc8a3b1 (diff) | |
download | ccache-42273c937f72802ad3b21abcd8886b5d5012368c.tar.gz |
Let compressed files get different hash sums than uncompressed
This is to avoid problems when older ccache versions (without compression
support) access the cache.
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | ccache.c | 9 | ||||
-rwxr-xr-x | test.sh | 35 |
3 files changed, 44 insertions, 6 deletions
@@ -84,12 +84,6 @@ Bug fixes: Compatibility notes: - - The object files cached by ccache are now stored compressed. ccache - understands old ccache directories (created by ccache versions without - compression support), but not the other way around. Thus, if you need to be - able to run both old and new ccache versions on the same ccache directory, - you have to tell ccache not to use compression by setting CCACHE_NOCOMPRESS. - - 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" @@ -701,6 +701,15 @@ static int find_hash(ARGS *args, enum findhash_call_mode mode) hash_start(&hash); + /* + * Let compressed files get a different hash sums 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 */ + } + /* when we are doing the unifying tricks we need to include the input file name in the hash to get the warnings right */ if (enable_unify) { @@ -792,6 +792,40 @@ EOF fi } +compression_suite() { + rm -rf $CCACHE_DIR + + ################################################################## + # Create some code to compile. + cat <<EOF >test.c +int test; +EOF + + ################################################################## + # Check that compressed and uncompressed files get different hash sums in + # order to maintain forward compatibility of previous ccache versions. + testname="compression hash sum" + $CCACHE $COMPILER -c test.c + checkstat 'cache hit (direct)' 0 + checkstat 'cache hit (preprocessed)' 0 + checkstat 'cache miss' 1 + + $CCACHE $COMPILER -c test.c + checkstat 'cache hit (direct)' 0 + 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 +} + ###################################################################### # main program @@ -820,6 +854,7 @@ nlevels4 nlevels1 direct basedir +compression " if [ -z "$suites" ]; then |