From: Joel Rosdahl Date: Sun, 5 Sep 2010 09:05:04 +0000 (+0200) Subject: Add "can't use precompiled header" statistics X-Git-Tag: v3.1~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f38abae7e6d1ef0cd268fdbe52180c32b1b549e0;p=thirdparty%2Fccache.git Add "can't use precompiled header" statistics --- diff --git a/MANUAL.txt b/MANUAL.txt index 352d168fb..fbc9d7656 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -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 diff --git a/ccache.c b/ccache.c index 3b221987b..fffb51864 100644 --- 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(); } /* diff --git a/ccache.h b/ccache.h index e58626e22..9977f60d1 100644 --- 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 c22614199..1494007f6 100644 --- 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 26b34afa9..1bd05ad34 100755 --- 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