Imported Upstream version 3.7.8 upstream/3.7.8
authorJinWang An <jinwang.an@samsung.com>
Tue, 3 Aug 2021 07:28:57 +0000 (16:28 +0900)
committerJinWang An <jinwang.an@samsung.com>
Tue, 3 Aug 2021 07:28:57 +0000 (16:28 +0900)
21 files changed:
LICENSE.html
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/conf.c
src/lockfile.c
src/util.c
src/version.c
test/run
test/suites/base.bash
test/suites/pch.bash
unittest/test_args.c
unittest/test_conf.c
unittest/test_lockfile.c
unittest/util.c

index 66556c42fe41b1468a7d26f872fc49720ad835cc..3959213505c97ad34c2001e5bfed2fb667ba6c65 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.7</span>\r
+<span id="revnumber">version 3.7.8</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.7<br />\r
+Version 3.7.8<br />\r
 Last updated\r
- 2020-01-05 21:09:39 CET\r
+ 2020-03-16 21:59:40 CET\r
 </div>\r
 </div>\r
 </body>\r
index 8890b33346c7e1eb7cea51ffc56f5b80fad554d8..2e3ac90062d5fdc52127f621b0f9d038a91ba0e0 100644 (file)
--- a/dev.mk.in
+++ b/dev.mk.in
@@ -190,9 +190,10 @@ doc/ccache.1: doc/MANUAL.xml
 
 .PHONY: update-authors
 update-authors:
-       git log --pretty=format:"%H %aN" \
-         | grep -Ev 'd7c5056beda5483fcd5c098165fffd9be86fe98d' \
-         | sed -r 's/[^ ]+/*/' \
+       git log --pretty=format:"%H %aN%n%(trailers:only)" \
+         | grep -Ev 'd7c5056beda5483fcd5c098165fffd9be86fe98d|http|Conflicts:' \
+         | grep '^[^ ]' \
+         | sed -r -e 's/[^ ]+/*/' -e 's/<.*//' -e 's/ *$$//' \
          | sort -u \
          | perl -00 -p -i -e 's/^\*.*/<STDIN> . "\n"/es' doc/AUTHORS.adoc
 
index 20c9bb427a883a166e1e2aa17540d32486d6a667..e98504393ea531b0bbdfd6eae542f958d8b82927 100644 (file)
@@ -12,7 +12,7 @@ ccache is a collective work with contributions from many people, including:
 * Andrea Bittau
 * Andreas Huber
 * André Klitzing
-* Andrew Boie
+* Andrew Boie
 * Andrew Stubbs
 * Andrew Tridgell
 * Bernhard Bauer
@@ -93,6 +93,7 @@ ccache is a collective work with contributions from many people, including:
 * RW
 * Ryan Brown
 * Sam Gross
+* Steffen Dettmer
 * Thomas Otto
 * Thomas Röfer
 * Timofei Kushnir
index 512639351f4ebdd542dd649eca02fd228f119617..9f3d099f31775abea18be640c0dbc38afa85c1c2 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.7</span>\r
+<span id="revnumber">version 3.7.8</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>
@@ -780,7 +780,7 @@ André Klitzing
 </li>\r
 <li>\r
 <p>\r
-Andrew Boie\r
+Andrew Boie\r
 </p>\r
 </li>\r
 <li>\r
@@ -1185,6 +1185,11 @@ Sam Gross
 </li>\r
 <li>\r
 <p>\r
+Steffen Dettmer\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
 Thomas Otto\r
 </p>\r
 </li>\r
@@ -1261,9 +1266,9 @@ Yvan Janssens
 <div id="footnotes"><hr /></div>\r
 <div id="footer">\r
 <div id="footer-text">\r
-Version 3.7.7<br />\r
+Version 3.7.8<br />\r
 Last updated\r
- 2020-01-05 21:09:39 CET\r
+ 2020-03-16 21:59:40 CET\r
 </div>\r
 </div>\r
 </body>\r
index 409d56084b2dba655940e41b19b62bfdce5697d0..19fc857024999ea014ba47897ab7a04c94059295 100644 (file)
@@ -570,7 +570,7 @@ still has to do _some_ preprocessing (like macros).
     Ignore ctimes when *file_stat_matches* is enabled. This can be useful when
     backdating files' mtimes in a controlled way.
 *include_file_ctime*::
-    By default, ccache also will not cache a file if it includes a header whose
+    By default, ccache will not cache a file if it includes a header whose
     ctime is too new. This option disables that check.
 *include_file_mtime*::
     By default, ccache will not cache a file if it includes a header whose
@@ -1189,13 +1189,13 @@ problems and what may be done to increase the hit rate:
    setting.
 ** A modification time of one of the include files is too new (created the same
    second as the compilation is being done). This check is made to avoid a race
-   condition. To fix this, create the include file earlier in the build
-   process, if possible, or set *sloppiness* to *include_file_mtime* if you are
-   willing to take the risk. (The race condition consists of these events: the
-   preprocessor is run; an include file is modified by someone; the new include
-   file is hashed by ccache; the real compiler is run on the preprocessor's
-   output, which contains data from the old header file; the wrong object file
-   is stored in the cache.)
+   condition. To fix this, create the include file earlier in the build process,
+   if possible, or set *sloppiness* to *include_file_ctime, include_file_mtime*
+   if you are willing to take the risk. (The race condition consists of these
+   events: the preprocessor is run; an include file is modified by someone; the
+   new include file is hashed by ccache; the real compiler is run on the
+   preprocessor's output, which contains data from the old header file; the
+   wrong object file is stored in the cache.)
 ** The `__TIME__` preprocessor macro is (potentially) being used. ccache turns
    off direct mode if `__TIME__` is present in the source code. This is done as
    a safety measure since the string indicates that a `__TIME__` macro _may_
index 805860e1c3a01cb050f0a620fb0b8b8895ad8807..2e6a15b6620d100e5be7345fd64c23808b964dfd 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.7</span>\r
+<span id="revnumber">version 3.7.8</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>
@@ -1603,7 +1603,7 @@ still has to do <em>some</em> preprocessing (like macros).</p></div>
 </dt>\r
 <dd>\r
 <p>\r
-    By default, ccache also will not cache a file if it includes a header whose\r
+    By default, ccache will not cache a file if it includes a header whose\r
     ctime is too new. This option disables that check.\r
 </p>\r
 </dd>\r
@@ -2581,13 +2581,13 @@ This was the first compilation with a new value of the base directory
 <p>\r
 A modification time of one of the include files is too new (created the same\r
    second as the compilation is being done). This check is made to avoid a race\r
-   condition. To fix this, create the include file earlier in the build\r
-   process, if possible, or set <strong>sloppiness</strong> to <strong>include_file_mtime</strong> if you are\r
-   willing to take the risk. (The race condition consists of these events: the\r
-   preprocessor is run; an include file is modified by someone; the new include\r
-   file is hashed by ccache; the real compiler is run on the preprocessor&#8217;s\r
-   output, which contains data from the old header file; the wrong object file\r
-   is stored in the cache.)\r
+   condition. To fix this, create the include file earlier in the build process,\r
+   if possible, or set <strong>sloppiness</strong> to <strong>include_file_ctime, include_file_mtime</strong>\r
+   if you are willing to take the risk. (The race condition consists of these\r
+   events: the preprocessor is run; an include file is modified by someone; the\r
+   new include file is hashed by ccache; the real compiler is run on the\r
+   preprocessor&#8217;s output, which contains data from the old header file; the\r
+   wrong object file is stored in the cache.)\r
 </p>\r
 </li>\r
 <li>\r
@@ -2713,9 +2713,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.7<br />\r
+Version 3.7.8<br />\r
 Last updated\r
- 2020-01-05 21:09:39 CET\r
+ 2020-03-16 21:59:40 CET\r
 </div>\r
 </div>\r
 </body>\r
index 5b8f9f1c0361fb87c0ff9be18f4b61787b13cf5a..e860e6b1976eab785ffc55c4bae2aa9adbfa0367 100644 (file)
@@ -1,6 +1,49 @@
 ccache news
 ===========
 
+ccache 3.7.8
+------------
+Release date: 2020-03-16
+
+Bug fixes
+~~~~~~~~~
+
+- Use `$PWD` instead of the real CWD (current working directory) when checking
+  for CWD in preprocessed output. This fixes a problem when `$PWD` includes a
+  symlink part and the user has set `hash_dir = false`.
+
+- Rewrote the Windows version of the lockfile routines. This should mitigate
+  several problems with the old implementation.
+
+- If `localtime_r` fails the epoch time is now logged instead of garbage.
+
+
+Other
+~~~~~
+
+- Improved error message when a boolean environment variable has an invalid
+  value.
+
+- Improved the regression fix in ccache 3.7.5 related to not passing
+  compilation-only options to the preprocessor.
+
+- ccache’s PCH test suite now skips running the tests if it detects broken PCH
+  compiler support.
+
+- Fixed unit test failure on Windows.
+
+- Fixed “stringop-truncation” build warning on Windows.
+
+- Improved “x_rename” implementation on Windows.
+
+- Improved removal of temporary file when rewriting absolute paths to relative
+  in the dependency file.
+
+- Clarified “include_file_ctime sloppiness” in the Performance section in the
+  manual.
+
+
+
 ccache 3.7.7
 ------------
 Release date: 2020-01-05
index e41e51fa625353ac6c39cec0755bd592ccddb89a..ea7c6b2e3ac7f4f0fb3bac72f29345fb97b081e0 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.7</span>\r
+<span id="revnumber">version 3.7.8</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,11 +743,90 @@ asciidoc.install(2);
 </div>\r
 <div id="content">\r
 <div class="sect1">\r
+<h2 id="_ccache_3_7_8">ccache 3.7.8</h2>\r
+<div class="sectionbody">\r
+<div class="paragraph"><p>Release date: 2020-03-16</p></div>\r
+<div class="sect2">\r
+<h3 id="_bug_fixes">Bug fixes</h3>\r
+<div class="ulist"><ul>\r
+<li>\r
+<p>\r
+Use <code>$PWD</code> instead of the real CWD (current working directory) when checking\r
+  for CWD in preprocessed output. This fixes a problem when <code>$PWD</code> includes a\r
+  symlink part and the user has set <code>hash_dir = false</code>.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Rewrote the Windows version of the lockfile routines. This should mitigate\r
+  several problems with the old implementation.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+If <code>localtime_r</code> fails the epoch time is now logged instead of garbage.\r
+</p>\r
+</li>\r
+</ul></div>\r
+</div>\r
+<div class="sect2">\r
+<h3 id="_other">Other</h3>\r
+<div class="ulist"><ul>\r
+<li>\r
+<p>\r
+Improved error message when a boolean environment variable has an invalid\r
+  value.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Improved the regression fix in ccache 3.7.5 related to not passing\r
+  compilation-only options to the preprocessor.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+ccache’s PCH test suite now skips running the tests if it detects broken PCH\r
+  compiler support.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Fixed unit test failure on Windows.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Fixed “stringop-truncation” build warning on Windows.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Improved “x_rename” implementation on Windows.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Improved removal of temporary file when rewriting absolute paths to relative\r
+  in the dependency file.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Clarified “include_file_ctime sloppiness” in the Performance section in the\r
+  manual.\r
+</p>\r
+</li>\r
+</ul></div>\r
+</div>\r
+</div>\r
+</div>\r
+<div class="sect1">\r
 <h2 id="_ccache_3_7_7">ccache 3.7.7</h2>\r
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2020-01-05</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
@@ -795,7 +874,7 @@ The “cache miss” statistics counter will now be updated for read-only cache
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2019-11-17</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
@@ -842,7 +921,7 @@ Added support for <code>-MF=arg</code> (with an extra equal sign) as understood
 </ul></div>\r
 </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
@@ -912,7 +991,7 @@ Added support for converting paths like “/c/users” into relative paths on
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2019-08-17</p></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
@@ -937,7 +1016,7 @@ Fixed a regression in 3.7.2 when using the compiler option “-Werror” and the
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2019-07-19</p></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
@@ -1394,7 +1473,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_6">Bug fixes</h3>\r
+<h3 id="_bug_fixes_7">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1431,7 +1510,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_7">Bug fixes</h3>\r
+<h3 id="_bug_fixes_8">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1475,7 +1554,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_8">Bug fixes</h3>\r
+<h3 id="_bug_fixes_9">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1561,7 +1640,7 @@ Documented caveats related to colored warnings from compilers.
 </ul></div>\r
 </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
@@ -1599,7 +1678,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_10">Bug fixes</h3>\r
+<h3 id="_bug_fixes_11">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1625,7 +1704,7 @@ Documented how automatic cache cleanup works.
 </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
@@ -1708,7 +1787,7 @@ Documented the different cache statistics counters.
 </ul></div>\r
 </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
@@ -1738,7 +1817,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_13">Bug fixes</h3>\r
+<h3 id="_bug_fixes_14">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1755,7 +1834,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_14">Bug fixes</h3>\r
+<h3 id="_bug_fixes_15">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1780,7 +1859,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_15">Bug fixes</h3>\r
+<h3 id="_bug_fixes_16">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1962,7 +2041,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_16">Bug fixes</h3>\r
+<h3 id="_bug_fixes_17">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1988,7 +2067,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_17">Bug fixes</h3>\r
+<h3 id="_bug_fixes_18">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2006,7 +2085,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_18">Bug fixes</h3>\r
+<h3 id="_bug_fixes_19">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2030,7 +2109,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_19">Bug fixes</h3>\r
+<h3 id="_bug_fixes_20">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2053,7 +2132,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_20">Bug fixes</h3>\r
+<h3 id="_bug_fixes_21">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2103,7 +2182,7 @@ Made it harder to misinterpret documentation of boolean environment settings’
 </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
@@ -2163,7 +2242,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_22">Bug fixes</h3>\r
+<h3 id="_bug_fixes_23">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2218,7 +2297,7 @@ Added support for compiler option <code>-gsplit-dwarf</code>.
 </ul></div>\r
 </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
@@ -2272,7 +2351,7 @@ Add support for caching code coverage results (compiling for gcov).
 </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
@@ -2342,7 +2421,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_25">Bug fixes</h3>\r
+<h3 id="_bug_fixes_26">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2574,7 +2653,7 @@ Various other improvements of the test suite.
 </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
@@ -2605,7 +2684,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_27">Bug fixes</h3>\r
+<h3 id="_bug_fixes_28">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2623,7 +2702,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_28">Bug fixes</h3>\r
+<h3 id="_bug_fixes_29">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2705,7 +2784,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_29">Bug fixes</h3>\r
+<h3 id="_bug_fixes_30">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2745,7 +2824,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_30">Bug fixes</h3>\r
+<h3 id="_bug_fixes_31">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2779,7 +2858,7 @@ Disappearing temporary stdout/stderr files are now handled gracefully.
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_other">Other</h3>\r
+<h3 id="_other_2">Other</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2816,7 +2895,7 @@ Clang plugins are now hashed to catch plugin upgrades.
 </ul></div>\r
 </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
@@ -2843,7 +2922,7 @@ Paths are now correctly canonicalized when computing paths relative to the
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_other_2">Other</h3>\r
+<h3 id="_other_3">Other</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2864,7 +2943,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_32">Bug fixes</h3>\r
+<h3 id="_bug_fixes_33">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2916,7 +2995,7 @@ Reverted the GCC bug compatibility introduced in ccache 3.1.5 for <code>-MT</cod
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_other_3">Other</h3>\r
+<h3 id="_other_4">Other</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -2947,7 +3026,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_33">Bug fixes</h3>\r
+<h3 id="_bug_fixes_34">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3000,7 +3079,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_34">Bug fixes</h3>\r
+<h3 id="_bug_fixes_35">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3033,7 +3112,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_35">Bug fixes</h3>\r
+<h3 id="_bug_fixes_36">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3066,7 +3145,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_36">Bug fixes</h3>\r
+<h3 id="_bug_fixes_37">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3077,7 +3156,7 @@ The -MFarg, -MTarg and -MQarg compiler options (i.e, without space between
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_other_4">Other</h3>\r
+<h3 id="_other_5">Other</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3093,7 +3172,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_37">Bug fixes</h3>\r
+<h3 id="_bug_fixes_38">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3114,7 +3193,7 @@ Fixed issue when parsing precompiler output on AIX.
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_other_5">Other</h3>\r
+<h3 id="_other_6">Other</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3141,7 +3220,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_38">Bug fixes</h3>\r
+<h3 id="_bug_fixes_39">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3179,7 +3258,7 @@ ccache development version (set by dev.mk) now works with gits whose
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_other_6">Other</h3>\r
+<h3 id="_other_7">Other</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3263,7 +3342,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_39">Bug fixes</h3>\r
+<h3 id="_bug_fixes_40">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3288,7 +3367,7 @@ EINTR is now handled correctly.
 </ul></div>\r
 </div>\r
 <div class="sect2">\r
-<h3 id="_other_7">Other</h3>\r
+<h3 id="_other_8">Other</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3349,7 +3428,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_40">Bug fixes</h3>\r
+<h3 id="_bug_fixes_41">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3538,7 +3617,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_41">Bug fixes</h3>\r
+<h3 id="_bug_fixes_42">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -3683,9 +3762,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.7<br />\r
+Version 3.7.8<br />\r
 Last updated\r
- 2020-01-05 21:09:39 CET\r
+ 2020-03-16 21:59:40 CET\r
 </div>\r
 </div>\r
 </body>\r
index be80e0d6c5e517165b39f72e502a7b33b759f6ff..d6fe85b35ed26016428e61102f816786c8800e93 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: 01/05/2020
+.\"      Date: 03/16/2020
 .\"    Manual: ccache Manual
-.\"    Source: ccache 3.7.7
+.\"    Source: ccache 3.7.8
 .\"  Language: English
 .\"
-.TH "CCACHE" "1" "01/05/2020" "ccache 3\&.7\&.7" "ccache Manual"
+.TH "CCACHE" "1" "03/16/2020" "ccache 3\&.7\&.8" "ccache Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -722,7 +722,7 @@ is enabled\&. This can be useful when backdating files\*(Aq mtimes in a controll
 .PP
 \fBinclude_file_ctime\fR
 .RS 4
-By default, ccache also will not cache a file if it includes a header whose ctime is too new\&. This option disables that check\&.
+By default, ccache will not cache a file if it includes a header whose ctime is too new\&. This option disables that check\&.
 .RE
 .PP
 \fBinclude_file_mtime\fR
@@ -2075,7 +2075,7 @@ This was the first compilation with a new value of the base directory setting\&.
 A modification time of one of the include files is too new (created the same second as the compilation is being done)\&. This check is made to avoid a race condition\&. To fix this, create the include file earlier in the build process, if possible, or set
 \fBsloppiness\fR
 to
-\fBinclude_file_mtime\fR
+\fBinclude_file_ctime, include_file_mtime\fR
 if you are willing to take the risk\&. (The race condition consists of these events: the preprocessor is run; an include file is modified by someone; the new include file is hashed by ccache; the real compiler is run on the preprocessor\(cqs output, which contains data from the old header file; the wrong object file is stored in the cache\&.)
 .RE
 .sp
index 36b41bb232bd97857ee115fd8040a5a83a78f864..6e9da51c2a9700a822ed7b059ace2bd6dca85c41 100644 (file)
@@ -914,7 +914,7 @@ process_preprocessed_file(struct hash *hash, const char *path, bool pump)
 
        init_included_files_table();
 
-       char *cwd = gnu_getcwd();
+       char *cwd = get_cwd();
 
        // Bytes between p and q are pending to be hashed.
        char *p = data;
@@ -1156,7 +1156,7 @@ out:
        }
        if (!result) {
                cc_log("Removing temporary dependency file: %s", tmp_file);
-               x_unlink(tmp_file);
+               tmp_unlink(tmp_file);
        }
        free(tmp_file);
 }
@@ -1910,7 +1910,7 @@ calculate_common_hash(struct args *args, struct hash *hash)
 
        // Possibly hash the current working directory.
        if (generating_debuginfo && conf->hash_dir) {
-               char *cwd = gnu_getcwd();
+               char *cwd = get_cwd();
                for (size_t i = 0; i < debug_prefix_maps_len; i++) {
                        char *map = debug_prefix_maps[i];
                        char *sep = strchr(map, '=');
@@ -2009,7 +2009,8 @@ calculate_common_hash(struct args *args, struct hash *hash)
 // modes and calculate the object hash. Returns the object hash on success,
 // otherwise NULL. Caller frees.
 static struct file_hash *
-calculate_object_hash(struct args *args, struct hash *hash, int direct_mode)
+calculate_object_hash(struct args *args, struct args *preprocessor_args,
+                      struct hash *hash, int direct_mode)
 {
        bool found_ccbin = false;
 
@@ -2273,23 +2274,24 @@ calculate_object_hash(struct args *args, struct hash *hash, int direct_mode)
                        cc_log("Did not find object file hash in manifest");
                }
        } else {
+               assert(preprocessor_args);
                if (arch_args_size == 0) {
-                       object_hash = get_object_name_from_cpp(args, hash);
+                       object_hash = get_object_name_from_cpp(preprocessor_args, hash);
                        cc_log("Got object file hash from preprocessor");
                } else {
-                       args_add(args, "-arch");
+                       args_add(preprocessor_args, "-arch");
                        for (size_t i = 0; i < arch_args_size; ++i) {
-                               args_add(args, arch_args[i]);
-                               object_hash = get_object_name_from_cpp(args, hash);
+                               args_add(preprocessor_args, arch_args[i]);
+                               object_hash = get_object_name_from_cpp(preprocessor_args, hash);
                                cc_log("Got object file hash from preprocessor with -arch %s",
                                       arch_args[i]);
                                if (i != arch_args_size - 1) {
                                        free(object_hash);
                                        object_hash = NULL;
                                }
-                               args_pop(args, 1);
+                               args_pop(preprocessor_args, 1);
                        }
-                       args_pop(args, 1);
+                       args_pop(preprocessor_args, 1);
                }
                if (generating_dependencies) {
                        // Nothing is actually created with -MF /dev/null
@@ -4041,7 +4043,7 @@ ccache(int argc, char *argv[])
        if (conf->direct_mode) {
                cc_log("Trying direct lookup");
                MTR_BEGIN("hash", "direct_hash");
-               object_hash = calculate_object_hash(args_to_hash, direct_hash, 1);
+               object_hash = calculate_object_hash(args_to_hash, NULL, direct_hash, 1);
                MTR_END("hash", "direct_hash");
                if (object_hash) {
                        update_cached_result_globals(object_hash);
@@ -4074,7 +4076,8 @@ ccache(int argc, char *argv[])
                        cpp_hash, output_obj, 'p', "PREPROCESSOR MODE", debug_text_file);
 
                MTR_BEGIN("hash", "cpp_hash");
-               object_hash = calculate_object_hash(args_to_hash, cpp_hash, 0);
+               object_hash = calculate_object_hash(
+                       args_to_hash, preprocessor_args, cpp_hash, 0);
                MTR_END("hash", "cpp_hash");
                if (!object_hash) {
                        fatal("internal error: object hash from cpp returned NULL");
index 92fe34bd630e3e035292308afe209d7aec1bfb1d..a990c9200ff5ed78a3511e8b167322cb260e3be2 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2019 Joel Rosdahl
+// Copyright (C) 2011-2020 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
@@ -39,15 +39,15 @@ find_env_to_conf(const char *name)
 
 static enum handle_conf_result
 handle_conf_setting(struct conf *conf, const char *key, const char *value,
-                    char **errmsg, bool from_env_variable, bool negate_boolean,
-                    const char *origin)
+                    char **errmsg, const char *env_var_name,
+                    bool negate_boolean, const char *origin)
 {
        const struct conf_item *item = find_conf(key);
        if (!item) {
                return HANDLE_CONF_UNKNOWN;
        }
 
-       if (from_env_variable && item->parser == confitem_parse_bool) {
+       if (env_var_name && item->parser == confitem_parse_bool) {
                // Special rule for boolean settings from the environment: "0", "false",
                // "disable" and "no" (case insensitive) are invalid, and all other values
                // mean true.
@@ -57,7 +57,13 @@ handle_conf_setting(struct conf *conf, const char *key, const char *value,
                // enabled.
                if (str_eq(value, "0") || strcasecmp(value, "false") == 0
                    || strcasecmp(value, "disable") == 0 || strcasecmp(value, "no") == 0) {
-                       fatal("invalid boolean environment variable value \"%s\"", value);
+                       fatal(
+                               "invalid boolean environment variable value \"%s\" for CCACHE_%s%s"
+                               " (did you mean to set \"CCACHE_%s%s=true\"?)",
+                               value,
+                               negate_boolean ? "NO" : "",
+                               env_var_name, negate_boolean ? "" : "NO",
+                               env_var_name);
                }
 
                bool *boolvalue = (bool *)((char *)conf + item->offset);
@@ -218,7 +224,7 @@ conf_read(struct conf *conf, const char *path, char **errmsg)
                bool ok = parse_line(buf, &key, &value, &errmsg2);
                if (ok && key) { // key == NULL if comment or blank line.
                        hcr =
-                               handle_conf_setting(conf, key, value, &errmsg2, false, false, path);
+                               handle_conf_setting(conf, key, value, &errmsg2, NULL, false, path);
                        ok = hcr != HANDLE_CONF_FAIL; // unknown is OK
                }
                free(key);
@@ -274,8 +280,8 @@ conf_update_from_environment(struct conf *conf, char **errmsg)
 
                char *errmsg2 = NULL;
                enum handle_conf_result hcr = handle_conf_setting(
-                       conf, env_to_conf_item->conf_name, q, &errmsg2, true, negate,
-                       "environment");
+                       conf, env_to_conf_item->conf_name, q, &errmsg2,
+                       env_to_conf_item->env_name, negate, "environment");
                if (hcr != HANDLE_CONF_OK) {
                        *errmsg = format("%s: %s", key, errmsg2);
                        free(errmsg2);
index 9d1a49db2f3d499422d571853d9bed4e270ef0ff..bbf4c950333cd154896e860e778c4e5b7898503c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2018 Joel Rosdahl
+// Copyright (C) 2010-2020 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
@@ -16,6 +16,8 @@
 
 #include "ccache.h"
 
+#ifndef _WIN32
+
 // This function acquires a lockfile for the given path. Returns true if the
 // lock was acquired, otherwise false. If the lock has been considered stale
 // for the number of microseconds specified by staleness_limit, the function
@@ -34,65 +36,13 @@ lockfile_acquire(const char *path, unsigned staleness_limit)
        const char *hostname = get_hostname();
        bool acquired = false;
        unsigned to_sleep = 1000; // Microseconds.
+       unsigned max_to_sleep = 10000; // Microseconds.
        unsigned slept = 0; // Microseconds.
 
        while (true) {
                free(my_content);
                my_content = format("%s:%d:%d", hostname, (int)getpid(), (int)time(NULL));
 
-#ifdef _WIN32
-               int fd = open(lockfile, O_WRONLY|O_CREAT|O_EXCL|O_BINARY, 0666);
-               if (fd == -1) {
-                       int saved_errno = errno;
-                       cc_log("lockfile_acquire: open WRONLY %s: %s", lockfile, strerror(errno));
-                       if (saved_errno == ENOENT) {
-                               // Directory doesn't exist?
-                               if (create_parent_dirs(lockfile) == 0) {
-                                       // OK. Retry.
-                                       continue;
-                               }
-                       }
-                       if (saved_errno != EEXIST) {
-                               // Directory doesn't exist or isn't writable?
-                               goto out;
-                       }
-                       // Someone else has the lock.
-                       fd = open(lockfile, O_RDONLY|O_BINARY);
-                       if (fd == -1) {
-                               if (errno == ENOENT) {
-                                       // The file was removed after the open() call above, so retry
-                                       // acquiring it.
-                                       continue;
-                               } else {
-                                       cc_log("lockfile_acquire: open RDONLY %s: %s",
-                                              lockfile, strerror(errno));
-                                       goto out;
-                               }
-                       }
-                       free(content);
-                       const size_t bufsize = 1024;
-                       content = x_malloc(bufsize);
-                       int len = read(fd, content, bufsize - 1);
-                       if (len == -1) {
-                               cc_log("lockfile_acquire: read %s: %s", lockfile, strerror(errno));
-                               close(fd);
-                               goto out;
-                       }
-                       close(fd);
-                       content[len] = '\0';
-               } else {
-                       // We got the lock.
-                       if (write(fd, my_content, strlen(my_content)) == -1) {
-                               cc_log("lockfile_acquire: write %s: %s", lockfile, strerror(errno));
-                               close(fd);
-                               x_unlink(lockfile);
-                               goto out;
-                       }
-                       close(fd);
-                       acquired = true;
-                       goto out;
-               }
-#else
                if (symlink(my_content, lockfile) == 0) {
                        // We got the lock.
                        acquired = true;
@@ -129,7 +79,6 @@ lockfile_acquire(const char *path, unsigned staleness_limit)
                                goto out;
                        }
                }
-#endif
 
                if (str_eq(content, my_content)) {
                        // Lost NFS reply?
@@ -164,7 +113,7 @@ lockfile_acquire(const char *path, unsigned staleness_limit)
                       lockfile, to_sleep);
                usleep(to_sleep);
                slept += to_sleep;
-               to_sleep *= 2;
+               to_sleep = MIN(max_to_sleep, 2 * to_sleep);
        }
 
 out:
@@ -191,23 +140,114 @@ lockfile_release(const char *path)
        free(lockfile);
 }
 
+#else
+
+HANDLE lockfile_handle = NULL;
+
+// This function acquires a lockfile for the given path. Returns true if the
+// lock was acquired, otherwise false. If the lock has been acquired within the
+// limit (in microseconds) the function will give up and return false. The time
+// limit should be reasonably larger than the longest time the lock can be
+// expected to be held.
+bool
+lockfile_acquire(const char *path, unsigned time_limit)
+{
+       char *lockfile = format("%s.lock", path);
+       unsigned to_sleep = 1000; // Microseconds.
+       unsigned max_to_sleep = 10000; // Microseconds.
+       unsigned slept = 0; // Microseconds.
+       bool acquired = false;
+
+       while (true) {
+               DWORD flags = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE;
+               lockfile_handle = CreateFile(
+                       lockfile,
+                       GENERIC_WRITE, // desired access
+                       0,             // shared mode (0 = not shared)
+                       NULL,          // security attributes
+                       CREATE_ALWAYS, // creation disposition,
+                       flags,         // flags and attributes
+                       NULL           // template file
+               );
+               if (lockfile_handle != INVALID_HANDLE_VALUE) {
+                       acquired = true;
+                       break;
+               }
+
+               DWORD error = GetLastError();
+               cc_log("lockfile_acquire: CreateFile %s: error code %lu", lockfile, error);
+               if (error == ERROR_PATH_NOT_FOUND) {
+                       // Directory doesn't exist?
+                       if (create_parent_dirs(lockfile) == 0) {
+                               // OK. Retry.
+                               continue;
+                       }
+               }
+
+               // ERROR_SHARING_VIOLATION: lock already held.
+               // ERROR_ACCESS_DENIED: maybe pending delete.
+               if (error != ERROR_SHARING_VIOLATION && error != ERROR_ACCESS_DENIED) {
+                       // Fatal error, give up.
+                       break;
+               }
+
+               if (slept > time_limit) {
+                       cc_log("lockfile_acquire: gave up acquiring %s", lockfile);
+                       break;
+               }
+
+               cc_log("lockfile_acquire: failed to acquire %s; sleeping %u microseconds",
+                      lockfile, to_sleep);
+               usleep(to_sleep);
+               slept += to_sleep;
+               to_sleep = MIN(max_to_sleep, 2 * to_sleep);
+       }
+
+       if (acquired) {
+               cc_log("Acquired lock %s", lockfile);
+       } else {
+               cc_log("Failed to acquire lock %s", lockfile);
+       }
+       free(lockfile);
+       return acquired;
+}
+
+// Release the lockfile for the given path. Assumes that we are the legitimate
+// owner.
+void
+lockfile_release(const char *path)
+{
+       assert(lockfile_handle != INVALID_HANDLE_VALUE);
+       cc_log("Releasing lock %s.lock", path);
+       CloseHandle(lockfile_handle);
+       lockfile_handle = NULL;
+}
+
+#endif
+
 #ifdef TEST_LOCKFILE
+
 int
 main(int argc, char **argv)
 {
-       extern char *cache_logfile;
-       cache_logfile = "/dev/stdout";
-       if (argc == 4) {
+       extern struct conf *conf;
+       conf = conf_create();
+       if (argc == 3) {
                unsigned staleness_limit = atoi(argv[1]);
-               if (str_eq(argv[2], "acquire")) {
-                       return lockfile_acquire(argv[3], staleness_limit) == 0;
-               } else if (str_eq(argv[2], "release")) {
-                       lockfile_release(argv[3]);
-                       return 0;
+               printf("Acquiring\n");
+               bool acquired = lockfile_acquire(argv[2], staleness_limit);
+               if (acquired) {
+                       printf("Sleeping 2 seconds\n");
+                       sleep(2);
+                       lockfile_release(argv[2]);
+                       printf("Released\n");
+               } else {
+                       printf("Failed to acquire\n");
                }
+       } else {
+               fprintf(stderr,
+                       "Usage: testlockfile <staleness_limit> <path>\n");
        }
-       fprintf(stderr,
-               "Usage: testlockfile <staleness_limit> <acquire|release> <path>\n");
        return 1;
 }
 #endif
index 262aa6a6254b445cba0adfbcab852ecf8767b7e7..325a839504fcf0abefb6620839ea765cca3a7bfc 100644 (file)
@@ -1,5 +1,5 @@
 // Copyright (C) 2002 Andrew Tridgell
-// Copyright (C) 2009-2019 Joel Rosdahl
+// Copyright (C) 2009-2020 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
@@ -97,12 +97,11 @@ log_prefix(bool log_updated_time)
                struct tm tm;
                struct timeval tv;
                gettimeofday(&tv, NULL);
-#ifdef __MINGW64_VERSION_MAJOR
-               localtime_r((time_t *)&tv.tv_sec, &tm);
-#else
-               localtime_r(&tv.tv_sec, &tm);
-#endif
-               strftime(timestamp, sizeof(timestamp), "%Y-%m-%dT%H:%M:%S", &tm);
+               if (localtime_r((time_t *)&tv.tv_sec, &tm) != NULL) {
+                       strftime(timestamp, sizeof(timestamp), "%Y-%m-%dT%H:%M:%S", &tm);
+               } else {
+                       snprintf(timestamp, sizeof(timestamp), "%lu", tv.tv_sec);
+               }
                snprintf(prefix, sizeof(prefix),
                         "[%s.%06d %-5d] ", timestamp, (int)tv.tv_usec, (int)getpid());
        }
@@ -1125,7 +1124,7 @@ static BOOL GetFileNameFromHandle(HANDLE file_handle, TCHAR *filename,
                                                                           TEXT("%s%s"),
                                                                           drive,
                                                                           filename+name_len);
-                                                               _tcsncpy(filename, temp_file, _tcslen(temp_file));
+                                                               strcpy(filename, temp_file);
                                                        }
                                                }
                                        }
@@ -1519,9 +1518,8 @@ x_rename(const char *oldpath, const char *newpath)
        return rename(oldpath, newpath);
 #else
        // Windows' rename() refuses to overwrite an existing file.
-       unlink(newpath); // Not x_unlink, as x_unlink calls x_rename.
        // If the function succeeds, the return value is nonzero.
-       if (MoveFileA(oldpath, newpath) == 0) {
+       if (MoveFileExA(oldpath, newpath, MOVEFILE_REPLACE_EXISTING) == 0) {
                LPVOID lp_msg_buf;
                DWORD dw = GetLastError();
                FormatMessage(
index fb1c3084049d984a4f6c0c0194b180115f7cb549..7c56463c56281b8f58044f69eca9fb88871978ff 100644 (file)
@@ -1 +1 @@
-extern const char CCACHE_VERSION[]; const char CCACHE_VERSION[] = "3.7.7";
+extern const char CCACHE_VERSION[]; const char CCACHE_VERSION[] = "3.7.8";
index f81040932faa5b5d6a98c9a201f630ccd140858f..d506c4657ee46219cc88c2a9dde9f99803cef32d 100755 (executable)
--- a/test/run
+++ b/test/run
@@ -3,7 +3,7 @@
 # A simple test suite for ccache.
 #
 # Copyright (C) 2002-2007 Andrew Tridgell
-# Copyright (C) 2009-2019 Joel Rosdahl
+# Copyright (C) 2009-2020 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 Software
@@ -262,8 +262,12 @@ EOF
 
     cd /
     remove_cache
-    rm -rf $ABS_TESTDIR/run
-    mkdir $ABS_TESTDIR/run
+    rm -rf $ABS_TESTDIR/run $ABS_TESTDIR/run.real
+
+    # Verify that tests behave well when apparent CWD != actual CWD.
+    mkdir $ABS_TESTDIR/run.real
+    ln -s run.real $ABS_TESTDIR/run
+
     cd $ABS_TESTDIR/run
     if type SUITE_${suite_name}_SETUP >/dev/null 2>&1; then
         SUITE_${suite_name}_SETUP
index 00664a9c6401a454b902429ac3207c72ebc0bc4a..7a864e9409859ffe0de30884e3a2931ea33b0009 100644 (file)
@@ -967,22 +967,40 @@ EOF
     # -------------------------------------------------------------------------
     TEST "Handling of compiler-only arguments"
 
-    $CCACHE_COMPILE -c test1.c
+    cat >compiler.sh <<EOF
+#!/bin/sh
+printf "[%s]" "\$*" >>compiler.args
+[ \$1 = -E ] && echo test || echo test >test1.o
+EOF
+    chmod +x compiler.sh
+    backdate compiler.sh
+
+    $CCACHE ./compiler.sh -c test1.c
     expect_stat 'cache hit (preprocessed)' 0
     expect_stat 'cache miss' 1
     expect_stat 'files in cache' 1
+    if [ -z "$CCACHE_NOCPP2" ]; then
+        expect_file_content compiler.args "[-E test1.c][-c -o test1.o test1.c]"
+    fi
+    rm compiler.args
 
-    $CCACHE_COMPILE -c test1.c
+    $CCACHE ./compiler.sh -c test1.c
     expect_stat 'cache hit (preprocessed)' 1
     expect_stat 'cache miss' 1
     expect_stat 'files in cache' 1
+    expect_file_content compiler.args "[-E test1.c]"
+    rm compiler.args
 
     # Even though -Werror is not passed to the preprocessor, it should be part
     # of the hash, so we expect a cache miss:
-    $CCACHE_COMPILE -c -Werror test1.c
+    $CCACHE ./compiler.sh -c -Werror -rdynamic test1.c
     expect_stat 'cache hit (preprocessed)' 1
     expect_stat 'cache miss' 2
     expect_stat 'files in cache' 2
+    if [ -z "$CCACHE_NOCPP2" ]; then
+        expect_file_content compiler.args "[-E test1.c][-Werror -rdynamic -c -o test1.o test1.c]"
+    fi
+    rm compiler.args
 
     # -------------------------------------------------------------------------
     TEST "Dependency file content"
index caf82c4598f4bf1ad4ca8a62c9c5711e85285520..f779a36f6a7a8a124f6e6be83dccf57a3517ca20 100644 (file)
@@ -1,8 +1,15 @@
 SUITE_pch_PROBE() {
-    touch pch.h
+    touch pch.h empty.c
+    mkdir dir
+
     if ! $REAL_COMPILER $SYSROOT -fpch-preprocess pch.h 2>/dev/null \
             || [ ! -f pch.h.gch ]; then
-        echo "compiler ($($COMPILER --version | head -1)) doesn't support precompiled headers"
+        echo "compiler ($($COMPILER --version | head -n 1)) doesn't support precompiled headers"
+    fi
+
+    $REAL_COMPILER $SYSROOT -c pch.h -o dir/pch.h.gch 2>/dev/null
+    if ! $REAL_COMPILER $SYSROOT -c -include dir/pch.h empty.c 2>/dev/null; then
+        echo "compiler ($($COMPILER --version | head -n 1)) seems to have broken support for precompiled headers"
     fi
 }
 
index 65c66d8d95f708643796a264a89774f3596e6c3a..60302950c435e903b9dcf771ca0cbb83b378c6d7 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2018 Joel Rosdahl
+// Copyright (C) 2010-2020 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,11 +74,7 @@ TEST(args_init_from_gcc_atfile)
        CHECK_STR_EQ("fourth", args->argv[3]);
        CHECK_STR_EQ("fif th", args->argv[4]);
        CHECK_STR_EQ("si'x\" th", args->argv[5]);
-#ifndef _WIN32
        CHECK_STR_EQ("seve\nth", args->argv[6]);
-#else
-       CHECK_STR_EQ("seve\r\nth", args->argv[6]);
-#endif
        CHECK(!args->argv[7]);
        args_free(args);
 }
index a203ec8752ce13f7912fc03e17e8bda4dc67aa4e..b9c4e4d29212fa7d8c43e8d86d69f37a82b07fd5 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2019 Joel Rosdahl
+// Copyright (C) 2011-2020 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
index 98811c68f3bfb59bb4cf5cfae2dda2f8c4ed6c1a..94d9e483a39a5455ad251376b50c65c0f71483c1 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2018 Joel Rosdahl
+// Copyright (C) 2010-2020 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
 
 TEST_SUITE(lockfile)
 
-TEST(acquire_should_create_symlink)
+TEST(acquire_and_release)
 {
-       lockfile_acquire("test", 1000);
+       CHECK(lockfile_acquire("test", 1000));
 
 #ifdef _WIN32
        CHECK(path_exists("test.lock"));
 #else
        CHECK(is_symlink("test.lock"));
 #endif
-}
 
-TEST(release_should_delete_file)
-{
-       create_file("test.lock", "");
        lockfile_release("test");
-
        CHECK(!path_exists("test.lock"));
 }
 
+#ifndef _WIN32
+
 TEST(lock_breaking)
 {
        char *p;
 
-#ifdef _WIN32
-       create_file("test.lock", "foo");
-       create_file("test.lock.lock", "foo");
-#else
        CHECK_INT_EQ(0, symlink("foo", "test.lock"));
        CHECK_INT_EQ(0, symlink("foo", "test.lock.lock"));
-#endif
        CHECK(lockfile_acquire("test", 1000));
 
-#ifdef _WIN32
-       p = read_text_file("test.lock", 0);
-#else
        p = x_readlink("test.lock");
-#endif
        CHECK(p);
        CHECK(!str_eq(p, "foo"));
        CHECK(!path_exists("test.lock.lock"));
@@ -66,12 +54,12 @@ TEST(lock_breaking)
        free(p);
 }
 
-#ifndef _WIN32
 TEST(failed_lock_breaking)
 {
        create_file("test.lock", "");
        CHECK(!lockfile_acquire("test", 1000));
 }
-#endif
+
+#endif // !_WIN32
 
 TEST_SUITE_END
index 1e52c525c45b49a7eee0f30d44433871120577a5..e06761a276aa5cc0b1588dca20dc6d4a6392a9f2 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2018 Joel Rosdahl
+// Copyright (C) 2010-2020 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
@@ -31,7 +31,7 @@ path_exists(const char *path)
 void
 create_file(const char *path, const char *content)
 {
-       FILE *f = fopen(path, "w");
+       FILE *f = fopen(path, "wb");
        if (!f || fputs(content, f) < 0) {
                fprintf(stderr, "create_file: %s: %s\n", path, strerror(errno));
        }