]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Force new hash sums
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 21 Feb 2010 09:03:42 +0000 (10:03 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 21 Feb 2010 17:18:03 +0000 (18:18 +0100)
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.

NEWS
ccache.c
test.sh

diff --git a/NEWS b/NEWS
index cbb6fa414aa3e69cd4e7336c1ff81b452146ef07..9d05dba349f43d02fa242334d1989396b4961077 100644 (file)
--- 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.
index 9c29888ded5b98359551a6a79eef3bad4ebbcb7c..8d70a74f5af03a4e5ea5c5802bb9521f9b490534 100644 (file)
--- 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 d3a5a4e21e322a769b8bf80a0e6b5a1347695cf3..a689cc04ae2f7e6fa7834ce9f7a2bcb2f91d0771 100755 (executable)
--- 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
 }
 
 ######################################################################