]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Also require time_macros sloppiness when detecting PCH from .gch
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 2 Sep 2010 20:43:24 +0000 (22:43 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 2 Sep 2010 20:57:52 +0000 (22:57 +0200)
ccache.c
test.sh

index 910c934daac6b64ccfe1228409256fe1ff135e9e..10177f61f48029c60889500947ac3f639453801a 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1176,6 +1176,7 @@ cc_process_args(struct args *orig_args, struct args **preprocessor_args,
        bool found_S_opt = false;
        bool found_arch_opt = false;
        bool found_pch = false;
+       bool found_fpch_preprocess = false;
        const char *explicit_language = NULL; /* As specified with -x. */
        const char *file_language;            /* As deduced from file extension. */
        const char *actual_language;          /* Language to actually use. */
@@ -1232,13 +1233,8 @@ cc_process_args(struct args *orig_args, struct args **preprocessor_args,
                        }
                }
 
-               if (str_eq(argv[i], "-fpch-preprocess")
-                   && !(sloppiness & SLOPPY_TIME_MACROS)) {
-                       cc_log("You have to specify \"time_macros\" sloppiness when using"
-                              " -fpch-preprocess");
-                       stats_update(STATS_UNSUPPORTED);
-                       result = false;
-                       goto out;
+               if (str_eq(argv[i], "-fpch-preprocess")) {
+                       found_fpch_preprocess = true;
                }
 
                /* we must have -c */
@@ -1497,6 +1493,14 @@ cc_process_args(struct args *orig_args, struct args **preprocessor_args,
                goto out;
        }
 
+       if ((found_pch || found_fpch_preprocess)
+           && !(sloppiness & SLOPPY_TIME_MACROS)) {
+               cc_log("You have to specify \"time_macros\" sloppiness when using"
+                      " precompiled headers to get direct hits");
+               cc_log("Disabling direct mode");
+               enable_direct = false;
+       }
+
        if (explicit_language && str_eq(explicit_language, "none")) {
                explicit_language = NULL;
        }
diff --git a/test.sh b/test.sh
index 3adb5dd9d50020ee4591145add7d6912a4950b12..32e388e06a089a6d0d025c8e207c51e0a9b21435 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -1678,11 +1678,11 @@ EOF
 
     testname="no -fpch-preprocess, using -include"
     $CCACHE -z >/dev/null
-    $CCACHE $COMPILER -c -include pch.h pch2.c 2>/dev/null
+    CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER -c -include pch.h pch2.c 2>/dev/null
     checkstat 'cache hit (direct)' 0
     checkstat 'cache hit (preprocessed)' 0
     checkstat 'cache miss' 1
-    $CCACHE $COMPILER -c -include pch.h pch2.c 2>/dev/null
+    CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER -c -include pch.h pch2.c 2>/dev/null
     checkstat 'cache hit (direct)' 1
     checkstat 'cache hit (preprocessed)' 0
     checkstat 'cache miss' 1
@@ -1692,11 +1692,14 @@ EOF
     $CCACHE $COMPILER -c -fpch-preprocess pch.c
     checkstat 'cache hit (direct)' 0
     checkstat 'cache hit (preprocessed)' 0
-    checkstat 'cache miss' 0
-    checkstat 'unsupported compiler option' 1
+    checkstat 'cache miss' 1
+    $CCACHE $COMPILER -c -fpch-preprocess pch.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 1
+    checkstat 'cache miss' 1
 
     testname="-fpch-preprocess, sloppy time macros"
-    $CCACHE -z >/dev/null
+    $CCACHE -zC >/dev/null
     CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER -c -fpch-preprocess pch.c
     checkstat 'cache hit (direct)' 0
     checkstat 'cache hit (preprocessed)' 0