diff options
Diffstat (limited to 'test/suites/pch.bash')
-rw-r--r-- | test/suites/pch.bash | 608 |
1 files changed, 373 insertions, 235 deletions
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 } |