]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add "can't use precompiled header" statistics
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 5 Sep 2010 09:05:04 +0000 (11:05 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 5 Sep 2010 09:44:09 +0000 (11:44 +0200)
MANUAL.txt
ccache.c
ccache.h
stats.c
test.sh

index 352d168fb518cace94d44e54cbd7c7e1138f381a..fbc9d7656f11369cbda91ee1734d4a67292ef3be 100644 (file)
@@ -735,6 +735,11 @@ problems and what may be done to increase the hit rate:
   doesn't support that. Compile the source code files separately if possible.
 * If ``unsupported compiler option'' has been incremented, enable debug logging
   and check which option was rejected.
+* If ``preprocessor error'' has been incremented, one possible reason is that
+  precompiled headers are being used. See <<_precompiled_headers,PRECOMPILED
+  HEADERS>> for how to remedy this.
+* If ``can't use precompiled header'' has been incremented, see
+  <<_precompiled_headers,PRECOMPILED HEADERS>>.
 
 
 Errors when compiling with ccache
index 3b221987b650af18eb8eb775b129031dca222127..fffb5186432986e36dd848de5ffd73d03019f7b8 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -183,6 +183,11 @@ static bool compile_preprocessed_source_code;
 /* Whether the output is a precompiled header */
 static bool output_is_precompiled_header = false;
 
+/*
+ * Whether we are using a precompiled header (either via -include or #include).
+ */
+static bool using_precompiled_header = false;
+
 /* How long (in microseconds) to wait before breaking a stale lock. */
 unsigned lock_staleness_limit = 2000000;
 
@@ -1494,12 +1499,16 @@ 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 (found_pch || found_fpch_preprocess) {
+               using_precompiled_header = true;
+               if (!(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");
+                       stats_update(STATS_CANTUSEPCH);
+                       result = false;
+                       goto out;
+               }
        }
 
        if (explicit_language && str_eq(explicit_language, "none")) {
@@ -1823,6 +1832,10 @@ 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();
        }
 
        /*
index e58626e22fe6822aabfd735586402daad033c5c4..9977f60d1734f9652c1128aee9006cb1e8675626 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -46,6 +46,7 @@ enum stats {
        STATS_EMPTYOUTPUT = 24,
        STATS_BADEXTRAFILE = 25,
        STATS_COMPCHECK = 26,
+       STATS_CANTUSEPCH = 27,
 
        STATS_END
 };
diff --git a/stats.c b/stats.c
index c2261419925568a7a3b9bd47ee2528ca82426295..1494007f612fccc0be964947328f8568a31c86c6 100644 (file)
--- a/stats.c
+++ b/stats.c
@@ -82,6 +82,7 @@ static struct {
        { STATS_TOTALSIZE,    "cache size                     ", display_size , FLAG_NOZERO|FLAG_ALWAYS },
        { STATS_MAXFILES,     "max files                      ", NULL, FLAG_NOZERO },
        { STATS_MAXSIZE,      "max cache size                 ", display_size, FLAG_NOZERO },
+       { STATS_CANTUSEPCH,   "can't use precompiled header   ", NULL, 0 },
        { STATS_NONE, NULL, NULL, 0 }
 };
 
diff --git a/test.sh b/test.sh
index 26b34afa9660c0ab98b3119699b56f9733741f0c..1bd05ad346e18b811d82bbf173da996b1397ed34 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -1693,11 +1693,8 @@ EOF
     $CCACHE $COMPILER -c -fpch-preprocess pch.c
     checkstat 'cache hit (direct)' 0
     checkstat 'cache hit (preprocessed)' 0
-    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
+    checkstat 'cache miss' 0
+    checkstat "can't use precompiled header" 1
 
     testname="-fpch-preprocess, sloppy time macros"
     $CCACHE -zC >/dev/null