summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS6
-rw-r--r--ccache.c9
-rwxr-xr-xtest.sh35
3 files changed, 44 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index 34180a08..afbd3cd4 100644
--- a/NEWS
+++ b/NEWS
@@ -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"
diff --git a/ccache.c b/ccache.c
index 29d74c7f..9b0571aa 100644
--- a/ccache.c
+++ b/ccache.c
@@ -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) {
diff --git a/test.sh b/test.sh
index e5787686..c5436c74 100755
--- a/test.sh
+++ b/test.sh
@@ -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