]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Allow preprocessed hits even when using PCH
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 5 Sep 2010 13:17:40 +0000 (15:17 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 5 Sep 2010 13:17:40 +0000 (15:17 +0200)
ccache.c
test.sh

index ba069d3e2d1225ce903addce8eea7b671672d87f..4fe730def4c81dbba3b97c253390006a8954b071 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -877,7 +877,8 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
                   to the hash. The theory is that these arguments will change
                   the output of -E if they are going to have any effect at
                   all. For precompiled headers this might not be the case. */
-               if (!direct_mode && !output_is_precompiled_header) {
+               if (!direct_mode && !output_is_precompiled_header
+                   && !using_precompiled_header) {
                        if (compopt_affects_cpp(args->argv[i])) {
                                i++;
                                continue;
@@ -1830,10 +1831,6 @@ ccache(int argc, char *argv[])
                        /* Add object to manifest later. */
                        put_object_in_manifest = true;
                }
-       } else if (using_precompiled_header) {
-               cc_log("Direct mode must be enabled when using a precompiled header");
-               stats_update(STATS_CANTUSEPCH);
-               failed();
        }
 
        /*
@@ -1873,16 +1870,8 @@ ccache(int argc, char *argv[])
                put_object_in_manifest = true;
        }
 
-       if (using_precompiled_header) {
-               /*
-                * We must avoid a preprocessed hit when using a PCH. Otherwise, we would
-                * get a false hit if the PCH has changed (but the rest of the source has
-                * not) since the preprocessed output doesn't include the PCH content.
-                */
-       } else {
-               /* if we can return from cache at this point then do */
-               from_cache(FROMCACHE_CPP_MODE, put_object_in_manifest);
-       }
+       /* if we can return from cache at this point then do */
+       from_cache(FROMCACHE_CPP_MODE, put_object_in_manifest);
 
        if (getenv("CCACHE_READONLY")) {
                cc_log("Read-only mode; running real compiler");
diff --git a/test.sh b/test.sh
index 8995956d461989416a901616159c9e45e46dc335..290830ba038b3c92e10793cc66cff9cd3fbe0ddf 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -1669,14 +1669,6 @@ EOF
     rm -f pch.h
     backdate pch.h.gch
 
-    testname="preprocessor mode"
-    $CCACHE -Cz >/dev/null
-    CCACHE_NODIRECT=1 CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER -c -fpch-preprocess pch.c
-    checkstat 'cache hit (direct)' 0
-    checkstat 'cache hit (preprocessed)' 0
-    checkstat 'cache miss' 0
-    checkstat "can't use precompiled header" 1
-
     testname="no -fpch-preprocess, #include"
     $CCACHE -Cz >/dev/null
     $CCACHE $COMPILER -c pch.c 2>/dev/null
@@ -1731,10 +1723,31 @@ EOF
     backdate pch.h.gch
     CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER -c -fpch-preprocess pch.c
     checkstat 'cache hit (direct)' 1
-    # Shouldnt' get a preprocessed hit since the preprocessed output doesn't
-    # include the PCH header:
     checkstat 'cache hit (preprocessed)' 0
     checkstat 'cache miss' 2
+
+    testname="preprocessor mode"
+    $CCACHE -Cz >/dev/null
+    CCACHE_NODIRECT=1 CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER -c -fpch-preprocess pch.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 1
+    CCACHE_NODIRECT=1 CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER -c -fpch-preprocess pch.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 1
+    checkstat 'cache miss' 1
+
+    testname="preprocessor mode, file changed"
+    echo "updated" >>pch.h.gch # GCC seems to cope with this...
+    backdate pch.h.gch
+    CCACHE_NODIRECT=1 CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER -c -fpch-preprocess pch.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 1
+    checkstat 'cache miss' 2
+    CCACHE_NODIRECT=1 CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER -c -fpch-preprocess pch.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 2
+    checkstat 'cache miss' 2
 }
 
 ######################################################################