From 890bb7312b04393d0ab2c92ddaacd810b4398d27 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Thu, 2 Sep 2010 22:43:24 +0200 Subject: [PATCH] Also require time_macros sloppiness when detecting PCH from .gch --- ccache.c | 18 +++++++++++------- test.sh | 13 ++++++++----- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/ccache.c b/ccache.c index 910c934da..10177f61f 100644 --- 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 3adb5dd9d..32e388e06 100755 --- 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 -- 2.47.3