Imported Upstream version 3.7.2 upstream/3.7.2
authorJinWang An <jinwang.an@samsung.com>
Tue, 3 Aug 2021 07:28:33 +0000 (16:28 +0900)
committerJinWang An <jinwang.an@samsung.com>
Tue, 3 Aug 2021 07:28:33 +0000 (16:28 +0900)
28 files changed:
LICENSE.html
autogen.sh
configure
configure.ac
dev.mk.in
doc/AUTHORS.adoc
doc/AUTHORS.html
doc/MANUAL.adoc
doc/MANUAL.html
doc/NEWS.adoc
doc/NEWS.html
doc/ccache.1
src/ccache.c
src/ccache.h
src/compopt.c
src/compopt.h
src/conf.c
src/confitems.c
src/confitems.h
src/counters.c
src/manifest.c
src/stats.c
src/version.c
test/run
test/suites/pch.bash
unittest/main.c
unittest/test_argument_processing.c
unittest/test_conf.c

index 35edf7ddd5c7367fb0e414e86f03b33642a353fe..5311e6192fbaf80fb052ddae731ee3645da893e3 100644 (file)
@@ -735,7 +735,7 @@ asciidoc.install(2);
 <body class="article">\r
 <div id="header">\r
 <h1>ccache copyright and license</h1>\r
-<span id="revnumber">version 3.7.1</span>\r
+<span id="revnumber">version 3.7.2</span>\r
 <div id="toc">
   <div id="toctitle">Table of Contents</div>
   <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
@@ -1235,9 +1235,9 @@ following license:</p></div>
 <div id="footnotes"><hr /></div>\r
 <div id="footer">\r
 <div id="footer-text">\r
-Version 3.7.1<br />\r
+Version 3.7.2<br />\r
 Last updated\r
- 2019-05-01 16:28:03 CEST\r
+ 2019-07-19 09:58:41 CEST\r
 </div>\r
 </div>\r
 </body>\r
index eb3d9ba12d50fd764e50a61c1d90fa5cb87adc17..00c9f52c85e44d129fc01eb336b6ccb6f321bde8 100755 (executable)
@@ -2,7 +2,19 @@
 
 set -e
 
-rm -f dev_mode_disabled
+if [ -f dev_mode_disabled ]; then
+    cat <<EOF >&2
+Error: It looks like you are building ccache from a release archive. If so,
+there is no need to run autoconf.sh. See INSTALL.md for further instructions.
+
+If you do want to the enable the development mode, delete the file
+dev_mode_disabled first, but it's probably a better idea to work with the
+proper ccache Git repository directly as described on
+<https://ccache.dev/repo.html>.
+EOF
+    exit 1
+fi
+
 autoheader
 autoconf
 echo "Now run ./configure and make"
index 7530d839b995d8ef4f50a6619082d6ffba235d8f..dbec97523f5f0eca89b96524b0cfbe6dc548b2fb 100755 (executable)
--- a/configure
+++ b/configure
@@ -6336,7 +6336,7 @@ fi
 
 mkdir -p .deps src unittest
 
-if test ! -f $srcdir/dev_mode_disabled && test "$RUN_FROM_BUILD_FARM" != yes; then
+if test ! -f $srcdir/dev_mode_disabled; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: developer mode enabled" >&5
 $as_echo "$as_me: developer mode enabled" >&6;}
     ac_config_files="$ac_config_files dev.mk"
index 903091aefa4bf11bb7fe179147073df4a61e7314..45c47991ec918536b91f22a0453112c1593a26bb 100644 (file)
@@ -208,7 +208,7 @@ fi
 mkdir -p .deps src unittest
 
 dnl Enable developer mode if dev.mk.in exists.
-if test ! -f $srcdir/dev_mode_disabled && test "$RUN_FROM_BUILD_FARM" != yes; then
+if test ! -f $srcdir/dev_mode_disabled; then
     AC_MSG_NOTICE(developer mode enabled)
     AC_CONFIG_FILES([dev.mk])
     include_dev_mk='include dev.mk'
index 80a2cd3ccff0d41e3925aebb06c088896fe1a853..da76797c9f6945dde61846ce46095e2de6c3d1e5 100644 (file)
--- a/dev.mk.in
+++ b/dev.mk.in
@@ -22,11 +22,8 @@ version := \
 
 dist_dir = ccache-$(version)
 dist_archives = \
-    ccache-$(version).tar.bz2 \
-    ccache-$(version).tar.gz
-ifneq ($(shell uname), Darwin)
-    dist_archives += ccache-$(version).tar.xz
-endif
+    ccache-$(version).tar.gz \
+    ccache-$(version).tar.xz
 
 generated_docs = \
     LICENSE.html \
@@ -62,7 +59,7 @@ headers = \
 generated_headers = \
     unittest/suites.h
 
-files_to_clean += *.tar.bz2 *.tar.gz *.tar.xz *.xml .deps/* perfdir.*
+files_to_clean += *.tar.gz *.tar.xz *.xml doc/*.xml .deps/* perfdir.*
 files_to_clean += compile_commands.json
 files_to_clean += src/confitems_lookup.c
 files_to_clean += src/envtoconfitems_lookup.c
@@ -145,7 +142,6 @@ $(dist_archives): $(dist_files)
        (cd $$tmpdir && \
         tarcompression= && \
         case $@ in \
-            *.bz2) tarcompression=-j ;; \
             *.gz) tarcompression=-z ;; \
             *.xz) tarcompression=-J ;; \
         esac && \
index e3ca5f631487db1d5c019beb91cd918f5090c66c..660eff484f53ac00a7a3dd8f90f1b99914f0101a 100644 (file)
@@ -49,6 +49,7 @@ ccache is a collective work with contributions from many people, including:
 * Leanid Chaika
 * Loïc Yhuel
 * Luboš Luňák
+* luzpaz
 * Maarten Maathuis
 * Mark Starovoytov
 * Martin Ettl
index ae849ab7f789c1c43aa027639f9f1b4170c3c575..306ab6ec28cbb0d31f7f7353b8b1779e29259a5d 100644 (file)
@@ -735,7 +735,7 @@ asciidoc.install(2);
 <body class="article">\r
 <div id="header">\r
 <h1>ccache authors</h1>\r
-<span id="revnumber">version 3.7.1</span>\r
+<span id="revnumber">version 3.7.2</span>\r
 <div id="toc">
   <div id="toctitle">Table of Contents</div>
   <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
@@ -965,6 +965,11 @@ Luboš Luňák
 </li>\r
 <li>\r
 <p>\r
+luzpaz\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
 Maarten Maathuis\r
 </p>\r
 </li>\r
@@ -1231,9 +1236,9 @@ Yvan Janssens
 <div id="footnotes"><hr /></div>\r
 <div id="footer">\r
 <div id="footer-text">\r
-Version 3.7.1<br />\r
+Version 3.7.2<br />\r
 Last updated\r
- 2019-05-01 16:28:03 CEST\r
+ 2019-07-19 09:58:41 CEST\r
 </div>\r
 </div>\r
 </body>\r
index bfafd3025ff3b14b41549274fb4dc4f0ad7457f3..2ca82c0c4ae241f358e13d84ffbf679b76ece7cf 100644 (file)
@@ -932,8 +932,11 @@ 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:
 
@@ -1046,11 +1049,14 @@ things to make it work properly:
 * You must either:
 +
 --
-** 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
+** use the *-include* compiler option to include the precompiled header (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
index 5782f21b7393b4418e1ecf3c2e0cc88c375c031a..3bfcdf09de93af6be201824c177ee456e7914328 100644 (file)
@@ -735,7 +735,7 @@ asciidoc.install(2);
 <body class="article">\r
 <div id="header">\r
 <h1>CCACHE(1)</h1>\r
-<span id="revnumber">version 3.7.1</span>\r
+<span id="revnumber">version 3.7.2</span>\r
 <div id="toc">
   <div id="toctitle">Table of Contents</div>
   <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
@@ -2163,8 +2163,15 @@ The cache hit rate will likely be lower since any change to compiler options
 </li>\r
 <li>\r
 <p>\r
-The manifest entries will include system header files as well, thus slowing\r
-  down cache hits slightly.\r
+If -MD is used, the manifest entries will include system header files as\r
+  well, thus slowing down cache hits slightly, just as using -MD slows down\r
+  make.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+If -MMD is used, the manifest entries will not include system header files,\r
+  which means ccache will ignore changes in them.\r
 </p>\r
 </li>\r
 </ul></div>\r
@@ -2367,8 +2374,10 @@ You must either:
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
-use the <strong>-include</strong> compiler option to include the precompiled header\r
-   (i.e., don&#8217;t use <strong>#include</strong> in the source code to include the header); or\r
+use the <strong>-include</strong> compiler option to include the precompiled header (i.e.,\r
+   don&#8217;t use <strong>#include</strong> in the source code to include the header; the filename\r
+   itself must be sufficient to find the header, i.e. <strong>-I</strong> paths are not\r
+   searched); or\r
 </p>\r
 </li>\r
 <li>\r
@@ -2379,7 +2388,8 @@ use the <strong>-include</strong> compiler option to include the precompiled hea
 </li>\r
 <li>\r
 <p>\r
-add the <strong>-fpch-preprocess</strong> compiler option when compiling.\r
+(for the GCC compiler) add the <strong>-fpch-preprocess</strong> compiler option when\r
+   compiling.\r
 </p>\r
 </li>\r
 </ul></div>\r
@@ -2736,9 +2746,9 @@ maintained by Joel Rosdahl. See AUTHORS.txt or AUTHORS.html and
 <div id="footnotes"><hr /></div>\r
 <div id="footer">\r
 <div id="footer-text">\r
-Version 3.7.1<br />\r
+Version 3.7.2<br />\r
 Last updated\r
- 2019-05-01 16:28:03 CEST\r
+ 2019-07-19 09:58:41 CEST\r
 </div>\r
 </div>\r
 </body>\r
index 10b9dd7e0aa411c91931533dc0b37cc96544555a..8661a3f88a0f3a249e552a9d3976ae08f0687f23 100644 (file)
@@ -1,6 +1,42 @@
 ccache news
 ===========
 
+ccache 3.7.2
+------------
+Release date: 2019-07-19
+
+Bug fixes
+~~~~~~~~~
+
+- The compiler option `-gdwarf*` no longer forces “run_second_cpp = true”.
+
+- Added verification that the value passed to the `-o/--set-config` option is
+  valid.
+
+- Fixed detection of precompiled headers in the depend mode.
+
+- Bail out on too hard Clang option `-ftime-trace`.
+
+- ccache now updates the correct stats file when adding/updating manifest
+  files. This bug previously made the file and size statistics counters
+  incorrect over time.
+
+- Fixed warnings from Clang about unused arguments during preprocessing.
+
+- Unknown manifest versions are now handled gracefully in `--dump-manifest`.
+
+- Fixed `make check` with “funny” locales.
+
+
+Documentation
+~~~~~~~~~~~~~
+
+- Added a hint about not running `autogen.sh` when building from a release
+  archive.
+
+- Mention that `xsltproc` is needed when building from the source repository.
+
+
 ccache 3.7.1
 ------------
 Release date: 2019-05-01
@@ -34,7 +70,7 @@ Changes
 
 - Compilations with /dev/null as the input file are now cached.
 
-- ccache has learned how to contruct the object filename if no `-o` option is
+- ccache has learned how to construct the object filename if no `-o` option is
   given and the source filename does not include a `.` or ends with a `.`.
 
 - Fixed a temporary file leak when the depend mode is enabled and the compiler
index 57e489cefce53f400a2e7788a0503449aea3ac94..6b0c6bb66133482f11e11d69ce77581d0ebf8c8b 100644 (file)
@@ -735,7 +735,7 @@ asciidoc.install(2);
 <body class="article">\r
 <div id="header">\r
 <h1>ccache news</h1>\r
-<span id="revnumber">version 3.7.1</span>\r
+<span id="revnumber">version 3.7.2</span>\r
 <div id="toc">
   <div id="toctitle">Table of Contents</div>
   <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
@@ -743,6 +743,76 @@ asciidoc.install(2);
 </div>\r
 <div id="content">\r
 <div class="sect1">\r
+<h2 id="_ccache_3_7_2">ccache 3.7.2</h2>\r
+<div class="sectionbody">\r
+<div class="paragraph"><p>Release date: 2019-07-19</p></div>\r
+<div class="sect2">\r
+<h3 id="_bug_fixes">Bug fixes</h3>\r
+<div class="ulist"><ul>\r
+<li>\r
+<p>\r
+The compiler option <code>-gdwarf*</code> no longer forces “run_second_cpp = true”.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Added verification that the value passed to the <code>-o/--set-config</code> option is\r
+  valid.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Fixed detection of precompiled headers in the depend mode.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Bail out on too hard Clang option <code>-ftime-trace</code>.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+ccache now updates the correct stats file when adding/updating manifest\r
+  files. This bug previously made the file and size statistics counters\r
+  incorrect over time.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Fixed warnings from Clang about unused arguments during preprocessing.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Unknown manifest versions are now handled gracefully in <code>--dump-manifest</code>.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Fixed <code>make check</code> with “funny” locales.\r
+</p>\r
+</li>\r
+</ul></div>\r
+</div>\r
+<div class="sect2">\r
+<h3 id="_documentation">Documentation</h3>\r
+<div class="ulist"><ul>\r
+<li>\r
+<p>\r
+Added a hint about not running <code>autogen.sh</code> when building from a release\r
+  archive.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Mention that <code>xsltproc</code> is needed when building from the source repository.\r
+</p>\r
+</li>\r
+</ul></div>\r
+</div>\r
+</div>\r
+</div>\r
+<div class="sect1">\r
 <h2 id="_ccache_3_7_1">ccache 3.7.1</h2>\r
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2019-05-01</p></div>\r
@@ -801,7 +871,7 @@ Compilations with /dev/null as the input file are now cached.
 </li>\r
 <li>\r
 <p>\r
-ccache has learned how to contruct the object filename if no <code>-o</code> option is\r
+ccache has learned how to construct the object filename if no <code>-o</code> option is\r
   given and the source filename does not include a <code>.</code> or ends with a <code>.</code>.\r
 </p>\r
 </li>\r
@@ -1134,7 +1204,7 @@ Made “./configure --without-bundled-zlib” do what’s intended.
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2018-09-02</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes">Bug fixes</h3>\r
+<h3 id="_bug_fixes_2">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1171,7 +1241,7 @@ Upgraded bundled zlib to version 1.2.11.
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2018-03-25</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_2">Bug fixes</h3>\r
+<h3 id="_bug_fixes_3">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1215,7 +1285,7 @@ Made it possible to perform out-of-source builds in dev mode again.
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2018-02-11</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_3">Bug fixes</h3>\r
+<h3 id="_bug_fixes_4">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1301,7 +1371,7 @@ Documented caveats related to colored warnings from compilers.
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_4">Bug fixes</h3>\r
+<h3 id="_bug_fixes_5">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1339,7 +1409,7 @@ Improved instructions on how to get cache hits between different working
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_5">Bug fixes</h3>\r
+<h3 id="_bug_fixes_6">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1365,7 +1435,7 @@ Documented how automatic cache cleanup works.
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_6">Bug fixes</h3>\r
+<h3 id="_bug_fixes_7">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1448,7 +1518,7 @@ Documented the different cache statistics counters.
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_7">Bug fixes</h3>\r
+<h3 id="_bug_fixes_8">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1478,7 +1548,7 @@ Fixed undefined behavior warnings in ccache found by <code>-fsanitize=undefined<
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2016-10-26</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_8">Bug fixes</h3>\r
+<h3 id="_bug_fixes_9">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1495,7 +1565,7 @@ ccache now detects usage of <code>.incbin</code> assembler directives in the sou
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2016-09-28</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_9">Bug fixes</h3>\r
+<h3 id="_bug_fixes_10">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1520,7 +1590,7 @@ Fixed a regression in ccache 3.3.1: ccache could get confused when using the
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2016-09-07</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_10">Bug fixes</h3>\r
+<h3 id="_bug_fixes_11">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1702,7 +1772,7 @@ Increased buffer size used when reading file data. This improves performance
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_11">Bug fixes</h3>\r
+<h3 id="_bug_fixes_12">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1728,7 +1798,7 @@ Fixed build and test for MinGW32 and Windows.
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2016-09-28</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_12">Bug fixes</h3>\r
+<h3 id="_bug_fixes_13">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1746,7 +1816,7 @@ Fixed a regression in ccache 3.2.8: ccache could get confused when using the
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2016-09-07</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_13">Bug fixes</h3>\r
+<h3 id="_bug_fixes_14">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1770,7 +1840,7 @@ ccache now understands the undocumented <code>-coverage</code> (only one dash) G
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2016-07-20</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_14">Bug fixes</h3>\r
+<h3 id="_bug_fixes_15">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1793,7 +1863,7 @@ ccache now knows how to work around a glitch in the output of GCC 6’s
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2016-07-12</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_15">Bug fixes</h3>\r
+<h3 id="_bug_fixes_16">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1843,7 +1913,7 @@ Made it harder to misinterpret documentation of boolean environment settings’
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_16">Bug fixes</h3>\r
+<h3 id="_bug_fixes_17">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1903,7 +1973,7 @@ The man page is now built when running “make install” from Git repository
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2015-10-08</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_17">Bug fixes</h3>\r
+<h3 id="_bug_fixes_18">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1958,7 +2028,7 @@ Added support for compiler option <code>-gsplit-dwarf</code>.
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_18">Bug fixes</h3>\r
+<h3 id="_bug_fixes_19">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2012,7 +2082,7 @@ Add support for caching code coverage results (compiling for gcov).
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_19">Bug fixes</h3>\r
+<h3 id="_bug_fixes_20">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2082,7 +2152,7 @@ Fixed build error when compiling ccache with recent Clang versions.
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2014-12-10</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_20">Bug fixes</h3>\r
+<h3 id="_bug_fixes_21">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2314,7 +2384,7 @@ Various other improvements of the test suite.
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_21">Bug fixes</h3>\r
+<h3 id="_bug_fixes_22">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2345,7 +2415,7 @@ Fixed test suite failures when <code>CC</code> is a ccache-wrapped compiler.
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2016-07-12</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_22">Bug fixes</h3>\r
+<h3 id="_bug_fixes_23">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2363,7 +2433,7 @@ Fixed a bug where (due to ccache rewriting paths) the compiler could choose
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2015-03-07</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_23">Bug fixes</h3>\r
+<h3 id="_bug_fixes_24">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2445,7 +2515,7 @@ Stale files in the internal temporary directory (<code>&lt;ccache_dir&gt;/tmp</c
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_24">Bug fixes</h3>\r
+<h3 id="_bug_fixes_25">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2485,7 +2555,7 @@ Fixed problem with logging of current working directory.
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2013-01-06</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_25">Bug fixes</h3>\r
+<h3 id="_bug_fixes_26">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2556,7 +2626,7 @@ Clang plugins are now hashed to catch plugin upgrades.
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_26">Bug fixes</h3>\r
+<h3 id="_bug_fixes_27">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2604,7 +2674,7 @@ Fixed <code>static_assert</code> macro definition clash with GCC 4.7.
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2012-01-08</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_27">Bug fixes</h3>\r
+<h3 id="_bug_fixes_28">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2687,7 +2757,7 @@ Rewrite argument to <code>--sysroot</code> if <code>CCACHE_BASEDIR</code> is use
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_28">Bug fixes</h3>\r
+<h3 id="_bug_fixes_29">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2740,7 +2810,7 @@ Improved order of statistics counters in <code>ccache -s</code> output.
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_29">Bug fixes</h3>\r
+<h3 id="_bug_fixes_30">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2773,7 +2843,7 @@ Systems that lack (and don’t need to be linked with) libm are now supported.
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2011-01-09</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_30">Bug fixes</h3>\r
+<h3 id="_bug_fixes_31">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2806,7 +2876,7 @@ The file handle in now correctly closed on write error when trying to create
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2010-11-28</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_31">Bug fixes</h3>\r
+<h3 id="_bug_fixes_32">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2833,7 +2903,7 @@ Portability fixes for HP-UX 11.00 and other esoteric systems.
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2010-11-21</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_32">Bug fixes</h3>\r
+<h3 id="_bug_fixes_33">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2881,7 +2951,7 @@ The test suite now also works on systems that lack a /dev/zero.
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2010-11-07</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_33">Bug fixes</h3>\r
+<h3 id="_bug_fixes_34">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3003,7 +3073,7 @@ Added <code>-install_name</code> as an option known to take an argument. (This i
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_34">Bug fixes</h3>\r
+<h3 id="_bug_fixes_35">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3089,7 +3159,7 @@ New <code>HACKING.txt</code> file with some notes about ccache code conventions.
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2010-07-15</p></div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_35">Bug fixes</h3>\r
+<h3 id="_bug_fixes_36">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3278,7 +3348,7 @@ The following options are no longer hashed in the preprocessor mode:
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_bug_fixes_36">Bug fixes</h3>\r
+<h3 id="_bug_fixes_37">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3423,9 +3493,9 @@ Statistics counters are now correctly updated for -E option failures and
 <div id="footnotes"><hr /></div>\r
 <div id="footer">\r
 <div id="footer-text">\r
-Version 3.7.1<br />\r
+Version 3.7.2<br />\r
 Last updated\r
- 2019-05-01 16:28:03 CEST\r
+ 2019-07-19 09:58:41 CEST\r
 </div>\r
 </div>\r
 </body>\r
index 932278556a8459500dfae7817a0ac94869a7cc0e..5c406577c12034215c4a8b5a2910a8aad2ce42f5 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: ccache
 .\"    Author: [see the "Author" section]
 .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
-.\"      Date: 05/01/2019
+.\"      Date: 07/19/2019
 .\"    Manual: ccache Manual
-.\"    Source: ccache 3.7.1
+.\"    Source: ccache 3.7.2
 .\"  Language: English
 .\"
-.TH "CCACHE" "1" "05/01/2019" "ccache 3\&.7\&.1" "ccache Manual"
+.TH "CCACHE" "1" "07/19/2019" "ccache 3\&.7\&.2" "ccache Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -1466,7 +1466,18 @@ The cache hit rate will likely be lower since any change to compiler options or
 .sp -1
 .IP \(bu 2.3
 .\}
-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\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+If \-MMD is used, the manifest entries will not include system header files, which means ccache will ignore changes in them\&.
 .RE
 .sp
 The depend mode will be disabled if any of the following holds:
@@ -1783,7 +1794,9 @@ use the
 \fB\-include\fR
 compiler option to include the precompiled header (i\&.e\&., don\(cqt use
 \fB#include\fR
-in the source code to include the header); or
+in the source code to include the header; the filename itself must be sufficient to find the header, i\&.e\&.
+\fB\-I\fR
+paths are not searched); or
 .RE
 .sp
 .RS 4
@@ -1807,7 +1820,7 @@ compiler option to include the PCH file generated from the precompiled header; o
 .sp -1
 .IP \(bu 2.3
 .\}
-add the
+(for the GCC compiler) add the
 \fB\-fpch\-preprocess\fR
 compiler option when compiling\&.
 .RE
index 251783acb9f6ba364430418b0afc913e059b399e..ca3b961ab671c2ea5ca5c5756425ab3da62b1e6c 100644 (file)
@@ -236,6 +236,9 @@ static char *cpp_stderr;
 // belongs (<cache_dir>/<x>/stats).
 char *stats_file = NULL;
 
+// The stats file to use for the manifest.
+static char *manifest_stats_file;
+
 // Whether the output is a precompiled header.
 bool output_is_precompiled_header = false;
 
@@ -692,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
@@ -1029,7 +1035,7 @@ process_preprocessed_file(struct hash *hash, const char *path, bool pump)
        free(data);
        free(cwd);
 
-       // Explicitly check the .gch/.pch/.pth file, Clang does not include any
+       // Explicitly check the .gch/.pch/.pth file as Clang does not include any
        // mention of it in the preprocessed output.
        if (included_pch_file) {
                char *pch_path = x_strdup(included_pch_file);
@@ -1159,6 +1165,15 @@ object_hash_from_depfile(const char *depfile, struct hash *hash)
 
        fclose(f);
 
+       // Explicitly check the .gch/.pch/.pth file as 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);
@@ -1221,6 +1236,7 @@ do_copy_or_move_file_to_cache(const char *source, const char *dest, bool copy)
                failed();
        }
        stats_update_size(
+               stats_file,
                file_size(&st) - (orig_dest_existed ? file_size(&orig_dest_st) : 0),
                orig_dest_existed ? 0 : 1);
 }
@@ -1340,11 +1356,15 @@ update_manifest_file(void)
        if (stat(manifest_path, &st) == 0) {
                old_size = file_size(&st);
        }
+
        MTR_BEGIN("manifest", "manifest_put");
        if (manifest_put(manifest_path, cached_obj_hash, included_files)) {
                cc_log("Added object file hash to %s", manifest_path);
                if (x_stat(manifest_path, &st) == 0) {
-                       stats_update_size(file_size(&st) - old_size, old_size == 0 ? 1 : 0);
+                       stats_update_size(
+                               manifest_stats_file,
+                               file_size(&st) - old_size,
+                               old_size == 0 ? 1 : 0);
                }
        } else {
                cc_log("Failed to add object file hash to %s", manifest_path);
@@ -2199,6 +2219,8 @@ calculate_object_hash(struct args *args, struct hash *hash, int direct_mode)
 
                char *manifest_name = hash_result(hash);
                manifest_path = get_path_in_cache(manifest_name, ".manifest");
+               manifest_stats_file =
+                       format("%s/%c/stats", conf->cache_dir, manifest_name[0]);
                free(manifest_name);
 
                cc_log("Looking for object file hash in %s", manifest_path);
@@ -2475,38 +2497,49 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
        const char *explicit_language = NULL; // As specified with -x.
        const char *file_language;            // As deduced from file extension.
        const char *input_charset = NULL;
+
        // Is the dependency makefile name overridden with -MF?
        bool dependency_filename_specified = false;
+
        // Is the dependency makefile target name specified with -MT or -MQ?
        bool dependency_target_specified = false;
+
        // Is the dependency target name implicitly specified using
        // DEPENDENCIES_OUTPUT or SUNPRO_DEPENDENCIES?
        bool dependency_implicit_target_specified = false;
+
        // expanded_args is a copy of the original arguments given to the compiler
        // but with arguments from @file and similar constructs expanded. It's only
        // used as a temporary data structure to loop over.
        struct args *expanded_args = args_copy(args);
-       // stripped_args essentially contains all original arguments except those
-       // that only should be passed to the preprocessor (if run_second_cpp is
-       // false) and except dependency options (like -MD and friends).
-       struct args *stripped_args = args_init(0, NULL);
-       // cpp_args contains arguments that were not added to stripped_args, i.e.
-       // those that should only be passed to the preprocessor if run_second_cpp is
-       // false. If run_second_cpp is true, they will be passed to the compiler as
-       // well.
+
+       // common_args contains all original arguments except:
+       // * those that never should be passed to the preprocessor,
+       // * those that only should be passed to the preprocessor (if run_second_cpp
+       //   is false), and
+       // * dependency options (like -MD and friends).
+       struct args *common_args = args_init(0, NULL);
+
+       // cpp_args contains arguments that were not added to common_args, i.e. those
+       // that should only be passed to the preprocessor if run_second_cpp is false.
+       // If run_second_cpp is true, they will be passed to the compiler as well.
        struct args *cpp_args = args_init(0, NULL);
-       // dep_args contains dependency options like -MD. They only passed to the
+
+       // dep_args contains dependency options like -MD. They are only passed to the
        // preprocessor, never to the compiler.
        struct args *dep_args = args_init(0, NULL);
 
-       bool found_color_diagnostics = false;
+       // compiler_only_args contains arguments that should only be passed to the
+       // compiler, not the preprocessor.
+       struct args *compiler_only_args = args_init(0, NULL);
 
+       bool found_color_diagnostics = false;
        bool found_directives_only = false;
        bool found_rewrite_includes = false;
 
        int argc = expanded_args->argc;
        char **argv = expanded_args->argv;
-       args_add(stripped_args, argv[0]);
+       args_add(common_args, argv[0]);
 
        bool result = true;
        for (int i = 1; i < argc; i++) {
@@ -2518,7 +2551,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                result = false;
                                goto out;
                        }
-                       args_add(stripped_args, argv[i]);
+                       args_add(common_args, argv[i]);
                        continue;
                }
 
@@ -2634,6 +2667,26 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        continue;
                }
 
+               // Handle options that should not be passed to the preprocessor.
+               if (compopt_affects_comp(argv[i])) {
+                       args_add(compiler_only_args, argv[i]);
+                       if (compopt_takes_arg(argv[i])) {
+                               if (i == argc - 1) {
+                                       cc_log("Missing argument to %s", argv[i]);
+                                       stats_update(STATS_ARGS);
+                                       result = false;
+                                       goto out;
+                               }
+                               args_add(compiler_only_args, argv[i + 1]);
+                               ++i;
+                       }
+                       continue;
+               }
+               if (compopt_prefix_affects_comp(argv[i])) {
+                       args_add(compiler_only_args, argv[i]);
+                       continue;
+               }
+
                if (str_eq(argv[i], "-fpch-preprocess")
                    || str_eq(argv[i], "-emit-pch")
                    || str_eq(argv[i], "-emit-pth")) {
@@ -2648,7 +2701,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
 
                // -S changes the default extension.
                if (str_eq(argv[i], "-S")) {
-                       args_add(stripped_args, argv[i]);
+                       args_add(common_args, argv[i]);
                        found_S_opt = true;
                        continue;
                }
@@ -2701,14 +2754,21 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                (debug_prefix_maps_len + 1) * sizeof(char *));
                        debug_prefix_maps[debug_prefix_maps_len++] =
                                x_strdup(&argv[i][argv[i][2] == 'f' ? 18 : 19]);
-                       args_add(stripped_args, argv[i]);
+                       args_add(common_args, argv[i]);
                        continue;
                }
 
                // Debugging is handled specially, so that we know if we can strip line
                // number info.
                if (str_startswith(argv[i], "-g")) {
-                       args_add(stripped_args, argv[i]);
+                       args_add(common_args, argv[i]);
+
+                       if (str_startswith(argv[i], "-gdwarf")) {
+                               // Selection of DWARF format (-gdwarf or -gdwarf-<version>) enables
+                               // debug info on level 2.
+                               generating_debuginfo = true;
+                               continue;
+                       }
 
                        char last_char = argv[i][strlen(argv[i]) - 1];
                        if (last_char == '0') {
@@ -2797,29 +2857,29 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                }
                if (str_eq(argv[i], "-fprofile-arcs")) {
                        profile_arcs = true;
-                       args_add(stripped_args, argv[i]);
+                       args_add(common_args, argv[i]);
                        continue;
                }
                if (str_eq(argv[i], "-ftest-coverage")) {
                        generating_coverage = true;
-                       args_add(stripped_args, argv[i]);
+                       args_add(common_args, argv[i]);
                        continue;
                }
                if (str_eq(argv[i], "-fstack-usage")) {
                        generating_stackusage = true;
-                       args_add(stripped_args, argv[i]);
+                       args_add(common_args, argv[i]);
                        continue;
                }
                if (str_eq(argv[i], "--coverage") // = -fprofile-arcs -ftest-coverage
                    || str_eq(argv[i], "-coverage")) { // Undocumented but still works.
                        profile_arcs = true;
                        generating_coverage = true;
-                       args_add(stripped_args, argv[i]);
+                       args_add(common_args, argv[i]);
                        continue;
                }
                if (str_startswith(argv[i], "-fprofile-dir=")) {
                        profile_dir = x_strdup(argv[i] + 14);
-                       args_add(stripped_args, argv[i]);
+                       args_add(common_args, argv[i]);
                        continue;
                }
                if (str_startswith(argv[i], "-fsanitize-blacklist=")) {
@@ -2827,13 +2887,13 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                sanitize_blacklists,
                                (sanitize_blacklists_len + 1) * sizeof(char *));
                        sanitize_blacklists[sanitize_blacklists_len++] = x_strdup(argv[i] + 21);
-                       args_add(stripped_args, argv[i]);
+                       args_add(common_args, argv[i]);
                        continue;
                }
                if (str_startswith(argv[i], "--sysroot=")) {
                        char *relpath = make_relative_path(x_strdup(argv[i] + 10));
                        char *option = format("--sysroot=%s", relpath);
-                       args_add(stripped_args, option);
+                       args_add(common_args, option);
                        free(relpath);
                        free(option);
                        continue;
@@ -2846,9 +2906,9 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                result = false;
                                goto out;
                        }
-                       args_add(stripped_args, argv[i]);
+                       args_add(common_args, argv[i]);
                        char *relpath = make_relative_path(x_strdup(argv[i+1]));
-                       args_add(stripped_args, relpath);
+                       args_add(common_args, relpath);
                        i++;
                        free(relpath);
                        continue;
@@ -2861,8 +2921,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                result = false;
                                goto out;
                        }
-                       args_add(stripped_args, argv[i]);
-                       args_add(stripped_args, argv[i+1]);
+                       args_add(common_args, argv[i]);
+                       args_add(common_args, argv[i+1]);
                        i++;
                        continue;
                }
@@ -2977,7 +3037,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        }
 
                        if (supported_profile_option) {
-                               args_add(stripped_args, arg);
+                               args_add(common_args, arg);
                                free(arg);
 
                                // If the profile directory has already been set, give up... Hard to
@@ -3002,17 +3062,17 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                    || str_eq(argv[i], "-fdiagnostics-color=always")
                    || str_eq(argv[i], "-fno-diagnostics-color")
                    || str_eq(argv[i], "-fdiagnostics-color=never")) {
-                       args_add(stripped_args, argv[i]);
+                       args_add(common_args, argv[i]);
                        found_color_diagnostics = true;
                        continue;
                }
                if (str_eq(argv[i], "-fdiagnostics-color=auto")) {
                        if (color_output_possible()) {
                                // Output is redirected, so color output must be forced.
-                               args_add(stripped_args, "-fdiagnostics-color=always");
+                               args_add(common_args, "-fdiagnostics-color=always");
                                cc_log("Automatically forcing colors");
                        } else {
-                               args_add(stripped_args, argv[i]);
+                               args_add(common_args, argv[i]);
                        }
                        found_color_diagnostics = true;
                        continue;
@@ -3062,8 +3122,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                args_add(cpp_args, argv[i]);
                                args_add(cpp_args, relpath);
                        } else {
-                               args_add(stripped_args, argv[i]);
-                               args_add(stripped_args, relpath);
+                               args_add(common_args, argv[i]);
+                               args_add(common_args, relpath);
                        }
                        free(relpath);
 
@@ -3083,7 +3143,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                        if (compopt_affects_cpp(option)) {
                                                args_add(cpp_args, new_option);
                                        } else {
-                                               args_add(stripped_args, new_option);
+                                               args_add(common_args, new_option);
                                        }
                                        free(new_option);
                                        free(relpath);
@@ -3108,8 +3168,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                args_add(cpp_args, argv[i]);
                                args_add(cpp_args, argv[i+1]);
                        } else {
-                               args_add(stripped_args, argv[i]);
-                               args_add(stripped_args, argv[i+1]);
+                               args_add(common_args, argv[i]);
+                               args_add(common_args, argv[i+1]);
                        }
 
                        i++;
@@ -3122,7 +3182,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                            || compopt_prefix_affects_cpp(argv[i])) {
                                args_add(cpp_args, argv[i]);
                        } else {
-                               args_add(stripped_args, argv[i]);
+                               args_add(common_args, argv[i]);
                        }
                        continue;
                }
@@ -3137,7 +3197,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                    && (stat(argv[i], &st) != 0 || !S_ISREG(st.st_mode))) {
                        cc_log("%s is not a regular file, not considering as input file",
                               argv[i]);
-                       args_add(stripped_args, argv[i]);
+                       args_add(common_args, argv[i]);
                        continue;
                }
 
@@ -3293,7 +3353,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
 
        if (!found_c_opt && !found_S_opt) {
                if (output_is_precompiled_header) {
-                       args_add(stripped_args, "-c");
+                       args_add(common_args, "-c");
                } else {
                        cc_log("No -c option found");
                        // I find that having a separate statistic for autoconf tests is useful,
@@ -3416,7 +3476,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
        if (!found_color_diagnostics && color_output_possible()) {
                if (guessed_compiler == GUESSED_CLANG) {
                        if (!str_eq(actual_language, "assembler")) {
-                               args_add(stripped_args, "-fcolor-diagnostics");
+                               args_add(common_args, "-fcolor-diagnostics");
                                cc_log("Automatically enabling colors");
                        }
                } else if (guessed_compiler == GUESSED_GCC) {
@@ -3425,7 +3485,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        // set (and not empty), so use that for detecting if GCC would use
                        // colors.
                        if (getenv("GCC_COLORS") && getenv("GCC_COLORS")[0] != '\0') {
-                               args_add(stripped_args, "-fdiagnostics-color");
+                               args_add(common_args, "-fdiagnostics-color");
                                cc_log("Automatically enabling colors");
                        }
                }
@@ -3462,7 +3522,9 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                output_su = make_relative_path(default_sufile_name);
        }
 
-       *compiler_args = args_copy(stripped_args);
+       *compiler_args = args_copy(common_args);
+       args_extend(*compiler_args, compiler_only_args);
+
        if (conf->run_second_cpp) {
                args_extend(*compiler_args, cpp_args);
        } else if (found_directives_only || found_rewrite_includes) {
@@ -3502,12 +3564,12 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
        // source.
        args_extend(cpp_args, dep_args);
 
-       *preprocessor_args = args_copy(stripped_args);
+       *preprocessor_args = args_copy(common_args);
        args_extend(*preprocessor_args, cpp_args);
 
 out:
        args_free(expanded_args);
-       args_free(stripped_args);
+       args_free(common_args);
        args_free(dep_args);
        args_free(cpp_args);
        return result;
@@ -3920,7 +3982,7 @@ ccache(int argc, char *argv[])
                        from_cache(FROMCACHE_DIRECT_MODE, 0);
 
                        // Wasn't able to return from cache at this point. However, the object
-                       // was already found in manifest, so don't readd it later.
+                       // was already found in manifest, so don't re-add it later.
                        put_object_in_manifest = false;
 
                        object_hash_from_manifest = object_hash;
@@ -4033,6 +4095,7 @@ ccache_main_options(int argc, char *argv[])
               != -1) {
                switch (c) {
                case DUMP_MANIFEST:
+                       initialize();
                        manifest_dump(optarg, stdout);
                        break;
 
index 66a98457b264d54c345b309bffda263045dff6bf..a2694d1a6112973e6a7aa10781e32ba5c3f8d97b 100644 (file)
@@ -224,7 +224,7 @@ unsigned stats_get_pending(enum stats stat);
 void stats_zero(void);
 void stats_summary(void);
 void stats_print(void);
-void stats_update_size(int64_t size, int files);
+void stats_update_size(const char *sfile, int64_t size, int files);
 void stats_get_obsolete_limits(const char *dir, unsigned *maxfiles,
                                uint64_t *maxsize);
 void stats_set_sizes(const char *dir, unsigned num_files, uint64_t total_size);
index 2106df3da1405280da6609662a039484acf877b6..413a1b37a17e1defcc416ea045003ddd04b73666 100644 (file)
 #include "ccache.h"
 #include "compopt.h"
 
+// The option it too hard to handle at all.
 #define TOO_HARD         (1 << 0)
+
+// The option it too hard for the direct mode.
 #define TOO_HARD_DIRECT  (1 << 1)
+
+// The option takes a separate argument, e.g. "-D FOO=1".
 #define TAKES_ARG        (1 << 2)
+
+// The option takes a concatenated argument, e.g. "-DFOO=1".
 #define TAKES_CONCAT_ARG (1 << 3)
+
+// The argument to the option is a path that may be rewritten if base_dir is
+// used.
 #define TAKES_PATH       (1 << 4)
+
+// The option only affects preprocessing; not passed to the compiler if
+// run_second_cpp is false.
 #define AFFECTS_CPP      (1 << 5)
 
+// The option only affects compilation; not passed to the preprocesor.
+#define AFFECTS_COMP (1 << 6)
+
 struct compopt {
        const char *name;
        int type;
@@ -56,19 +72,26 @@ static const struct compopt compopts[] = {
        {"-P",              TOO_HARD},
        {"-U",              AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG},
        {"-V",              TAKES_ARG},
-       {"-Xassembler",     TAKES_ARG},
+       {"-Wa,",            TAKES_CONCAT_ARG | AFFECTS_COMP},
+       {"-Werror",         AFFECTS_COMP}, // don't exit with error when preprocessing
+       {"-Wl,",            TAKES_CONCAT_ARG | AFFECTS_COMP},
+       {"-Xassembler",     TAKES_ARG | TAKES_CONCAT_ARG | AFFECTS_COMP},
        {"-Xclang",         TAKES_ARG},
-       {"-Xlinker",        TAKES_ARG},
+       {"-Xlinker",        TAKES_ARG | TAKES_CONCAT_ARG | AFFECTS_COMP},
        {"-Xpreprocessor",  AFFECTS_CPP | TOO_HARD_DIRECT | TAKES_ARG},
+       {"-all_load",       AFFECTS_COMP},
        {"-analyze",        TOO_HARD}, // clang
        {"-arch",           TAKES_ARG},
        {"-aux-info",       TAKES_ARG},
        {"-b",              TAKES_ARG},
+       {"-bind_at_load",   AFFECTS_COMP},
+       {"-bundle",         AFFECTS_COMP},
        {"-ccbin",          AFFECTS_CPP | TAKES_ARG}, // nvcc
        {"-fmodules",       TOO_HARD},
        {"-fno-working-directory", AFFECTS_CPP},
        {"-fplugin=libcc1plugin", TOO_HARD}, // interaction with GDB
        {"-frepo",          TOO_HARD},
+       {"-ftime-trace",    TOO_HARD}, // clang
        {"-fworking-directory", AFFECTS_CPP},
        {"-gtoggle",        TOO_HARD},
        {"-idirafter",      AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
@@ -86,9 +109,14 @@ static const struct compopt compopts[] = {
        {"-iwithprefixbefore",
         AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
        {"-ldir",           AFFECTS_CPP | TAKES_ARG}, // nvcc
+       {"-nolibc",         AFFECTS_COMP},
        {"-nostdinc",       AFFECTS_CPP},
        {"-nostdinc++",     AFFECTS_CPP},
        {"-odir",           AFFECTS_CPP | TAKES_ARG}, // nvcc
+       {"-pie",            AFFECTS_COMP},
+       {"-prebind",        AFFECTS_COMP},
+       {"-preload",        AFFECTS_COMP},
+       {"-rdynamic",       AFFECTS_COMP},
        {"-remap",          AFFECTS_CPP},
        {"-save-temps",     TOO_HARD},
        {"-save-temps=cwd", TOO_HARD},
@@ -171,6 +199,13 @@ compopt_affects_cpp(const char *option)
        return co && (co->type & AFFECTS_CPP);
 }
 
+bool
+compopt_affects_comp(const char *option)
+{
+       const struct compopt *co = find(option);
+       return co && (co->type & AFFECTS_COMP);
+}
+
 bool
 compopt_too_hard(const char *option)
 {
@@ -215,3 +250,13 @@ compopt_prefix_affects_cpp(const char *option)
        const struct compopt *co = find_prefix(option);
        return co && (co->type & TAKES_CONCAT_ARG) && (co->type & AFFECTS_CPP);
 }
+
+// Determines if the prefix of the option matches any option and affects the
+// preprocessor.
+bool
+compopt_prefix_affects_comp(const char *option)
+{
+       // Prefix options have to take concatenated args.
+       const struct compopt *co = find_prefix(option);
+       return co && (co->type & TAKES_CONCAT_ARG) && (co->type & AFFECTS_COMP);
+}
index d72639fe4d261f9a0eeb714093f679878feba581..4f1f760e9b86b4c70149412cc86d66a64d9187bf 100644 (file)
@@ -5,11 +5,13 @@
 
 bool compopt_short(bool (*fn)(const char *option), const char *option);
 bool compopt_affects_cpp(const char *option);
+bool compopt_affects_comp(const char *option);
 bool compopt_too_hard(const char *option);
 bool compopt_too_hard_for_direct_mode(const char *option);
 bool compopt_takes_path(const char *option);
 bool compopt_takes_arg(const char *option);
 bool compopt_takes_concat_arg(const char *option);
 bool compopt_prefix_affects_cpp(const char *option);
+bool compopt_prefix_affects_comp(const char *option);
 
 #endif // CCACHE_COMPOPT_H
index 0e76863a03de5bb47b1f275c492f22372e35db44..9ddd14c027a925d85a84db9e565a47cc3cd4ccd8 100644 (file)
@@ -192,7 +192,7 @@ conf_free(struct conf *conf)
 
 // Note: The path pointer is stored in conf, so path must outlive conf.
 //
-// On failure, if an I/O error occured errno is set appropriately, otherwise
+// On failure, if an I/O error occurred errno is set appropriately, otherwise
 // errno is set to zero indicating that config itself was invalid.
 bool
 conf_read(struct conf *conf, const char *path, char **errmsg)
@@ -300,6 +300,12 @@ conf_set_value_in_file(const char *path, const char *key, const char *value,
                return false;
        }
 
+       char dummy[8] = {0}; // The maximum entry size in struct conf.
+       if (!item->parser(value, (void *)dummy, errmsg)
+           || (item->verifier && !item->verifier(value, errmsg))) {
+               return false;
+       }
+
        FILE *infile = fopen(path, "r");
        if (!infile) {
                *errmsg = format("%s: %s", path, strerror(errno));
index f6fb89d29edf2b684abe2e26d4e3e016a375ad02..1c24464105fb3b610e3feb84e054ae46da962d8e 100644 (file)
@@ -18,9 +18,9 @@
 #include "ccache.h"
 
 static char *
-format_string(void *value)
+format_string(const void *value)
 {
-       char **str = (char **)value;
+       const char * const *str = (const char * const*)value;
        return x_strdup(*str);
 }
 
@@ -42,9 +42,9 @@ confitem_parse_bool(const char *str, void *result, char **errmsg)
 }
 
 char *
-confitem_format_bool(void *value)
+confitem_format_bool(const void *value)
 {
-       bool *b = (bool *)value;
+       const bool *b = (const bool *)value;
        return x_strdup(*b ? "true" : "false");
 }
 
@@ -58,7 +58,7 @@ confitem_parse_env_string(const char *str, void *result, char **errmsg)
 }
 
 char *
-confitem_format_env_string(void *value)
+confitem_format_env_string(const void *value)
 {
        return format_string(value);
 }
@@ -80,9 +80,9 @@ confitem_parse_double(const char *str, void *result, char **errmsg)
 }
 
 char *
-confitem_format_double(void *value)
+confitem_format_double(const void *value)
 {
-       double *x = (double *)value;
+       const double *x = (const double *)value;
        return format("%.1f", *x);
 }
 
@@ -101,9 +101,9 @@ confitem_parse_size(const char *str, void *result, char **errmsg)
 }
 
 char *
-confitem_format_size(void *value)
+confitem_format_size(const void *value)
 {
-       uint64_t *size = (uint64_t *)value;
+       const uint64_t *size = (const uint64_t *)value;
        return format_parsable_size_with_suffix(*size);
 }
 
@@ -153,9 +153,9 @@ confitem_parse_sloppiness(const char *str, void *result, char **errmsg)
 }
 
 char *
-confitem_format_sloppiness(void *value)
+confitem_format_sloppiness(const void *value)
 {
-       unsigned *sloppiness = (unsigned *)value;
+       const unsigned *sloppiness = (const unsigned *)value;
        char *s = x_strdup("");
        if (*sloppiness & SLOPPY_FILE_MACRO) {
                reformat(&s, "%sfile_macro, ", s);
@@ -206,7 +206,7 @@ confitem_parse_string(const char *str, void *result, char **errmsg)
 }
 
 char *
-confitem_format_string(void *value)
+confitem_format_string(const void *value)
 {
        return format_string(value);
 }
@@ -232,9 +232,9 @@ confitem_parse_umask(const char *str, void *result, char **errmsg)
 }
 
 char *
-confitem_format_umask(void *value)
+confitem_format_umask(const void *value)
 {
-       unsigned *umask = (unsigned *)value;
+       const unsigned *umask = (const unsigned *)value;
        if (*umask == UINT_MAX) {
                return x_strdup("");
        } else {
@@ -259,16 +259,16 @@ confitem_parse_unsigned(const char *str, void *result, char **errmsg)
 }
 
 char *
-confitem_format_unsigned(void *value)
+confitem_format_unsigned(const void *value)
 {
-       unsigned *i = (unsigned *)value;
+       const unsigned *i = (const unsigned *)value;
        return format("%u", *i);
 }
 
 bool
-confitem_verify_absolute_path(void *value, char **errmsg)
+confitem_verify_absolute_path(const void *value, char **errmsg)
 {
-       char **path = (char **)value;
+       const char * const *path = (const char * const *)value;
        assert(*path);
        if (str_eq(*path, "")) {
                // The empty string means "disable" in this case.
@@ -282,9 +282,9 @@ confitem_verify_absolute_path(void *value, char **errmsg)
 }
 
 bool
-confitem_verify_dir_levels(void *value, char **errmsg)
+confitem_verify_dir_levels(const void *value, char **errmsg)
 {
-       unsigned *levels = (unsigned *)value;
+       const unsigned *levels = (const unsigned *)value;
        assert(levels);
        if (*levels >= 1 && *levels <= 8) {
                return true;
index 3ac501eac6d2b9302e291760f97d15708c0ff81a..8b42caeafdb7396d3bb1c98e42cd520b2a9e8959 100644 (file)
@@ -4,8 +4,8 @@
 #include "system.h"
 
 typedef bool (*conf_item_parser)(const char *str, void *result, char **errmsg);
-typedef bool (*conf_item_verifier)(void *value, char **errmsg);
-typedef char *(*conf_item_formatter)(void *value);
+typedef bool (*conf_item_verifier)(const void *value, char **errmsg);
+typedef char *(*conf_item_formatter)(const void *value);
 
 struct conf_item {
        const char *name;
@@ -17,31 +17,31 @@ struct conf_item {
 };
 
 bool confitem_parse_bool(const char *str, void *result, char **errmsg);
-char *confitem_format_bool(void *value);
+char *confitem_format_bool(const void *value);
 
 bool confitem_parse_env_string(const char *str, void *result, char **errmsg);
-char *confitem_format_env_string(void *value);
+char *confitem_format_env_string(const void *value);
 
 bool confitem_parse_double(const char *str, void *result, char **errmsg);
-char *confitem_format_double(void *value);
+char *confitem_format_double(const void *value);
 
 bool confitem_parse_size(const char *str, void *result, char **errmsg);
-char *confitem_format_size(void *value);
+char *confitem_format_size(const void *value);
 
 bool confitem_parse_sloppiness(const char *str, void *result, char **errmsg);
-char *confitem_format_sloppiness(void *value);
+char *confitem_format_sloppiness(const void *value);
 
 bool confitem_parse_string(const char *str, void *result, char **errmsg);
-char *confitem_format_string(void *value);
+char *confitem_format_string(const void *value);
 
 bool confitem_parse_umask(const char *str, void *result, char **errmsg);
-char *confitem_format_umask(void *value);
+char *confitem_format_umask(const void *value);
 
 bool confitem_parse_unsigned(const char *str, void *result, char **errmsg);
-char *confitem_format_unsigned(void *value);
+char *confitem_format_unsigned(const void *value);
 
-bool confitem_verify_absolute_path(void *value, char **errmsg);
-bool confitem_verify_dir_levels(void *value, char **errmsg);
+bool confitem_verify_absolute_path(const void *value, char **errmsg);
+bool confitem_verify_dir_levels(const void *value, char **errmsg);
 
 const struct conf_item *confitems_get(const char *str, size_t len);
 size_t confitems_count(void);
index 1693c97d47ed8760ea36903fac254b0386b0a420..1441a4fb8b38379dd4c46d76a78448e94be00ee9 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2016 Joel Rosdahl
+// Copyright (C) 2010-2019 Joel Rosdahl
 //
 // This program is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by the Free
@@ -35,8 +35,10 @@ counters_init(size_t initial_size)
 void
 counters_free(struct counters *c)
 {
-       free(c->data);
-       free(c);
+       if (c) {
+               free(c->data);
+               free(c);
+       }
 }
 
 // Set a new size. New data entries are set to 0.
index 5e0bcac62520fd82879172476d54cf914a8bcddc..0b85e90686a87415fb4bd6baddd1d41bc50ca0c6 100644 (file)
@@ -224,27 +224,32 @@ create_empty_manifest(void)
 }
 
 static struct manifest *
-read_manifest(gzFile f)
+read_manifest(gzFile f, char **errmsg)
 {
+       *errmsg = NULL;
        struct manifest *mf = create_empty_manifest();
 
        uint32_t magic;
        READ_INT(4, magic);
        if (magic != MAGIC) {
-               cc_log("Manifest file has bad magic number %u", magic);
+               *errmsg = format("Manifest file has bad magic number %u", magic);
                goto error;
        }
 
        READ_BYTE(mf->version);
        if (mf->version != MANIFEST_VERSION) {
-               cc_log("Manifest file has unknown version %u", mf->version);
+               *errmsg = format(
+                       "Unknown manifest version (actual %u, expected %u)",
+                       mf->version,
+                       MANIFEST_VERSION);
                goto error;
        }
 
        READ_BYTE(mf->hash_size);
        if (mf->hash_size != 16) {
                // Temporary measure until we support different hash algorithms.
-               cc_log("Manifest file has unsupported hash size %u", mf->hash_size);
+               *errmsg =
+                       format("Manifest file has unsupported hash size %u", mf->hash_size);
                goto error;
        }
 
@@ -283,7 +288,9 @@ read_manifest(gzFile f)
        return mf;
 
 error:
-       cc_log("Corrupt manifest file");
+       if (!errmsg) {
+               *errmsg = x_strdup("Corrupt manifest file");
+       }
        free_manifest(mf);
        return NULL;
 }
@@ -592,9 +599,11 @@ manifest_get(struct conf *conf, const char *manifest_path)
                cc_log("Failed to gzdopen manifest file");
                goto out;
        }
-       mf = read_manifest(f);
+
+       char *errmsg;
+       mf = read_manifest(f, &errmsg);
        if (!mf) {
-               cc_log("Error reading manifest file");
+               cc_log("%s", errmsg);
                goto out;
        }
 
@@ -653,9 +662,12 @@ manifest_put(const char *manifest_path, struct file_hash *object_hash,
                        close(fd1);
                        goto out;
                }
-               mf = read_manifest(f1);
+               char *errmsg;
+               mf = read_manifest(f1, &errmsg);
                gzclose(f1);
                if (!mf) {
+                       cc_log("%s", errmsg);
+                       free(errmsg);
                        cc_log("Failed to read manifest file; deleting it");
                        x_unlink(manifest_path);
                        mf = create_empty_manifest();
@@ -741,9 +753,11 @@ manifest_dump(const char *manifest_path, FILE *stream)
                close(fd);
                goto out;
        }
-       mf = read_manifest(f);
+       char *errmsg;
+       mf = read_manifest(f, &errmsg);
        if (!mf) {
-               fprintf(stderr, "Error reading manifest file\n");
+               fprintf(stderr, "%s\n", errmsg);
+               free(errmsg);
                goto out;
        }
 
index f221d7bac7803c74f346bedff352a679e7c62d3f..ff3123a259939d3ec080e8e53ea7792688009ec7 100644 (file)
@@ -47,6 +47,7 @@ typedef char *(*format_fn)(uint64_t value);
 
 static char *format_size_times_1024(uint64_t size);
 static char *format_timestamp(uint64_t timestamp);
+static void stats_flush_to_file(const char *sfile, struct counters *updates);
 
 // Statistics fields in display order.
 static struct {
@@ -399,11 +400,21 @@ stats_collect(struct counters *counters, time_t *last_updated)
 // Record that a number of bytes and files have been added to the cache. Size
 // is in bytes.
 void
-stats_update_size(int64_t size, int files)
+stats_update_size(const char *sfile, int64_t size, int files)
 {
-       init_counter_updates();
-       counter_updates->data[STATS_NUMFILES] += files;
-       counter_updates->data[STATS_TOTALSIZE] += size / 1024;
+       struct counters *updates;
+       if (sfile == stats_file) {
+               init_counter_updates();
+               updates = counter_updates;
+       } else {
+               updates = counters_init(STATS_END);
+       }
+       updates->data[STATS_NUMFILES] += files;
+       updates->data[STATS_TOTALSIZE] += size / 1024;
+       if (sfile != stats_file) {
+               stats_flush_to_file(sfile, updates);
+               counters_free(updates);
+       }
 }
 
 // Read in the stats from one directory and add to the counters.
@@ -417,9 +428,9 @@ stats_read(const char *sfile, struct counters *counters)
        free(data);
 }
 
-// Write counter updates in counter_updates to disk.
-void
-stats_flush(void)
+// Write counter updates in updates to sfile.
+static void
+stats_flush_to_file(const char *sfile, struct counters *updates)
 {
        assert(conf);
 
@@ -427,13 +438,13 @@ stats_flush(void)
                return;
        }
 
-       if (!counter_updates) {
+       if (!updates) {
                return;
        }
 
        bool should_flush = false;
        for (int i = 0; i < STATS_END; ++i) {
-               if (counter_updates->data[i] > 0) {
+               if (updates->data[i] > 0) {
                        should_flush = true;
                        break;
                }
@@ -442,38 +453,38 @@ stats_flush(void)
                return;
        }
 
-       if (!stats_file) {
+       if (!sfile) {
                char *stats_dir;
 
-               // A NULL stats_file means that we didn't get past calculate_object_hash(),
-               // so we just choose one of stats files in the 16 subdirectories.
+               // A NULL sfile means that we didn't get past calculate_object_hash(), so
+               // we just choose one of stats files in the 16 subdirectories.
                stats_dir = format("%s/%x", conf->cache_dir, hash_from_int(getpid()) % 16);
-               stats_file = format("%s/stats", stats_dir);
+               sfile = format("%s/stats", stats_dir);
                free(stats_dir);
        }
 
-       if (!lockfile_acquire(stats_file, lock_staleness_limit)) {
+       if (!lockfile_acquire(sfile, lock_staleness_limit)) {
                return;
        }
 
        struct counters *counters = counters_init(STATS_END);
-       stats_read(stats_file, counters);
+       stats_read(sfile, counters);
        for (int i = 0; i < STATS_END; ++i) {
-               counters->data[i] += counter_updates->data[i];
+               counters->data[i] += updates->data[i];
        }
-       stats_write(stats_file, counters);
-       lockfile_release(stats_file);
+       stats_write(sfile, counters);
+       lockfile_release(sfile);
 
        if (!str_eq(conf->log_file, "") || conf->debug) {
                for (int i = 0; i < STATS_END; ++i) {
-                       if (counter_updates->data[stats_info[i].stat] != 0
+                       if (updates->data[stats_info[i].stat] != 0
                            && !(stats_info[i].flags & FLAG_NOZERO)) {
                                cc_log("Result: %s", stats_info[i].message);
                        }
                }
        }
 
-       char *subdir = dirname(stats_file);
+       char *subdir = dirname(sfile);
        bool need_cleanup = false;
 
        if (conf->max_files != 0
@@ -501,6 +512,15 @@ stats_flush(void)
        counters_free(counters);
 }
 
+// Write counter updates in counter_updates to disk.
+void
+stats_flush(void)
+{
+       stats_flush_to_file(stats_file, counter_updates);
+       counters_free(counter_updates);
+       counter_updates = NULL;
+}
+
 // Update a normal stat.
 void
 stats_update(enum stats stat)
index 1af3e034cc1653271a9c15cc29751d21db66eb85..3c2231da9c84a0050bcb34071322f89a7f85aba8 100644 (file)
@@ -1 +1 @@
-extern const char CCACHE_VERSION[]; const char CCACHE_VERSION[] = "3.7.1";
+extern const char CCACHE_VERSION[]; const char CCACHE_VERSION[] = "3.7.2";
index b4a96b471894cf736492227a50bcfd470442a304..f81040932faa5b5d6a98c9a201f630ccd140858f 100755 (executable)
--- a/test/run
+++ b/test/run
@@ -273,6 +273,8 @@ EOF
 # =============================================================================
 # main program
 
+export LC_ALL=C
+
 if pwd | grep '[^A-Za-z0-9/.,=_%+-]' >/dev/null 2>&1; then
     cat <<EOF
 Error: The test suite doesn't work in directories with whitespace or other
index 12138d1597b6c51703082d28ebcba88821f81afd..caf82c4598f4bf1ad4ca8a62c9c5711e85285520 100644 (file)
@@ -31,15 +31,22 @@ 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.
+    #
+    # Put tests that work with both compilers in pch_suite_common and put
+    # compiler-specific tests in pch_suite_clang/pch_suite_gcc.
+
+    pch_suite_common
     if $COMPILER_TYPE_CLANG; then
         pch_suite_clang
     else
@@ -47,7 +54,7 @@ SUITE_pch() {
     fi
 }
 
-pch_suite_gcc() {
+pch_suite_common() {
     # -------------------------------------------------------------------------
     TEST "Create .gch, -c, no -o, without opt-in"
 
@@ -81,41 +88,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 +140,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 +155,340 @@ 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 +496,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 +510,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,120 +523,88 @@ 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
 }
 
 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"
 
@@ -402,7 +618,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 +626,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 +634,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 +653,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
 }
index e3299b00e77d373892e8bc0e26be9b39810dde70..f44379c7e27d9c923bcfb0a4cd729dcb39c65b69 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2018 Joel Rosdahl
+// Copyright (C) 2010-2019 Joel Rosdahl
 //
 // This program is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by the Free
@@ -74,10 +74,6 @@ main(int argc, char **argv)
                }
        }
 
-       if (getenv("RUN_FROM_BUILD_FARM")) {
-               verbose = 1;
-       }
-
        testdir = format("testdir.%d", (int)getpid());
        cct_create_fresh_dir(testdir);
        dir_before = gnu_getcwd();
index 8d40a511f5203e8b654e717856019ae1670ee7ec..7974f8a7660e8394802b5dc9bb57b5c3bab37203 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2018 Joel Rosdahl
+// Copyright (C) 2010-2019 Joel Rosdahl
 //
 // This program is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by the Free
@@ -494,4 +494,22 @@ TEST(debug_flag_order_with_known_option_last)
        args_free(orig);
 }
 
+TEST(options_not_to_be_passed_to_the_preprocesor)
+{
+       struct args *orig = args_init_from_string(
+               "cc -Wa,foo foo.c -g -Xlinker fie -Xlinker,fum -c -Werror");
+       struct args *exp_cpp = args_init_from_string("cc -g");
+       struct args *exp_cc = args_init_from_string(
+               "cc -g -Wa,foo -Xlinker fie -Xlinker,fum -Werror -c");
+       struct args *act_cpp = NULL;
+       struct args *act_cc = NULL;
+
+       create_file("foo.c", "");
+       CHECK(cc_process_args(orig, &act_cpp, &act_cc));
+       CHECK_ARGS_EQ_FREE12(exp_cpp, act_cpp);
+       CHECK_ARGS_EQ_FREE12(exp_cc, act_cc);
+
+       args_free(orig);
+}
+
 TEST_SUITE_END
index 9ef6708574256294e625b8d2f1260f73b12c4c3d..886bd28537f0d333285c531af351a468b3595d37 100644 (file)
@@ -369,11 +369,11 @@ TEST(conf_set_new_value)
        char *data;
 
        create_file("ccache.conf", "path = vanilla\n");
-       CHECKM(conf_set_value_in_file("ccache.conf", "stats", "chocolate", &errmsg),
+       CHECKM(conf_set_value_in_file("ccache.conf", "compiler", "chocolate", &errmsg),
               errmsg);
        data = read_text_file("ccache.conf", 0);
        CHECK(data);
-       CHECK_STR_EQ_FREE2("path = vanilla\nstats = chocolate\n", data);
+       CHECK_STR_EQ_FREE2("path = vanilla\ncompiler = chocolate\n", data);
 }
 
 TEST(conf_set_existing_value)