]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Require CCACHE_SLOPPINESS=pch_defines when creating precompiled header
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 16 Aug 2014 12:22:04 +0000 (14:22 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 16 Aug 2014 12:22:04 +0000 (14:22 +0200)
708d9110a103bd49437be7bff1e82697fff68d0b introduced the requirement of
sloppy pch_defines for using a PCH, but it's the act of creating (and
storing in the cache) a PCH that needs to be opt-in.

ccache.c
test.sh

index 8bdc8bdc397defa9956c21229f698638290894a9..f0dca22c7fc76b76ba716c3268241b328c6de5ef 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1758,8 +1758,7 @@ cc_process_args(struct args *orig_args, struct args **preprocessor_args,
 
        if (found_pch || found_fpch_preprocess) {
                using_precompiled_header = true;
-               if (!(sloppiness & SLOPPY_PCH_DEFINES)
-                   || !(sloppiness & SLOPPY_TIME_MACROS)) {
+               if (!(sloppiness & SLOPPY_TIME_MACROS)) {
                        cc_log("You have to specify \"pch_defines,time_macros\" sloppiness when"
                               " using precompiled headers to get direct hits");
                        cc_log("Disabling direct mode");
@@ -1788,6 +1787,14 @@ cc_process_args(struct args *orig_args, struct args **preprocessor_args,
        output_is_precompiled_header =
                actual_language && strstr(actual_language, "-header") != NULL;
 
+       if (output_is_precompiled_header && !(sloppiness & SLOPPY_PCH_DEFINES)) {
+               cc_log("You have to specify \"pch_defines,time_macros\" sloppiness when"
+                      " creating precompiled headers");
+               stats_update(STATS_CANTUSEPCH);
+               result = false;
+               goto out;
+       }
+
        if (!found_c_opt) {
                if (output_is_precompiled_header) {
                        args_add(stripped_args, "-c");
diff --git a/test.sh b/test.sh
index b4360e81da89968df685e561e765672c56f01ce6..4cad450d2c2727add3c68c4fd61e77cf01fe751e 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -1712,18 +1712,39 @@ EOF
     fi
 
     ##################################################################
-    # Tests for creating a .gch.
+    # Tests for creating a .gch without opt-in.
 
     backdate pch.h
 
-    testname="create .gch, -c, no -o"
+    testname="create .gch, -c, no -o, without opt-in"
     $CCACHE -zC >/dev/null
     $CCACHE $COMPILER -c pch.h
     checkstat 'cache hit (direct)' 0
     checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 0
+    checkstat "can't use precompiled header" 1
+
+    testname="create .gch, no -c, -o, without opt-in"
+    $CCACHE -Cz >/dev/null
+    $CCACHE $COMPILER pch.h -o pch.gch
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 0
+    checkstat "can't use precompiled header" 1
+
+    ##################################################################
+    # Tests for creating a .gch with opt-in.
+
+    backdate pch.h
+
+    testname="create .gch, -c, no -o, with opt-in"
+    $CCACHE -zC >/dev/null
+    CCACHE_SLOPPINESS=pch_defines,time_macros $CCACHE $COMPILER -c pch.h
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 0
     checkstat 'cache miss' 1
     rm -f pch.h.gch
-    $CCACHE $COMPILER -c pch.h
+    CCACHE_SLOPPINESS=pch_defines,time_macros $CCACHE $COMPILER -c pch.h
     checkstat 'cache hit (direct)' 1
     checkstat 'cache hit (preprocessed)' 0
     checkstat 'cache miss' 1
@@ -1731,13 +1752,13 @@ EOF
         test_failed "pch.h.gch missing"
     fi
 
-    testname="create .gch, no -c, -o"
+    testname="create .gch, no -c, -o, with opt-in"
     $CCACHE -Cz >/dev/null
-    $CCACHE $COMPILER pch.h -o pch.gch
+    CCACHE_SLOPPINESS=pch_defines,time_macros $CCACHE $COMPILER pch.h -o pch.gch
     checkstat 'cache hit (direct)' 0
     checkstat 'cache hit (preprocessed)' 0
     checkstat 'cache miss' 1
-    $CCACHE $COMPILER pch.h -o pch.gch
+    CCACHE_SLOPPINESS=pch_defines,time_macros $CCACHE $COMPILER pch.h -o pch.gch
     checkstat 'cache hit (direct)' 1
     checkstat 'cache hit (preprocessed)' 0
     checkstat 'cache miss' 1