From: Joel Rosdahl Date: Sun, 5 Sep 2010 13:17:40 +0000 (+0200) Subject: Allow preprocessed hits even when using PCH X-Git-Tag: v3.1~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d5e98332544e29a4ea0e8c58462ce2d1776bd57;p=thirdparty%2Fccache.git Allow preprocessed hits even when using PCH --- diff --git a/ccache.c b/ccache.c index ba069d3e2..4fe730def 100644 --- a/ccache.c +++ b/ccache.c @@ -877,7 +877,8 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode) to the hash. The theory is that these arguments will change the output of -E if they are going to have any effect at all. For precompiled headers this might not be the case. */ - if (!direct_mode && !output_is_precompiled_header) { + if (!direct_mode && !output_is_precompiled_header + && !using_precompiled_header) { if (compopt_affects_cpp(args->argv[i])) { i++; continue; @@ -1830,10 +1831,6 @@ 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(); } /* @@ -1873,16 +1870,8 @@ ccache(int argc, char *argv[]) put_object_in_manifest = true; } - if (using_precompiled_header) { - /* - * We must avoid a preprocessed hit when using a PCH. Otherwise, we would - * get a false hit if the PCH has changed (but the rest of the source has - * not) since the preprocessed output doesn't include the PCH content. - */ - } else { - /* if we can return from cache at this point then do */ - from_cache(FROMCACHE_CPP_MODE, put_object_in_manifest); - } + /* if we can return from cache at this point then do */ + from_cache(FROMCACHE_CPP_MODE, put_object_in_manifest); if (getenv("CCACHE_READONLY")) { cc_log("Read-only mode; running real compiler"); diff --git a/test.sh b/test.sh index 8995956d4..290830ba0 100755 --- a/test.sh +++ b/test.sh @@ -1669,14 +1669,6 @@ EOF rm -f pch.h backdate pch.h.gch - testname="preprocessor mode" - $CCACHE -Cz >/dev/null - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER -c -fpch-preprocess pch.c - checkstat 'cache hit (direct)' 0 - checkstat 'cache hit (preprocessed)' 0 - checkstat 'cache miss' 0 - checkstat "can't use precompiled header" 1 - testname="no -fpch-preprocess, #include" $CCACHE -Cz >/dev/null $CCACHE $COMPILER -c pch.c 2>/dev/null @@ -1731,10 +1723,31 @@ EOF backdate pch.h.gch CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER -c -fpch-preprocess pch.c checkstat 'cache hit (direct)' 1 - # Shouldnt' get a preprocessed hit since the preprocessed output doesn't - # include the PCH header: checkstat 'cache hit (preprocessed)' 0 checkstat 'cache miss' 2 + + testname="preprocessor mode" + $CCACHE -Cz >/dev/null + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER -c -fpch-preprocess pch.c + checkstat 'cache hit (direct)' 0 + checkstat 'cache hit (preprocessed)' 0 + checkstat 'cache miss' 1 + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER -c -fpch-preprocess pch.c + checkstat 'cache hit (direct)' 0 + checkstat 'cache hit (preprocessed)' 1 + checkstat 'cache miss' 1 + + testname="preprocessor mode, file changed" + echo "updated" >>pch.h.gch # GCC seems to cope with this... + backdate pch.h.gch + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER -c -fpch-preprocess pch.c + checkstat 'cache hit (direct)' 0 + checkstat 'cache hit (preprocessed)' 1 + checkstat 'cache miss' 2 + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS=time_macros $CCACHE $COMPILER -c -fpch-preprocess pch.c + checkstat 'cache hit (direct)' 0 + checkstat 'cache hit (preprocessed)' 2 + checkstat 'cache miss' 2 } ######################################################################