diff options
author | Luboš Luňák <l.lunak@centrum.cz> | 2019-05-20 21:18:16 +0200 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2019-05-20 21:18:16 +0200 |
commit | 2f89ccfccd3f6ac087874a43893b0d376ad332a0 (patch) | |
tree | 16a3bfcedecaf77dfc5176c3e1b65992fb649b3e | |
parent | 6821579c2c2567415ed4d8a442e14860ab102f83 (diff) | |
download | ccache-2f89ccfccd3f6ac087874a43893b0d376ad332a0.tar.gz |
Fix PCH detection in depend mode (+test improvements) (#427)
* do not refer to Clang's PTH in tests
The PTH feature has been removed (https://reviews.llvm.org/D54547)
and according to the commit it has never really been used. Maybe this
made sense somewhen in the past, but now those .pth files must be PCHs
internally. This commit actually just changes the .pth extensions
to .pch to avoid confusion, technically nothing should change
except for filenames.
* try to share PCH tests between GCC and Clang
Clang is supposed to be a drop-in for GCC, so in general it should
be able to handle everything GCC can. That's not completely true
in practice, there are differences, but it doesn't make sense
to completely duplicate a testcase just because there are some
differences. So start creating a shared common base for the PCH
tests and do separately only tests that act differently.
* more sharing of PCH tests between GCC and Clang
There's e.g. no need to do all kinds of complex tests with both
.gch and .pch with Clang, except for checking that Clang finds
one of them if none is specified explicitly.
* log also when pch usage is detect from pragma pch_preprocess
* try harder to verify in tests that ccache detects PCH changes
Some of the tests did that, e.g. those 'file changed', but e.g. the cached
.gch creation did not. So try to intentionally change the .gch/.h and test
that it leads to a cache miss. Otherwise there might be a hit simply
because ccache failed to detect PCH usage and ignores the .gch completely.
* clean up #include vs -fpch-preprocess in pch tests
As the manpage says, -fpch-preprocess is needed only with the #include
form, otherwise it's pointless.
* do not mention sloppiness in pch tests, only no sloppiness
Since sloppiness is normally required, so no point in stating the obvious.
* test also -include-pch with clang
* hash also pch introduced only using -include
GCC does not output the pch in the .d dependencies file, so without
this there would be false cache hits.
* be consistent about sloppiness in pch tests
create pch -> pch_defines
use pch -> time_macros
* test CCACHE_PCH_EXTSUM more thoroughly and also with -include
* pch test for .gch file being in an extra directory
* doc corrections for how to use PCH with ccache
- ccache will fail to properly detect that -include a.h means using
a.h.gch if it requires using path from -I (they are not searched)
- -fpch-preprocess does nothing with Clang, it doesn't output
pragma GCC pch_preprocess and so #include form for PCHs doesn't work
* explain better problems of -MD/-MMD in depend mode
-rw-r--r-- | doc/MANUAL.adoc | 12 | ||||
-rw-r--r-- | src/ccache.c | 12 | ||||
-rw-r--r-- | test/suites/pch.bash | 608 |
3 files changed, 393 insertions, 239 deletions
diff --git a/doc/MANUAL.adoc b/doc/MANUAL.adoc index eac87344..a62d6870 100644 --- a/doc/MANUAL.adoc +++ b/doc/MANUAL.adoc @@ -943,8 +943,10 @@ Disadvantages: or source code will make the hash different. Compare this with the default setup where ccache will fall back to the preprocessor mode, which is tolerant to some types of changes of compiler options and source code changes. -* The manifest entries will include system header files as well, thus slowing - down cache hits slightly. +* (If -MD is used) The manifest entries will include system header files as well, + thus slowing down cache hits slightly, just as using -MD slows down make. +* (If -MMD is used) The manifest entries will not include system header files, + which means ccache will ignore changes in them. The depend mode will be disabled if any of the following holds: @@ -1058,10 +1060,12 @@ things to make it work properly: + -- ** use the *-include* compiler option to include the precompiled header - (i.e., don't use *#include* in the source code to include the header); or + (i.e., don't use *#include* in the source code to include the header), + the filename itself must be sufficient to find the header (i.e. -I paths + are not searched); or ** (for the Clang compiler) use the *-include-pch* compiler option to include the PCH file generated from the precompiled header; or -** add the *-fpch-preprocess* compiler option when compiling. +** (for the GCC compiler) add the *-fpch-preprocess* compiler option when compiling. If you don't do this, either the non-precompiled version of the header file will be used (if available) or ccache will fall back to running the real diff --git a/src/ccache.c b/src/ccache.c index becadff5..7c3b8364 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -695,6 +695,9 @@ remember_include_file(char *path, struct hash *cpp_hash, bool system, bool is_pch = is_precompiled_header(path); if (is_pch) { + if (!included_pch_file) { + cc_log("Detected use of precompiled header: %s", path); + } bool using_pch_sum = false; if (conf->pch_external_checksum) { // hash pch.sum instead of pch when it exists @@ -1162,6 +1165,15 @@ object_hash_from_depfile(const char *depfile, struct hash *hash) fclose(f); + // Explicitly check the .gch/.pch/.pth file, it may not be mentioned + // in the dependencies output. + if (included_pch_file) { + char *pch_path = x_strdup(included_pch_file); + pch_path = make_relative_path(pch_path); + hash_string(hash, pch_path); + remember_include_file(pch_path, hash, false, NULL); + } + bool debug_included = getenv("CCACHE_DEBUG_INCLUDED"); if (debug_included) { print_included_files(stdout); diff --git a/test/suites/pch.bash b/test/suites/pch.bash index 12138d15..0f365623 100644 --- a/test/suites/pch.bash +++ b/test/suites/pch.bash @@ -31,15 +31,20 @@ EOF } SUITE_pch() { - # Clang and GCC handle precompiled headers similarly, but GCC is much more - # forgiving with precompiled headers. Both GCC and Clang keep an absolute - # path reference to the original file except that Clang uses that reference - # to validate the pch and GCC ignores the reference. Also, Clang has an - # additional feature: pre-tokenized headers. For these reasons, Clang - # should be tested differently from GCC. Clang can only use pch or pth - # headers on the command line and not as an #include statement inside a - # source file. - + # Clang should generally be compatible with GCC and so most of the tests + # can be shared. There are some differences though: + # - Both GCC and Clang keep an absolute path reference to the original + # file except that Clang uses that reference to validate the pch and GCC + # ignores the reference (i.e. the original file can be removed). + # - Clang can only use pch headers on the command line and not as an #include + # statement inside a source file, because it silently ignores -fpch-preprocess + # and does not output pragma GCC pch_preprocess. + # - Clang has -include-pch to directly include a PCH file without any magic + # of searching for a .gch file. + # + # Therefore have common tests and do dedicated tests only for differences. + + pch_suite_common if $COMPILER_TYPE_CLANG; then pch_suite_clang else @@ -47,7 +52,7 @@ SUITE_pch() { fi } -pch_suite_gcc() { +pch_suite_common() { # ------------------------------------------------------------------------- TEST "Create .gch, -c, no -o, without opt-in" @@ -81,41 +86,49 @@ pch_suite_gcc() { expect_stat 'cache miss' 1 expect_file_exists pch.h.gch + echo '#include <string.h> /*change pch*/' >>pch.h + backdate pch.h + rm pch.h.gch + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch.h + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 2 + expect_file_exists pch.h.gch + # ------------------------------------------------------------------------- TEST "Create .gch, no -c, -o, with opt-in" - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT pch.h -o pch.gch + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT pch.h -o pch.gch expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT pch.h -o pch.gch + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT pch.h -o pch.gch expect_stat 'cache hit (direct)' 1 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 expect_file_exists pch.gch # ------------------------------------------------------------------------- - TEST "Use .gch, no -fpch-preprocess, #include" + TEST "Use .gch, #include, remove pch.h" $REAL_COMPILER $SYSROOT -c pch.h backdate pch.h.gch rm pch.h - $CCACHE_COMPILE $SYSROOT -c pch.c + $CCACHE_COMPILE $SYSROOT -c pch.c 2>/dev/null expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 0 # Preprocessor error because GCC can't find the real include file when - # trying to preprocess: + # trying to preprocess (gcc -E will be called by ccache): expect_stat 'preprocessor error' 1 # ------------------------------------------------------------------------- - TEST "Use .gch, no -fpch-preprocess, -include, no sloppiness" + TEST "Use .gch, -include, no sloppiness" $REAL_COMPILER $SYSROOT -c pch.h backdate pch.h.gch - rm pch.h $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c expect_stat 'cache hit (direct)' 0 @@ -125,11 +138,10 @@ pch_suite_gcc() { expect_stat "can't use precompiled header" 1 # ------------------------------------------------------------------------- - TEST "Use .gch, no -fpch-preprocess, -include, sloppiness" + TEST "Use .gch, -include" $REAL_COMPILER $SYSROOT -c pch.h backdate pch.h.gch - rm pch.h CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c expect_stat 'cache hit (direct)' 0 @@ -141,106 +153,339 @@ pch_suite_gcc() { expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 + echo '#include <string.h> /*change pch*/' >>pch.h + backdate pch.h + $REAL_COMPILER $SYSROOT -c pch.h + backdate pch.h.gch + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 2 + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c + expect_stat 'cache hit (direct)' 2 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 2 + # ------------------------------------------------------------------------- - TEST "Use .gch, -fpch-preprocess, #include, no sloppiness" + TEST "Use .gch, preprocessor mode, -include" $REAL_COMPILER $SYSROOT -c pch.h backdate pch.h.gch - rm pch.h - $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 - # Must enable sloppy time macros: - expect_stat "can't use precompiled header" 1 + expect_stat 'cache miss' 1 + + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache hit (preprocessed)' 1 + expect_stat 'cache miss' 1 + + echo '#include <string.h> /*change pch*/' >>pch.h + backdate pch.h + $REAL_COMPILER $SYSROOT -c pch.h + backdate pch.h.gch + + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache hit (preprocessed)' 1 + expect_stat 'cache miss' 2 + + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache hit (preprocessed)' 2 + expect_stat 'cache miss' 2 + + # ------------------------------------------------------------------------- + TEST "Create .gch, -c, -o" + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch.h -o pch.h.gch + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 + rm -f pch.h.gch + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch.h -o pch.h.gch + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 + expect_file_exists pch.h.gch + + echo '#include <string.h> /*change pch*/' >>pch.h + backdate pch.h + rm pch.h.gch + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch.h -o pch.h.gch + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 2 + expect_file_exists pch.h.gch # ------------------------------------------------------------------------- - TEST "Use .gch, -fpch-preprocess, #include, sloppiness" + TEST "Use .gch, -include, PCH_EXTSUM=1" $REAL_COMPILER $SYSROOT -c pch.h backdate pch.h.gch - rm pch.h - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + echo "original checksum" > pch.h.gch.sum + + CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c expect_stat 'cache hit (direct)' 1 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 + echo "other checksum" > pch.h.gch.sum + CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 2 + + echo "original checksum" > pch.h.gch.sum + CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c + expect_stat 'cache hit (direct)' 2 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 2 + + # With GCC, a newly generated PCH is always different, even if the contents should be exactly the same. + # And Clang stores file timestamps, so in this case the PCH is different too. + # So without .sum a "changed" PCH would mean a miss, but if the .sum doesn't change, it should be a hit. + + sleep 1 + touch pch.h + $REAL_COMPILER $SYSROOT -c pch.h + backdate pch.h.gch + + CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c + expect_stat 'cache hit (direct)' 3 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 2 + # ------------------------------------------------------------------------- - TEST "Use .gch, -fpch-preprocess, #include, file changed" + TEST "Use .gch, -include, no PCH_EXTSUM" $REAL_COMPILER $SYSROOT -c pch.h backdate pch.h.gch - rm pch.h - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + echo "original checksum" > pch.h.gch.sum + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 + + # external checksum not used, so no cache miss when changed + echo "other checksum" > pch.h.gch.sum + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c + expect_stat 'cache hit (direct)' 2 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 + + # ------------------------------------------------------------------------- + TEST "Use .gch, -include, other dir for .gch" + + mkdir -p dir + $REAL_COMPILER $SYSROOT -c pch.h -o dir/pch.h.gch + backdate dir/pch.h.gch + rm -f pch.h.gch + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch2.c + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch2.c + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 + + echo '#include <string.h> /*change pch*/' >>pch.h + backdate pch.h + $REAL_COMPILER $SYSROOT -c pch.h -o dir/pch.h.gch + backdate dir/pch.h.gch + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch2.c + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 2 + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch2.c + expect_stat 'cache hit (direct)' 2 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 2 + rm -rf dir + + # ------------------------------------------------------------------------- + TEST "Use .gch, preprocessor mode, -include, other dir for .gch" + + mkdir -p dir + $REAL_COMPILER $SYSROOT -c pch.h -o dir/pch.h.gch + backdate dir/pch.h.gch + rm -f pch.h.gch + + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch.c + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 + + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch.c + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache hit (preprocessed)' 1 + expect_stat 'cache miss' 1 + + echo '#include <string.h> /*change pch*/' >>pch.h + backdate pch.h + $REAL_COMPILER $SYSROOT -c pch.h -o dir/pch.h.gch + backdate dir/pch.h.gch + + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch.c + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache hit (preprocessed)' 1 + expect_stat 'cache miss' 2 + + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include dir/pch.h pch.c + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache hit (preprocessed)' 2 + expect_stat 'cache miss' 2 + rm -rf dir + + # ------------------------------------------------------------------------- + TEST "Use .gch, depend mode, -include" + + $REAL_COMPILER $SYSROOT -c pch.h + backdate pch.h.gch + + CCACHE_DEPEND=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c -MD -MF pch.d expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + CCACHE_DEPEND=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c -MD -MF pch.d expect_stat 'cache hit (direct)' 1 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 - echo "updated" >>pch.h.gch # GCC seems to cope with this... + echo '#include <string.h> /*change pch*/' >>pch.h + backdate pch.h + $REAL_COMPILER $SYSROOT -c pch.h backdate pch.h.gch - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + CCACHE_DEPEND=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c -MD -MF pch.d expect_stat 'cache hit (direct)' 1 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 2 - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + CCACHE_DEPEND=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c -MD -MF pch.d expect_stat 'cache hit (direct)' 2 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 2 +} +pch_suite_gcc() { # ------------------------------------------------------------------------- - TEST "Use .gch, preprocessor mode" + TEST "Use .gch, -include, remove pch.h" $REAL_COMPILER $SYSROOT -c pch.h backdate pch.h.gch rm pch.h - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c - expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 1 + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 # ------------------------------------------------------------------------- - TEST "Use .gch, preprocessor mode, file changed" + TEST "Use .gch, #include, no sloppiness" $REAL_COMPILER $SYSROOT -c pch.h backdate pch.h.gch rm pch.h - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 1 + # Must enable sloppy time macros: + expect_stat "can't use precompiled header" 1 - echo "updated" >>pch.h.gch # GCC seems to cope with this... + # ------------------------------------------------------------------------- + TEST "Use .gch, #include" + + $REAL_COMPILER $SYSROOT -c pch.h backdate pch.h.gch + rm pch.h - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 + + echo '#include <string.h> /*change pch*/' >>pch.h + backdate pch.h + $REAL_COMPILER $SYSROOT -c pch.h + backdate pch.h.gch + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + expect_stat 'cache hit (direct)' 1 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 2 + + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + expect_stat 'cache hit (direct)' 2 + expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 2 - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + # ------------------------------------------------------------------------- + TEST "Use .gch, preprocessor mode, #include" + + $REAL_COMPILER $SYSROOT -c pch.h + backdate pch.h.gch + rm pch.h + + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 1 + + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 1 + expect_stat 'cache miss' 1 + + echo '#include <string.h> /*change pch*/' >>pch.h + backdate pch.h + $REAL_COMPILER $SYSROOT -c pch.h + backdate pch.h.gch + + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache hit (preprocessed)' 1 + expect_stat 'cache miss' 2 + + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + expect_stat 'cache hit (direct)' 0 + expect_stat 'cache hit (preprocessed)' 2 expect_stat 'cache miss' 2 # ------------------------------------------------------------------------- @@ -248,13 +493,13 @@ pch_suite_gcc() { mkdir pch.h.gch - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -x c-header -c pch.h -o pch.h.gch/foo + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -x c-header -c pch.h -o pch.h.gch/foo expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 rm pch.h.gch/foo - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -x c-header -c pch.h -o pch.h.gch/foo + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -x c-header -c pch.h -o pch.h.gch/foo expect_stat 'cache hit (direct)' 1 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 @@ -262,12 +507,12 @@ pch_suite_gcc() { backdate pch.h.gch/foo - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c expect_stat 'cache hit (direct)' 1 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 2 - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c expect_stat 'cache hit (direct)' 2 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 2 @@ -275,67 +520,81 @@ pch_suite_gcc() { echo "updated" >>pch.h.gch/foo # GCC seems to cope with this... backdate pch.h.gch/foo - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c expect_stat 'cache hit (direct)' 2 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 3 - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c expect_stat 'cache hit (direct)' 3 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 3 # ------------------------------------------------------------------------- - TEST "Use .gch, -fpch-preprocess, PCH_EXTSUM=1" + TEST "Use .gch, #include, PCH_EXTSUM=1" $REAL_COMPILER $SYSROOT -c pch.h backdate pch.h.gch echo "original checksum" > pch.h.gch.sum - CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 - CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c expect_stat 'cache hit (direct)' 1 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 echo "other checksum" > pch.h.gch.sum - CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c expect_stat 'cache hit (direct)' 1 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 2 echo "original checksum" > pch.h.gch.sum - CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c expect_stat 'cache hit (direct)' 2 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 2 + # With GCC, a newly generated PCH is always different, even if the contents should be exactly the same. + # And Clang stores file timestamps, so in this case the PCH is different too. + # So without .sum a "changed" PCH would mean a miss, but if the .sum doesn't change, it should be a hit. + + sleep 1 + touch pch.h + $REAL_COMPILER $SYSROOT -c pch.h + backdate pch.h.gch + + CCACHE_PCH_EXTSUM=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + expect_stat 'cache hit (direct)' 3 + expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache miss' 2 + # ------------------------------------------------------------------------- - TEST "Use .gch, -fpch-preprocess, no PCH_EXTSUM" + TEST "Use .gch, #include, no PCH_EXTSUM" $REAL_COMPILER $SYSROOT -c pch.h backdate pch.h.gch echo "original checksum" > pch.h.gch.sum - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c expect_stat 'cache hit (direct)' 1 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 # external checksum not used, so no cache miss when changed echo "other checksum" > pch.h.gch.sum - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c expect_stat 'cache hit (direct)' 2 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 @@ -343,53 +602,6 @@ pch_suite_gcc() { pch_suite_clang() { # ------------------------------------------------------------------------- - TEST "Create .gch, -c, no -o, without opt-in" - - $CCACHE_COMPILE $SYSROOT -c pch.h - expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 0 - expect_stat "can't use precompiled header" 1 - - # ------------------------------------------------------------------------- - TEST "Create .gch, no -c, -o, without opt-in" - - $CCACHE_COMPILE pch.h -o pch.gch - expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 0 - expect_stat "can't use precompiled header" 1 - - # ------------------------------------------------------------------------- - TEST "Create .gch, -c, no -o, with opt-in" - - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c pch.h - expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 1 - rm pch.h.gch - - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c pch.h - expect_stat 'cache hit (direct)' 1 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 1 - expect_file_exists pch.h.gch - - # ------------------------------------------------------------------------- - TEST "Create .gch, no -c, -o, with opt-in" - - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT pch.h -o pch.gch - expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 1 - - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT pch.h -o pch.gch - expect_stat 'cache hit (direct)' 1 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 1 - expect_file_exists pch.gch - - # ------------------------------------------------------------------------- TEST "Create .gch, include file mtime changed" backdate test.h @@ -402,7 +614,7 @@ EOF # of the test.h include, otherwise we might not cache its ctime/mtime. sleep 1 - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c pch2.h + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch2.h expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 @@ -410,7 +622,7 @@ EOF touch test.h sleep 1 - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c pch2.h + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch2.h expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 2 @@ -418,18 +630,18 @@ EOF $REAL_COMPILER $SYSROOT -c -include pch2.h pch2.c expect_file_exists pch2.o - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c pch2.h + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines" $CCACHE_COMPILE $SYSROOT -c pch2.h expect_stat 'cache hit (direct)' 1 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 2 # ------------------------------------------------------------------------- - TEST "Use .gch, no -fpch-preprocess, -include, no sloppiness" + TEST "Use .pch, -include, no sloppiness" - $REAL_COMPILER $SYSROOT -c pch.h - backdate pch.h.gch + $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pch + backdate pch.h.pch - $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c 2>/dev/null + $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 0 @@ -437,190 +649,116 @@ EOF expect_stat "can't use precompiled header" 1 # ------------------------------------------------------------------------- - TEST "Use .gch, no -fpch-preprocess, -include, sloppiness" + TEST "Use .pch, -include" - $REAL_COMPILER $SYSROOT -c pch.h - backdate pch.h.gch + $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pch + backdate pch.h.pch - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c expect_stat 'cache hit (direct)' 1 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 - # ------------------------------------------------------------------------- - TEST "Use .gch, -fpch-preprocess, -include, file changed" - - $REAL_COMPILER $SYSROOT -c pch.h - backdate pch.h.gch - - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c - expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 1 - - echo "updated" >>pch.h.gch # clang seems to cope with this... - backdate pch.h.gch - - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c - expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 2 + echo '#include <string.h> /*change pch*/' >>pch.h + backdate pch.h + $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pch + backdate pch.h.pch - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c expect_stat 'cache hit (direct)' 1 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 2 # ------------------------------------------------------------------------- - TEST "Use .gch, preprocessor mode" + TEST "Use .pch, preprocessor mode, -include" - $REAL_COMPILER $SYSROOT -c pch.h - backdate pch.h.gch + $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pch + backdate pch.h.pch - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 1 expect_stat 'cache miss' 1 - # ------------------------------------------------------------------------- - TEST "Use .gch, preprocessor mode, file changed" - - $REAL_COMPILER $SYSROOT -c pch.h - backdate pch.h.gch - - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c - expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 1 - - echo "updated" >>pch.h.gch # clang seems to cope with this... - backdate pch.h.gch - - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c - expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 2 + echo '#include <string.h> /*change pch*/' >>pch.h + backdate pch.h + $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pch + backdate pch.h.pch - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 1 expect_stat 'cache miss' 2 - # ------------------------------------------------------------------------- - TEST "Create .pth, -c, -o" - - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c pch.h -o pch.h.pth - expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 1 - rm -f pch.h.pth - - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c pch.h -o pch.h.pth - expect_stat 'cache hit (direct)' 1 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 1 - expect_file_exists pch.h.pth - - # ------------------------------------------------------------------------- - TEST "Use .pth, no -fpch-preprocess, -include, no sloppiness" - - $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pth - backdate pch.h.pth - - $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch.c expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 0 - # Must enable sloppy time macros: - expect_stat "can't use precompiled header" 1 + expect_stat 'cache hit (preprocessed)' 2 + expect_stat 'cache miss' 2 # ------------------------------------------------------------------------- - TEST "Use .pth, no -fpch-preprocess, -include, sloppiness" + TEST "Use .pch, -include-pch" - $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pth - backdate pch.h.pth + $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pch + backdate pch.h.pch - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include-pch pch.h.pch pch2.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include-pch pch.h.pch pch2.c expect_stat 'cache hit (direct)' 1 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 - # ------------------------------------------------------------------------- - TEST "Use .pth, -fpch-preprocess, -include, file changed" - - $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pth - backdate pch.h.pth - - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c - expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 1 - - echo "updated" >>pch.h.pth # clang seems to cope with this... - backdate pch.h.pth - - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c - expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 2 + echo '#include <string.h> /*change pch*/' >>pch.h + backdate pch.h + $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pch + backdate pch.h.pch - CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c + CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include-pch pch.h.pch pch2.c expect_stat 'cache hit (direct)' 1 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 2 # ------------------------------------------------------------------------- - TEST "Use .pth, preprocessor mode" + TEST "Use .pch, preprocessor mode, -include-pch" - $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pth - backdate pch.h.pth + $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pch + backdate pch.h.pch - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include-pch pch.h.pch pch.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 0 expect_stat 'cache miss' 1 - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include-pch pch.h.pch pch.c expect_stat 'cache hit (direct)' 0 expect_stat 'cache hit (preprocessed)' 1 expect_stat 'cache miss' 1 - # ------------------------------------------------------------------------- - TEST "Use .pth, preprocessor mode, file changed" - - $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pth - backdate pch.h.pth - - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c - expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 1 - - echo "updated" >>pch.h.pth # clang seems to cope with this... - backdate pch.h.pth + echo '#include <string.h> /*change pch*/' >>pch.h + backdate pch.h + $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pch + backdate pch.h.pch - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include-pch pch.h.pch pch.c expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 0 + expect_stat 'cache hit (preprocessed)' 1 expect_stat 'cache miss' 2 - CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c + CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include-pch pch.h.pch pch.c expect_stat 'cache hit (direct)' 0 - expect_stat 'cache hit (preprocessed)' 1 + expect_stat 'cache hit (preprocessed)' 2 expect_stat 'cache miss' 2 } |