Imported Upstream version 3.1.7 upstream/3.1.7
authorJinWang An <jinwang.an@samsung.com>
Tue, 3 Aug 2021 06:48:22 +0000 (15:48 +0900)
committerJinWang An <jinwang.an@samsung.com>
Tue, 3 Aug 2021 06:48:22 +0000 (15:48 +0900)
24 files changed:
AUTHORS.html
INSTALL.html
LICENSE.html
MANUAL.html
MANUAL.txt
NEWS.html
NEWS.txt
README.html
ccache.1
ccache.c
ccache.h
execute.c
manifest.c
mdfour.c
packaging/ccache.changes [deleted file]
packaging/ccache.manifest [deleted file]
packaging/ccache.spec [deleted file]
test.sh
test/test_argument_processing.c
util.c
version.c
zlib/crc32.c
zlib/inffast.c
zlib/inftrees.c

index 11cf16b..1279356 100644 (file)
@@ -532,7 +532,7 @@ footnotes: function () {
 <body class="article">\r
 <div id="header">\r
 <h1>ccache authors</h1>\r
-<span id="revnumber">version 3.1.6</span>\r
+<span id="revnumber">version 3.1.7</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>
@@ -668,8 +668,8 @@ Wilson Snyder &lt;<a href="mailto:wsnyder@wsnyder.org">wsnyder@wsnyder.org</a>&g
 <div id="footnotes"><hr /></div>\r
 <div id="footer">\r
 <div id="footer-text">\r
-Version 3.1.6<br />\r
-Last updated 2011-08-21 16:32:08 CEST\r
+Version 3.1.7<br />\r
+Last updated 2012-01-08 15:29:34 CET\r
 </div>\r
 </div>\r
 </body>\r
index 840bf4d..dcbf37c 100644 (file)
@@ -532,7 +532,7 @@ footnotes: function () {
 <body class="article">\r
 <div id="header">\r
 <h1>ccache installation</h1>\r
-<span id="revnumber">version 3.1.6</span>\r
+<span id="revnumber">version 3.1.7</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>
@@ -641,7 +641,7 @@ above.</p></div>
 <div id="footnotes"><hr /></div>\r
 <div id="footer">\r
 <div id="footer-text">\r
-Version 3.1.6<br />\r
+Version 3.1.7<br />\r
 Last updated 2010-04-28 20:58:43 CEST\r
 </div>\r
 </div>\r
index 0c5721e..07623a9 100644 (file)
@@ -532,7 +532,7 @@ footnotes: function () {
 <body class="article">\r
 <div id="header">\r
 <h1>ccache copyright and license</h1>\r
-<span id="revnumber">version 3.1.6</span>\r
+<span id="revnumber">version 3.1.7</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>
@@ -1008,8 +1008,8 @@ following license:</p></div>
 <div id="footnotes"><hr /></div>\r
 <div id="footer">\r
 <div id="footer-text">\r
-Version 3.1.6<br />\r
-Last updated 2011-08-21 16:32:08 CEST\r
+Version 3.1.7<br />\r
+Last updated 2012-01-08 15:29:34 CET\r
 </div>\r
 </div>\r
 </body>\r
index 97398e7..141dfdb 100644 (file)
@@ -532,7 +532,7 @@ footnotes: function () {
 <body class="article">\r
 <div id="header">\r
 <h1>CCACHE(1)</h1>\r
-<span id="revnumber">version 3.1.6</span>\r
+<span id="revnumber">version 3.1.7</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>
@@ -1752,10 +1752,27 @@ slower, though, so it is better to find and fix the root cause.</p></div>
 bad object file sneaks into the cache for some reason, it will of course stay\r
 bad. Some possible reasons for erroneous object files are bad hardware (disk\r
 drive, disk controller, memory, etc), buggy drivers or file systems, a bad\r
-<strong>CCACHE_PREFIX</strong> command or compiler wrapper. If this happens, you can either\r
-find out which object file is broken by reading the debug log and then delete\r
-the bad object file from the cache, or you can simply clear the whole cache\r
-with <strong>ccache -C</strong> if you don&#8217;t mind losing other cached results.</p></div>\r
+<strong>CCACHE_PREFIX</strong> command or compiler wrapper. If this happens, the easiest way\r
+of fixing it is this:</p></div>\r
+<div class="olist arabic"><ol class="arabic">\r
+<li>\r
+<p>\r
+Build so that the bad object file ends up in the build tree.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Remove the bad object file from the build tree.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Rebuild with <strong>CCACHE_RECACHE</strong> set.\r
+</p>\r
+</li>\r
+</ol></div>\r
+<div class="paragraph"><p>An alternative is to clear the whole cache with <strong>ccache -C</strong> if you don&#8217;t mind\r
+losing other cached results.</p></div>\r
 <div class="paragraph"><p>There are no reported issues about ccache producing broken object files\r
 reproducibly. That doesn&#8217;t mean it can&#8217;t happen, so if you find a repeatable\r
 case, please report it.</p></div>\r
@@ -1781,8 +1798,8 @@ 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.1.6<br />\r
-Last updated 2011-08-14 21:46:15 CEST\r
+Version 3.1.7<br />\r
+Last updated 2012-01-08 15:29:34 CET\r
 </div>\r
 </div>\r
 </body>\r
index 0a67b9f..f15d666 100644 (file)
@@ -771,10 +771,15 @@ It should be noted that ccache is susceptible to general storage problems. If a
 bad object file sneaks into the cache for some reason, it will of course stay
 bad. Some possible reasons for erroneous object files are bad hardware (disk
 drive, disk controller, memory, etc), buggy drivers or file systems, a bad
-*CCACHE_PREFIX* command or compiler wrapper. If this happens, you can either
-find out which object file is broken by reading the debug log and then delete
-the bad object file from the cache, or you can simply clear the whole cache
-with *ccache -C* if you don't mind losing other cached results.
+*CCACHE_PREFIX* command or compiler wrapper. If this happens, the easiest way
+of fixing it is this:
+
+1. Build so that the bad object file ends up in the build tree.
+2. Remove the bad object file from the build tree.
+3. Rebuild with *CCACHE_RECACHE* set.
+
+An alternative is to clear the whole cache with *ccache -C* if you don't mind
+losing other cached results.
 
 There are no reported issues about ccache producing broken object files
 reproducibly. That doesn't mean it can't happen, so if you find a repeatable
index 0d5a369..4589164 100644 (file)
--- a/NEWS.html
+++ b/NEWS.html
@@ -532,7 +532,7 @@ footnotes: function () {
 <body class="article">\r
 <div id="header">\r
 <h1>ccache news</h1>\r
-<span id="revnumber">version 3.1.6</span>\r
+<span id="revnumber">version 3.1.7</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>
@@ -540,6 +540,80 @@ footnotes: function () {
 </div>\r
 <div id="content">\r
 <div class="sect1">\r
+<h2 id="_ccache_3_1_7">ccache 3.1.7</h2>\r
+<div class="sectionbody">\r
+<div class="paragraph"><p>Release date: 2012-01-08</p></div>\r
+<div class="sect2">\r
+<h3 id="_bug_fixes">Bug fixes</h3>\r
+<div class="ulist"><ul>\r
+<li>\r
+<p>\r
+Non-writable <tt>CCACHE_DIR</tt> is now handled gracefully when\r
+      <tt>CCACHE_READONLY</tt> is set.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Made failure to create files (typically due to bad directory permissions)\r
+      in the cache directory fatal. Previously, such failures were silently and\r
+      erroneously flagged as "compiler produced stdout".\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Both the <tt>-specs=file</tt> and <tt>--specs=file</tt> forms are now recognized.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Added recognition and hashing of GCC plugins specified with\r
+      <tt>-fplugin=file</tt>.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+<tt>CCACHE_COMPILERCHECK</tt> now also determines how to hash explicit specs\r
+      files (<tt>-specs=file</tt>).\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Added <tt>CPATH</tt>, <tt>C_INCLUDE_PATH</tt> and similar environment variables to the\r
+      hash to avoid false cache hits when such variables have changed.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Corrected log message when unify mode is enabled.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Reverted the GCC bug compatibility introduced in ccache 3.1.5 for\r
+      <tt>-MT</tt>/<tt>-MQ</tt> options with concatenated arguments. (The bug is fixed in\r
+      recent GCC versions.)\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
+Corrected license header for <tt>mdfour.c</tt>.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Improved documentation on how to fix bad object files in the cache.\r
+</p>\r
+</li>\r
+</ul></div>\r
+</div>\r
+</div>\r
+</div>\r
+<div class="sect1">\r
 <h2 id="_ccache_3_1_6">ccache 3.1.6</h2>\r
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2011-08-21</p></div>\r
@@ -548,22 +622,22 @@ footnotes: function () {
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
-Rewrite argument to --sysroot if CCACHE_BASEDIR is used.\r
+Rewrite argument to <tt>--sysroot</tt> if <tt>CCACHE_BASEDIR</tt> is used.\r
 </p>\r
 </li>\r
 </ul></div>\r
 </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
-Don&#8217;t crash if getcwd() fails.\r
+Don&#8217;t crash if <tt>getcwd()</tt> fails.\r
 </p>\r
 </li>\r
 <li>\r
 <p>\r
-Fixed alignment of "called for preprocessing" counter.\r
+Fixed alignment of &#8220;called for preprocessing&#8221; counter.\r
 </p>\r
 </li>\r
 </ul></div>\r
@@ -607,7 +681,7 @@ Improved order of statistics counters in <tt>ccache -s</tt> output.
 </ul></div>\r
 </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
@@ -641,7 +715,7 @@ Systems that lack (and don&#8217;t need to be linked with) libm are now
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2011-01-09</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
@@ -674,7 +748,7 @@ The file handle in now correctly closed on write error when trying to
 <div class="sectionbody">\r
 <div class="paragraph"><p>Release date: 2010-11-28</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
@@ -685,7 +759,7 @@ The -MFarg, -MTarg and -MQarg compiler options (i.e, without space
 </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
@@ -701,7 +775,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_5">Bug fixes</h3>\r
+<h3 id="_bug_fixes_6">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -722,7 +796,7 @@ Fixed issue when parsing precompiler output on AIX.
 </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
@@ -749,7 +823,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_6">Bug fixes</h3>\r
+<h3 id="_bug_fixes_7">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -788,7 +862,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_3">Other</h3>\r
+<h3 id="_other_4">Other</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -873,7 +947,7 @@ Added <tt>-install_name</tt> as an option known to take an argument. (This
 </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
@@ -899,7 +973,7 @@ EINTR is now handled correctly.
 </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
@@ -961,7 +1035,7 @@ New <tt>HACKING.txt</tt> 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_8">Bug fixes</h3>\r
+<h3 id="_bug_fixes_9">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1155,7 +1229,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_9">Bug fixes</h3>\r
+<h3 id="_bug_fixes_10">Bug fixes</h3>\r
 <div class="ulist"><ul>\r
 <li>\r
 <p>\r
@@ -1300,8 +1374,8 @@ 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.1.6<br />\r
-Last updated 2011-08-21 16:34:07 CEST\r
+Version 3.1.7<br />\r
+Last updated 2012-01-08 15:37:31 CET\r
 </div>\r
 </div>\r
 </body>\r
index febf44e..c966f72 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -2,6 +2,40 @@ ccache news
 ===========
 
 
+ccache 3.1.7
+------------
+Release date: 2012-01-08
+
+
+Bug fixes
+~~~~~~~~~
+
+    - Non-writable `CCACHE_DIR` is now handled gracefully when
+      `CCACHE_READONLY` is set.
+    - Made failure to create files (typically due to bad directory permissions)
+      in the cache directory fatal. Previously, such failures were silently and
+      erroneously flagged as "compiler produced stdout".
+    - Both the `-specs=file` and `--specs=file` forms are now recognized.
+    - Added recognition and hashing of GCC plugins specified with
+      `-fplugin=file`.
+    - `CCACHE_COMPILERCHECK` now also determines how to hash explicit specs
+      files (`-specs=file`).
+    - Added `CPATH`, `C_INCLUDE_PATH` and similar environment variables to the
+      hash to avoid false cache hits when such variables have changed.
+    - Corrected log message when unify mode is enabled.
+    - Reverted the GCC bug compatibility introduced in ccache 3.1.5 for
+      `-MT`/`-MQ` options with concatenated arguments. (The bug is fixed in
+      recent GCC versions.)
+
+
+Other
+~~~~~
+
+    - Corrected license header for `mdfour.c`.
+    - Improved documentation on how to fix bad object files in the cache.
+
+
+
 ccache 3.1.6
 ------------
 Release date: 2011-08-21
@@ -10,14 +44,14 @@ Release date: 2011-08-21
 New features and improvements
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-    - Rewrite argument to --sysroot if CCACHE_BASEDIR is used.
+    - Rewrite argument to `--sysroot` if `CCACHE_BASEDIR` is used.
 
 
 Bug fixes
 ~~~~~~~~~
 
-    - Don't crash if getcwd() fails.
-    - Fixed alignment of "called for preprocessing" counter.
+    - Don't crash if `getcwd()` fails.
+    - Fixed alignment of ``called for preprocessing'' counter.
 
 
 ccache 3.1.5
index 7b50eb9..53773cc 100644 (file)
@@ -532,7 +532,7 @@ footnotes: function () {
 <body class="article">\r
 <div id="header">\r
 <h1>ccache README</h1>\r
-<span id="revnumber">version 3.1.6</span>\r
+<span id="revnumber">version 3.1.7</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>
@@ -628,8 +628,8 @@ Thiele&#8217;s &#8220;compilercache&#8221; (see <a href="http://www.erikyyy.de/c
 <div id="footnotes"><hr /></div>\r
 <div id="footer">\r
 <div id="footer-text">\r
-Version 3.1.6<br />\r
-Last updated 2010-09-16 19:02:32 CEST\r
+Version 3.1.7<br />\r
+Last updated 2011-09-17 23:53:29 CEST\r
 </div>\r
 </div>\r
 </body>\r
index 950b876..0c16eea 100644 (file)
--- a/ccache.1
+++ b/ccache.1
@@ -2,12 +2,12 @@
 .\"     Title: ccache
 .\"    Author: [see the "Author" section]
 .\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
-.\"      Date: 08/21/2011
+.\"      Date: 01/08/2012
 .\"    Manual: ccache Manual
-.\"    Source: ccache 3.1.6
+.\"    Source: ccache 3.1.7
 .\"  Language: English
 .\"
-.TH "CCACHE" "1" "08/21/2011" "ccache 3\&.1\&.6" "ccache Manual"
+.TH "CCACHE" "1" "01/08/2012" "ccache 3\&.1\&.7" "ccache Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -1354,7 +1354,44 @@ PRECOMPILED HEADERS\&.
 If compilation doesn\(cqt work with ccache, but it works without it, one possible reason is that the compiler can\(cqt compile preprocessed output correctly\&. A workaround that may work is to set \fBCCACHE_CPP2\fR\&. This will make cache misses slower, though, so it is better to find and fix the root cause\&.
 .SS "Corrupt object files"
 .sp
-It should be noted that ccache is susceptible to general storage problems\&. If a bad object file sneaks into the cache for some reason, it will of course stay bad\&. Some possible reasons for erroneous object files are bad hardware (disk drive, disk controller, memory, etc), buggy drivers or file systems, a bad \fBCCACHE_PREFIX\fR command or compiler wrapper\&. If this happens, you can either find out which object file is broken by reading the debug log and then delete the bad object file from the cache, or you can simply clear the whole cache with \fBccache \-C\fR if you don\(cqt mind losing other cached results\&.
+It should be noted that ccache is susceptible to general storage problems\&. If a bad object file sneaks into the cache for some reason, it will of course stay bad\&. Some possible reasons for erroneous object files are bad hardware (disk drive, disk controller, memory, etc), buggy drivers or file systems, a bad \fBCCACHE_PREFIX\fR command or compiler wrapper\&. If this happens, the easiest way of fixing it is this:
+.sp
+.RS 4
+.ie n \{\
+\h'-04' 1.\h'+01'\c
+.\}
+.el \{\
+.sp -1
+.IP "  1." 4.2
+.\}
+Build so that the bad object file ends up in the build tree\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04' 2.\h'+01'\c
+.\}
+.el \{\
+.sp -1
+.IP "  2." 4.2
+.\}
+Remove the bad object file from the build tree\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04' 3.\h'+01'\c
+.\}
+.el \{\
+.sp -1
+.IP "  3." 4.2
+.\}
+Rebuild with
+\fBCCACHE_RECACHE\fR
+set\&.
+.RE
+.sp
+An alternative is to clear the whole cache with \fBccache \-C\fR if you don\(cqt mind losing other cached results\&.
 .sp
 There are no reported issues about ccache producing broken object files reproducibly\&. That doesn\(cqt mean it can\(cqt happen, so if you find a repeatable case, please report it\&.
 .SH "MORE INFORMATION"
index 3bb6d77..e41af13 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -2,7 +2,7 @@
  * ccache -- a fast C/C++ compiler cache
  *
  * Copyright (C) 2002-2007 Andrew Tridgell
- * Copyright (C) 2009-2011 Joel Rosdahl
+ * Copyright (C) 2009-2012 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
@@ -267,8 +267,7 @@ get_path_in_cache(const char *name, const char *suffix)
                free(path);
                path = p;
                if (create_dir(path) != 0) {
-                       cc_log("Failed to create %s: %s", path, strerror(errno));
-                       failed();
+                       fatal("Failed to create %s: %s", path, strerror(errno));
                }
        }
        result = format("%s/%s%s", path, name + nlevels, suffix);
@@ -530,7 +529,10 @@ to_cache(struct args *args)
        status = execute(args->argv, tmp_stdout, tmp_stderr);
        args_pop(args, 3);
 
-       if (stat(tmp_stdout, &st) != 0 || st.st_size != 0) {
+       if (stat(tmp_stdout, &st) != 0) {
+               fatal("Could not create %s (permission denied?)", tmp_stdout);
+       }
+       if (st.st_size != 0) {
                cc_log("Compiler produced stdout");
                stats_update(STATS_STDOUT);
                tmp_unlink(tmp_stdout);
@@ -791,6 +793,36 @@ update_cached_result_globals(struct file_hash *hash)
 }
 
 /*
+ * Hash mtime or content of a file, or the output of a command, according to
+ * the CCACHE_COMPILERCHECK setting.
+ */
+static void
+hash_compiler(struct mdfour *hash, struct stat *st, const char *path,
+              bool allow_command)
+{
+       const char *compilercheck;
+
+       compilercheck = getenv("CCACHE_COMPILERCHECK");
+       if (!compilercheck) {
+               compilercheck = "mtime";
+       }
+       if (str_eq(compilercheck, "none")) {
+               /* Do nothing. */
+       } else if (str_eq(compilercheck, "mtime")) {
+               hash_delimiter(hash, "cc_mtime");
+               hash_int(hash, st->st_size);
+               hash_int(hash, st->st_mtime);
+       } else if (str_eq(compilercheck, "content") || !allow_command) {
+               hash_delimiter(hash, "cc_content");
+               hash_file(hash, path);
+       } else { /* command string */
+               if (!hash_multicommand_output(hash, compilercheck, orig_args->argv[0])) {
+                       fatal("Failure running compiler check command: %s", compilercheck);
+               }
+       }
+}
+
+/*
  * Update a hash sum with information common for the direct and preprocessor
  * modes.
  */
@@ -798,7 +830,6 @@ static void
 calculate_common_hash(struct args *args, struct mdfour *hash)
 {
        struct stat st;
-       const char *compilercheck;
        char *p;
 
        hash_string(hash, HASH_PREFIX);
@@ -819,31 +850,16 @@ calculate_common_hash(struct args *args, struct mdfour *hash)
        /*
         * Hash information about the compiler.
         */
-       compilercheck = getenv("CCACHE_COMPILERCHECK");
-       if (!compilercheck) {
-               compilercheck = "mtime";
-       }
-       if (str_eq(compilercheck, "none")) {
-               /* Do nothing. */
-       } else if (str_eq(compilercheck, "content")) {
-               hash_delimiter(hash, "cc_content");
-               hash_file(hash, args->argv[0]);
-       } else if (str_eq(compilercheck, "mtime")) {
-               hash_delimiter(hash, "cc_mtime");
-               hash_int(hash, st.st_size);
-               hash_int(hash, st.st_mtime);
-       } else { /* command string */
-               if (!hash_multicommand_output(hash, compilercheck, orig_args->argv[0])) {
-                       fatal("Failure running compiler check command: %s", compilercheck);
-               }
-       }
+       hash_compiler(hash, &st, args->argv[0], true);
 
        /*
         * Also hash the compiler name as some compilers use hard links and
         * behave differently depending on the real name.
         */
        hash_delimiter(hash, "cc_name");
-       hash_string(hash, basename(args->argv[0]));
+       p = basename(args->argv[0]);
+       hash_string(hash, p);
+       free(p);
 
        /* Possibly hash the current working directory. */
        if (getenv("CCACHE_HASHDIR")) {
@@ -886,6 +902,7 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
        struct stat st;
        int result;
        struct file_hash *object_hash = NULL;
+       char *p;
 
        /* first the arguments */
        for (i = 1; i < args->argc; i++) {
@@ -913,14 +930,24 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
                        }
                }
 
-               if (str_startswith(args->argv[i], "--specs=") &&
-                   stat(args->argv[i] + 8, &st) == 0) {
-                       /* If given a explicit specs file, then hash that file,
+               p = NULL;
+               if (str_startswith(args->argv[i], "-specs=")) {
+                       p = args->argv[i] + 7;
+               } else if (str_startswith(args->argv[i], "--specs=")) {
+                       p = args->argv[i] + 8;
+               }
+               if (p && stat(p, &st) == 0) {
+                       /* If given an explicit specs file, then hash that file,
                           but don't include the path to it in the hash. */
                        hash_delimiter(hash, "specs");
-                       if (!hash_file(hash, args->argv[i] + 8)) {
-                               failed();
-                       }
+                       hash_compiler(hash, &st, p, false);
+                       continue;
+               }
+
+               if (str_startswith(args->argv[i], "-fplugin=")
+                   && stat(args->argv[i] + 9, &st) == 0) {
+                       hash_delimiter(hash, "plugin");
+                       hash_compiler(hash, &st, args->argv[i] + 9, false);
                        continue;
                }
 
@@ -930,6 +957,24 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
        }
 
        if (direct_mode) {
+               /* Hash environment variables that affect the preprocessor output. */
+               const char **p;
+               const char *envvars[] = {
+                       "CPATH",
+                       "C_INCLUDE_PATH",
+                       "CPLUS_INCLUDE_PATH",
+                       "OBJC_INCLUDE_PATH",
+                       "OBJCPLUS_INCLUDE_PATH", /* clang */
+                       NULL
+               };
+               for (p = envvars; *p != NULL ; ++p) {
+                       char *v = getenv(*p);
+                       if (v) {
+                               hash_delimiter(hash, *p);
+                               hash_string(hash, v);
+                       }
+               }
+
                if (!(sloppiness & SLOPPY_FILE_MACRO)) {
                        /*
                         * The source code file or an include file may contain
@@ -1389,6 +1434,7 @@ cc_process_args(struct args *orig_args, struct args **preprocessor_args,
                        continue;
                }
                if (str_startswith(argv[i], "-MQ") || str_startswith(argv[i], "-MT")) {
+                       dependency_target_specified = true;
                        args_add(dep_args, argv[i]);
                        if (strlen(argv[i]) == 3) {
                                /* -MQ arg or -MT arg */
@@ -1400,13 +1446,6 @@ cc_process_args(struct args *orig_args, struct args **preprocessor_args,
                                }
                                args_add(dep_args, argv[i + 1]);
                                i++;
-                               /*
-                                * Yes, that's right. It's strange, but apparently, GCC behaves
-                                * differently for -MT arg and -MTarg (and similar for -MQ): in the
-                                * latter case, but not in the former, an implicit dependency for the
-                                * object file is added to the dependency file.
-                                */
-                               dependency_target_specified = true;
                        }
                        continue;
                }
@@ -1824,6 +1863,14 @@ ccache(int argc, char *argv[])
                failed();
        }
 
+       if (!getenv("CCACHE_READONLY")) {
+               if (create_cachedirtag(cache_dir) != 0) {
+                       cc_log("failed to create %s/CACHEDIR.TAG (%s)\n",
+                               cache_dir, strerror(errno));
+                       failed();
+               }
+       }
+
        sloppiness = parse_sloppiness(getenv("CCACHE_SLOPPINESS"));
 
        cc_log_argv("Command line: ", argv);
@@ -1835,7 +1882,7 @@ ccache(int argc, char *argv[])
        }
 
        if (getenv("CCACHE_UNIFY")) {
-               cc_log("Unify mode disabled");
+               cc_log("Unify mode enabled");
                enable_unify = true;
        }
 
@@ -2176,15 +2223,6 @@ ccache_main(int argc, char *argv[])
                exit(1);
        }
 
-       if (!getenv("CCACHE_READONLY")) {
-               if (create_cachedirtag(cache_dir) != 0) {
-                       fprintf(stderr,
-                               "ccache: failed to create %s/CACHEDIR.TAG (%s)\n",
-                               cache_dir, strerror(errno));
-                       exit(1);
-               }
-       }
-
        ccache(argc, argv);
        return 1;
 }
index c2536f5..2bc7c87 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -191,7 +191,6 @@ int execute(char **argv,
             const char *path_stderr);
 char *find_executable(const char *name, const char *exclude_name);
 void print_command(FILE *fp, char **argv);
-void print_executed_command(FILE *fp, char **argv);
 
 /* ------------------------------------------------------------------------- */
 /* lockfile.c */
index 80e327e..f1970d3 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -301,10 +301,3 @@ print_command(FILE *fp, char **argv)
        }
        fprintf(fp, "\n");
 }
-
-void
-print_executed_command(FILE *fp, char **argv)
-{
-       fprintf(fp, "%s: executing ", MYNAME);
-       print_command(fp, argv);
-}
index fcc163d..335874b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009-2010 Joel Rosdahl
+ * Copyright (C) 2009-2010, 2012 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
@@ -133,6 +133,7 @@ free_manifest(struct manifest *mf)
                free(mf->objects[i].file_info_indexes);
        }
        free(mf->objects);
+       free(mf);
 }
 
 #define READ_INT(size, var) \
index 6547dc0..8d5b9a7 100644 (file)
--- a/mdfour.c
+++ b/mdfour.c
@@ -1,19 +1,19 @@
 /*
  * Copyright (C) 1997-1998 Andrew Tridgell
  *
- * 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 Foundation; either version 3 of the License, or
- * (at your option) any later version.
+ * 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 Foundation; either version 3 of the License, or (at your option)
+ * any later version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include "ccache.h"
diff --git a/packaging/ccache.changes b/packaging/ccache.changes
deleted file mode 100644 (file)
index 7a20353..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
--------------------------------------------------------------------
-Sun Aug 21 18:24:58 UTC 2011 - asterios.dramis@gmail.com
-
-- update to ccache-3.1.6
-  - Rewrite argument to --sysroot if CCACHE_BASEDIR is used.
-  - Don't crash if getcwd() fails.
-  - Fixed alignment of "called for preprocessing" counter.
-
--------------------------------------------------------------------
-Mon Jun  6 14:52:55 UTC 2011 - puzel@novell.com
-
-- update to ccache-3.1.5
-  - Added a new statistics counter named ``called for
-    preprocessing''.
-  - The original command line is now logged to the file specified
-    with `CCACHE_LOGFILE`.
-  - Improved error logging when system calls fail.
-  - Added support for rewriting absolute paths in
-    `-F`/`-iframework` GCC options.
-  - Improved order of statistics counters in `ccache -s` output.
-  - The `-MF`/`-MT`/`-MQ` options with concatenated argument are
-    now handled correctly when they are last on the commandline.
-  - ccache is now bug compatible with GCC for the `-MT`/`-MQ`
-    options with concatenated arguments.
-  - Fixed a minor memory leak.
-  - Systems that lack (and don't need to be linked with) libm are
-    now supported.
-
--------------------------------------------------------------------
-Wed Feb 16 18:19:41 UTC 2011 - asterios.dramis@gmail.com
-
-- update to ccache-3.1.4
-  - Made a work-around for a bug in gzputc() in zlib 1.2.5.
-  - Corrupt manifest files are now removed so that they won't block direct
-    mode hits.
-  - ccache now copes with file systems that don't know about symbolic links.
-  - The file handle in now correctly closed on write error when trying to
-    create a cache dir tag.
-- Spec file updates:
-  - Changes based on rpmdevtools templates and spec-cleaner run.
-  - Updated Summary: and %description.
-  - Made it compile with external zlib instead of the bundled copy.
-  - Added also the html files in the %doc section.
-
--------------------------------------------------------------------
-Mon Nov 29 09:56:02 UTC 2010 - puzel@novell.com
-
-- update to ccache-3.1.3 
-  - The -MFarg, -MTarg and -MQarg compiler options (i.e, without
-    space between option and argument) are now handled correctly.
-
--------------------------------------------------------------------
-Mon Nov 22 10:58:50 UTC 2010 - puzel@novell.com
-
-- update to ccache-3.1.2 
-  - bail out on too hard compiler options '-fdump-*'
-  - NULL return values from malloc/calloc of zero bytes are now
-    handled correctly
-  - improved documentation on which information is included in the
-    hash sum
-  - made the 'too new header file' test case work on file systems
-    with unsynchronized clocks
-  - the test suite now also works on systems that lack a /dev/zero
-
--------------------------------------------------------------------
-Mon Nov  8 09:46:57 UTC 2010 - puzel@novell.com
-
-- update to ccache-3.1.1 
-  - ccache now falls back to preprocessor mode when a non-regular
-    include file (device, socket, etc) has been detected so that
-    potential hanging due to blocking reads is avoided.
-  - CRC errors are now detected when decompressing compressed files
-    in the cache.
-  - Fixed potential object file corruption race on NFS.
-  - Minor documentation corrections.
-  - Fixed configure detection of ar.
-  - ccache development version (set by dev.mk) now works with gits
-    whose `describe` command doesn't understand `--dirty`.
-
--------------------------------------------------------------------
-Fri Sep 17 09:22:59 UTC 2010 - puzel@novell.com
-
-- update to ccache-3.1 
- - features:
-  - Added support for hashing the output of a custom command
-    (e.g. `$compiler --version`) to identify the compiler
-    instead of stat-ing or hashing the compiler binary.   
-  - Added support for caching compilations that use precompiled
-    headers.
-  - Locking of the files containing statistics counters is now
-    done using symlinks instead of POSIX locks.  
-  - Manifest files are now updated without the need of taking
-    locks.
-  - Added `.cp` and `.CP` as known C++ suffixes.
-  - Improved logging.
- - bugfixes:
-  - Non-fatal error messages are now never printed to stderr but
-    logged instead.
-  - Fixed a bug affecting failing commands when `--ccache-skip` is
-    used.
-  - Made `--ccache-skip` work for all options.
-  - EINTR is now handled correctly.
-
--------------------------------------------------------------------
-Fri Jul 16 08:15:51 UTC 2010 - puzel@novell.com
-
-- update to ccache-3.0.1 
- - bugfixes:
-  - The statistics counter ``called for link'' is now correctly 
-    updated when linking with a single object file.
-  - Fixed a problem with out-of-source builds.
-
--------------------------------------------------------------------
-Mon Jul 12 11:43:54 UTC 2010 - puzel@novell.com
-
-- update to ccache-3.0
- - notable changes:
- - The way the hashes are calculated has changed, so you won't get
-   cache hits for compilation results stored by older ccache
-   versions. Because of this, you might as well clear the old
-   cache directory with `ccache --clear` if you want, unless you
-   plan to keep using an older ccache version.
- - ccache now has a ``direct mode'' where it computes a hash of
-   the source code (including all included files) and compiler
-   options without running the preprocessor. By not running the
-   preprocessor, CPU usage is reduced; the speed is somewhere
-   between 1 and 5 times that of ccache running in traditional
-   mode, depending on the circumstances. The speedup will be
-   higher when I/O is fast (e.g., when files are in the disk
-   cache).  The direct mode can be disabled by setting
-   +CCACHE_NODIRECT+.
- - Support has been added for rewriting absolute paths to relative
-   paths when hashing, in order to increase cache hit rate when
-   building the same source code in different directories even
-   when compiling with `-g` and when using absolute include
-   directory paths. This is done by setting the `CCACHE_BASEDIR`
-   environment variable to an absolute path that specifies which
-   paths to rewrite.
- - Object files are now optionally stored compressed in the cache.
-   The runtime cost is negligible, and more files will fit in the
-   ccache directory and in the disk cache. Set `CCACHE_COMPRESS`
-   to enable object file compression. Note that you can't use
-   compression in combination with the hard link feature.
- - A `CCACHE_COMPILERCHECK` option has been added. This option
-   tells ccache what compiler-identifying information to hash to
-   ensure that results retrieved from the cache are accurate.
-   Possible values are: none (don't hash anything), mtime (hash
-   the compiler's mtime and size) and content (hash the content of
-   the compiler binary). The default is mtime.
-- see /usr/share/doc/packages/ccache/NEWS.txt for complete
-  release notes
-
--------------------------------------------------------------------
-Wed Jan 25 21:34:51 CET 2006 - mls@suse.de
-
-- converted neededforbuild to BuildRequires
-
--------------------------------------------------------------------
-Thu Sep 29 03:16:43 CEST 2005 - dmueller@suse.de
-
- - add norootforbuild
-
--------------------------------------------------------------------
-Wed Sep 28 23:24:29 CEST 2005 - dmueller@suse.de
-
-- add norootforbuild 
-
--------------------------------------------------------------------
-Thu Oct 21 11:56:47 CEST 2004 - ltinkl@suse.cz
-
-- update to version 2.4
-
--------------------------------------------------------------------
-Mon Sep 29 11:38:06 CEST 2003 - ltinkl@suse.cz
-
-- update to version 2.3
-
--------------------------------------------------------------------
-Wed Jul 09 13:28:43 CEST 2003 - ltinkl@suse.cz
-
-- updated sources to version 2.2
-
--------------------------------------------------------------------
-Fri Mar 28 15:38:13 CET 2003 - vbobek@suse.cz
-
-- provides binary from older distcc package [#25806]
-
--------------------------------------------------------------------
-Mon Feb 10 14:32:44 CET 2003 - vbobek@suse.cz
-
-- initial suse release 2.1.1
-
diff --git a/packaging/ccache.manifest b/packaging/ccache.manifest
deleted file mode 100644 (file)
index 017d22d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
- <request>
-    <domain name="_"/>
- </request>
-</manifest>
diff --git a/packaging/ccache.spec b/packaging/ccache.spec
deleted file mode 100644 (file)
index 82efc69..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# spec file for package ccache
-#
-# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
-#
-# All modifications and additions to the file contributed by third parties
-# remain the property of their copyright owners, unless otherwise agreed
-# upon. The license for this file, and modifications and additions to the
-# file, is the same license as for the pristine package itself (unless the
-# license for the pristine package is not an Open Source License, in which
-# case the license is the MIT License). An "Open Source License" is a
-# license that conforms to the Open Source Definition (Version 1.9)
-# published by the Open Source Initiative.
-
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
-#
-
-# norootforbuild
-
-
-Name:           ccache
-Version:        3.1.6
-Release:        1
-Summary:        A Fast C/C++ Compiler Cache
-
-License:        GPLv3+
-Url:            http://ccache.samba.org/
-Group:          Development/Languages/C and C++
-Source0:        http://samba.org/ftp/ccache/%{name}-%{version}.tar.bz2
-Source1001:    ccache.manifest
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-
-BuildRequires:  zlib-devel
-Provides:       distcc:/usr/bin/ccache
-
-%description
-ccache is a compiler cache. It speeds up recompilation by caching the result of
-previous compilations and detecting when the same compilation is being done
-again. Supported languages are C, C++, Objective-C and Objective-C++.
-
-%prep
-%setup -q
-cp %{SOURCE1001} .
-
-%build
-%configure
-make %{?_smp_mflags}
-
-%install
-make install DESTDIR=%{buildroot}
-
-%clean
-rm -rf %{buildroot}
-
-%files
-%manifest %{name}.manifest
-%defattr(-,root,root,-)
-%doc AUTHORS.* GPL-3.0.txt INSTALL.* LICENSE.* MANUAL.* NEWS.* README.*
-%doc %{_mandir}/man1/ccache.1%{ext_man}
-%{_bindir}/ccache
-
-%changelog
diff --git a/test.sh b/test.sh
index 85f1baa..5f33a67 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -3,7 +3,7 @@
 # A simple test suite for ccache.
 #
 # Copyright (C) 2002-2007 Andrew Tridgell
-# Copyright (C) 2009-2011 Joel Rosdahl
+# Copyright (C) 2009-2012 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
@@ -1158,6 +1158,40 @@ EOF
     checkstat 'cache hit (direct)' 1
     checkstat 'cache hit (preprocessed)' 0
     checkstat 'cache miss' 1
+
+    ##################################################################
+    # Check that environment variables that affect the preprocessor are taken
+    # into account.
+    testname="environment variables"
+    $CCACHE -Cz >/dev/null
+    rm -rf subdir1 subdir2
+    mkdir subdir1 subdir2
+    cat <<EOF >subdir1/foo.h
+int foo;
+EOF
+    cat <<EOF >subdir2/foo.h
+int foo;
+EOF
+    cat <<EOF >foo.c
+#include <foo.h>
+EOF
+    backdate subdir1/foo.h subdir2/foo.h
+    CPATH=subdir1 $CCACHE $COMPILER -c foo.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 1
+    CPATH=subdir1 $CCACHE $COMPILER -c foo.c
+    checkstat 'cache hit (direct)' 1
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 1
+    CPATH=subdir2 $CCACHE $COMPILER -c foo.c
+    checkstat 'cache hit (direct)' 1
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 2 # subdir2 is part of the preprocessor output
+    CPATH=subdir2 $CCACHE $COMPILER -c foo.c
+    checkstat 'cache hit (direct)' 2
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 2
 }
 
 basedir_suite() {
index e6de579..94e46f4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2011 Joel Rosdahl
+ * Copyright (C) 2010-2012 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
@@ -197,12 +197,12 @@ TEST(MT_flag_without_immediate_argument_should_not_add_MTobj)
        args_free(orig);
 }
 
-TEST(MQ_flag_with_immediate_argument_should_add_MQobj)
+TEST(MQ_flag_with_immediate_argument_should_not_add_MQobj)
 {
        struct args *orig = args_init_from_string(
                "gcc -c -MD -MP -MFfoo.d -MQfoo.d foo.c");
        struct args *exp_cpp = args_init_from_string(
-               "gcc -c -MD -MP -MFfoo.d -MQfoo.d -MQ foo.o");
+               "gcc -c -MD -MP -MFfoo.d -MQfoo.d");
        struct args *exp_cc = args_init_from_string(
                "gcc -c");
        struct args *act_cpp = NULL, *act_cc = NULL;
@@ -215,12 +215,12 @@ TEST(MQ_flag_with_immediate_argument_should_add_MQobj)
        args_free(orig);
 }
 
-TEST(MT_flag_with_immediate_argument_should_add_MQobj)
+TEST(MT_flag_with_immediate_argument_should_not_add_MQobj)
 {
        struct args *orig = args_init_from_string(
                "gcc -c -MD -MP -MFfoo.d -MTfoo.d foo.c");
        struct args *exp_cpp = args_init_from_string(
-               "gcc -c -MD -MP -MFfoo.d -MTfoo.d -MQ foo.o");
+               "gcc -c -MD -MP -MFfoo.d -MTfoo.d");
        struct args *exp_cc = args_init_from_string(
                "gcc -c");
        struct args *act_cpp = NULL, *act_cc = NULL;
diff --git a/util.c b/util.c
index 1be5f08..3086b2c 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2002 Andrew Tridgell
- * Copyright (C) 2009-2011 Joel Rosdahl
+ * Copyright (C) 2009-2012 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
@@ -1101,15 +1101,19 @@ x_unlink(const char *path)
         * file. We don't care if the temp file is trashed, so it's always safe to
         * unlink it first.
         */
-       const char* tmp_name = format("%s.%s.rmXXXXXX", path, tmp_string());
+       char* tmp_name = format("%s.%s.rmXXXXXX", path, tmp_string());
+       int result = 0;
        cc_log("Unlink %s via %s", path, tmp_name);
        if (x_rename(path, tmp_name) == -1) {
-               return -1;
+               result = -1;
+               goto out;
        }
        if (unlink(tmp_name) == -1) {
-               return -1;
+               result = -1;
        }
-       return 0;
+out:
+       free(tmp_name);
+       return result;
 }
 
 #ifndef _WIN32
index 5081b0b..1f031ea 100644 (file)
--- a/version.c
+++ b/version.c
@@ -1 +1 @@
-const char CCACHE_VERSION[] = "3.1.6";
+const char CCACHE_VERSION[] = "3.1.7";
index 704b748..f658a9e 100644 (file)
@@ -293,7 +293,7 @@ local unsigned long crc32_little(crc, buf, len)
 }
 
 /* ========================================================================= */
-#define DOBIG4 c ^= *buf4++; \
+#define DOBIG4 c ^= *++buf4; \
         c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
             crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
 #define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
@@ -315,6 +315,7 @@ local unsigned long crc32_big(crc, buf, len)
     }
 
     buf4 = (const u4 FAR *)(const void FAR *)buf;
+    buf4--;
     while (len >= 32) {
         DOBIG32;
         len -= 32;
@@ -323,6 +324,7 @@ local unsigned long crc32_big(crc, buf, len)
         DOBIG4;
         len -= 4;
     }
+    buf4++;
     buf = (const unsigned char FAR *)buf4;
 
     if (len) do {
index 1fd6467..bbee92e 100644 (file)
 
 #ifndef ASMINF
 
+/* Allow machine dependent optimization for post-increment or pre-increment.
+   Based on testing to date,
+   Pre-increment preferred for:
+   - PowerPC G3 (Adler)
+   - MIPS R5000 (Randers-Pehrson)
+   Post-increment preferred for:
+   - none
+   No measurable difference:
+   - Pentium III (Anderson)
+   - M68060 (Nikl)
+ */
+#ifdef POSTINC
+#  define OFF 0
+#  define PUP(a) *(a)++
+#else
+#  define OFF 1
+#  define PUP(a) *++(a)
+#endif
+
 /*
    Decode literal, length, and distance codes and write out the resulting
    literal and match bytes until either not enough input or output is
@@ -77,9 +96,9 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
 
     /* copy state to local variables */
     state = (struct inflate_state FAR *)strm->state;
-    in = strm->next_in;
+    in = strm->next_in - OFF;
     last = in + (strm->avail_in - 5);
-    out = strm->next_out;
+    out = strm->next_out - OFF;
     beg = out - (start - strm->avail_out);
     end = out + (strm->avail_out - 257);
 #ifdef INFLATE_STRICT
@@ -100,9 +119,9 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
        input data or output space */
     do {
         if (bits < 15) {
-            hold += (unsigned long)(*in++) << bits;
+            hold += (unsigned long)(PUP(in)) << bits;
             bits += 8;
-            hold += (unsigned long)(*in++) << bits;
+            hold += (unsigned long)(PUP(in)) << bits;
             bits += 8;
         }
         this = lcode[hold & lmask];
@@ -115,14 +134,14 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
             Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
                     "inflate:         literal '%c'\n" :
                     "inflate:         literal 0x%02x\n", this.val));
-            *out++ = (unsigned char)(this.val);
+            PUP(out) = (unsigned char)(this.val);
         }
         else if (op & 16) {                     /* length base */
             len = (unsigned)(this.val);
             op &= 15;                           /* number of extra bits */
             if (op) {
                 if (bits < op) {
-                    hold += (unsigned long)(*in++) << bits;
+                    hold += (unsigned long)(PUP(in)) << bits;
                     bits += 8;
                 }
                 len += (unsigned)hold & ((1U << op) - 1);
@@ -131,9 +150,9 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
             }
             Tracevv((stderr, "inflate:         length %u\n", len));
             if (bits < 15) {
-                hold += (unsigned long)(*in++) << bits;
+                hold += (unsigned long)(PUP(in)) << bits;
                 bits += 8;
-                hold += (unsigned long)(*in++) << bits;
+                hold += (unsigned long)(PUP(in)) << bits;
                 bits += 8;
             }
             this = dcode[hold & dmask];
@@ -146,10 +165,10 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
                 dist = (unsigned)(this.val);
                 op &= 15;                       /* number of extra bits */
                 if (bits < op) {
-                    hold += (unsigned long)(*in++) << bits;
+                    hold += (unsigned long)(PUP(in)) << bits;
                     bits += 8;
                     if (bits < op) {
-                        hold += (unsigned long)(*in++) << bits;
+                        hold += (unsigned long)(PUP(in)) << bits;
                         bits += 8;
                     }
                 }
@@ -172,13 +191,13 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
                         state->mode = BAD;
                         break;
                     }
-                    from = window;
+                    from = window - OFF;
                     if (write == 0) {           /* very common case */
                         from += wsize - op;
                         if (op < len) {         /* some from window */
                             len -= op;
                             do {
-                                *out++ = *from++;
+                                PUP(out) = PUP(from);
                             } while (--op);
                             from = out - dist;  /* rest from output */
                         }
@@ -189,14 +208,14 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
                         if (op < len) {         /* some from end of window */
                             len -= op;
                             do {
-                                *out++ = *from++;
+                                PUP(out) = PUP(from);
                             } while (--op);
-                            from = window;
+                            from = window - OFF;
                             if (write < len) {  /* some from start of window */
                                 op = write;
                                 len -= op;
                                 do {
-                                    *out++ = *from++;
+                                    PUP(out) = PUP(from);
                                 } while (--op);
                                 from = out - dist;      /* rest from output */
                             }
@@ -207,35 +226,35 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
                         if (op < len) {         /* some from window */
                             len -= op;
                             do {
-                                *out++ = *from++;
+                                PUP(out) = PUP(from);
                             } while (--op);
                             from = out - dist;  /* rest from output */
                         }
                     }
                     while (len > 2) {
-                        *out++ = *from++;
-                        *out++ = *from++;
-                        *out++ = *from++;
+                        PUP(out) = PUP(from);
+                        PUP(out) = PUP(from);
+                        PUP(out) = PUP(from);
                         len -= 3;
                     }
                     if (len) {
-                        *out++ = *from++;
+                        PUP(out) = PUP(from);
                         if (len > 1)
-                            *out++ = *from++;
+                            PUP(out) = PUP(from);
                     }
                 }
                 else {
                     from = out - dist;          /* copy direct from output */
                     do {                        /* minimum length is three */
-                        *out++ = *from++;
-                        *out++ = *from++;
-                        *out++ = *from++;
+                        PUP(out) = PUP(from);
+                        PUP(out) = PUP(from);
+                        PUP(out) = PUP(from);
                         len -= 3;
                     } while (len > 2);
                     if (len) {
-                        *out++ = *from++;
+                        PUP(out) = PUP(from);
                         if (len > 1)
-                            *out++ = *from++;
+                            PUP(out) = PUP(from);
                     }
                 }
             }
@@ -272,8 +291,8 @@ unsigned start;         /* inflate()'s starting value for strm->avail_out */
     hold &= (1U << bits) - 1;
 
     /* update state and return */
-    strm->next_in = in;
-    strm->next_out = out;
+    strm->next_in = in + OFF;
+    strm->next_out = out + OFF;
     strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
     strm->avail_out = (unsigned)(out < end ?
                                  257 + (end - out) : 257 - (out - end));
index ccbba61..8a9c13f 100644 (file)
@@ -54,7 +54,7 @@ unsigned short FAR *work;
     code FAR *next;             /* next available space in table */
     const unsigned short FAR *base;     /* base value table to use */
     const unsigned short FAR *extra;    /* extra bits table to use */
-    unsigned match;             /* use base and extra for symbol >= match */
+    int end;                    /* use base and extra for symbol > end */
     unsigned short count[MAXBITS+1];    /* number of codes of each length */
     unsigned short offs[MAXBITS+1];     /* offsets in table for each length */
     static const unsigned short lbase[31] = { /* Length codes 257..285 base */
@@ -182,17 +182,19 @@ unsigned short FAR *work;
     switch (type) {
     case CODES:
         base = extra = work;    /* dummy value--not used */
-        match = 20;
+        end = 19;
         break;
     case LENS:
         base = lbase;
+        base -= 257;
         extra = lext;
-        match = 257;
+        extra -= 257;
+        end = 256;
         break;
     default:            /* DISTS */
         base = dbase;
         extra = dext;
-        match = 0;
+        end = -1;
     }
 
     /* initialize state for loop */
@@ -214,13 +216,13 @@ unsigned short FAR *work;
     for (;;) {
         /* create table entry */
         this.bits = (unsigned char)(len - drop);
-        if (work[sym] + 1 < match) {
+        if ((int)(work[sym]) < end) {
             this.op = (unsigned char)0;
             this.val = work[sym];
         }
-        else if (work[sym] >= match) {
-            this.op = (unsigned char)(extra[work[sym] - match]);
-            this.val = base[work[sym] - match];
+        else if ((int)(work[sym]) > end) {
+            this.op = (unsigned char)(extra[work[sym]]);
+            this.val = base[work[sym]];
         }
         else {
             this.op = (unsigned char)(32 + 64);         /* end of block */