--- Begin Message ---
Package: release.debian.org
User: release.debian....@packages.debian.org
Usertags: pu
Tags: jessie
Severity: normal
As suggested by Stefan Fritsch in #829088 ("ccache may silently
miscompile symlinked source files"), I propose to upgrade ccache from
3.1.10 to 3.1.12 in jessie. I'm the upstream maintainer of ccache as
well and I made the 3.1.12 release specifically for Debian stable to fix
#829088. Upgrading from 3.1.10 to 3.1.12 would also include three other
bug fixes that I think would be good to have in jessie.
Here's a summary of the bug fixes:
>From 3.1.12:
- Fixes a bug where (due to ccache rewriting paths) the compiler could
choose incorrect include files if CCACHE_BASEDIR is used and the
source file path is absolute and is a symlink. (Closes: #829088.)
>From 3.1.11:
- Fixes a bug which could result in false cache hits when source code
contains '"' followed by " /*" or " //" (with variations).
- Makes hash of cached result created with and without CCACHE_CPP2
different. This makes it possible to rebuild with CCACHE_CPP2 set
without having to clear the cache to get new results.
- Fixes a bug which could result in "No such file or directory" messages
in the ccache log when the cache directory doesn't exist.
See attachment for the proposed update diff.
-- Joel
diff -Nru ccache-3.1.10/AUTHORS.html ccache-3.1.12/AUTHORS.html
--- ccache-3.1.10/AUTHORS.html 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/AUTHORS.html 2016-07-12 21:34:50.000000000 +0200
@@ -734,7 +734,7 @@
<body class="article">
<div id="header">
<h1>ccache authors</h1>
-<span id="revnumber">version 3.1.10</span>
+<span id="revnumber">version 3.1.12</span>
<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>
@@ -915,8 +915,9 @@
<div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
-Version 3.1.10<br />
-Last updated 2014-10-19 19:05:10 CEST
+Version 3.1.12<br />
+Last updated
+ 2016-07-12 21:34:27 CEST
</div>
</div>
</body>
diff -Nru ccache-3.1.10/INSTALL.html ccache-3.1.12/INSTALL.html
--- ccache-3.1.10/INSTALL.html 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/INSTALL.html 2016-07-12 21:34:50.000000000 +0200
@@ -734,7 +734,7 @@
<body class="article">
<div id="header">
<h1>ccache installation</h1>
-<span id="revnumber">version 3.1.10</span>
+<span id="revnumber">version 3.1.12</span>
<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>
@@ -843,8 +843,9 @@
<div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
-Version 3.1.10<br />
-Last updated 2014-10-19 19:02:09 CEST
+Version 3.1.12<br />
+Last updated
+ 2016-07-12 21:34:27 CEST
</div>
</div>
</body>
diff -Nru ccache-3.1.10/LICENSE.html ccache-3.1.12/LICENSE.html
--- ccache-3.1.10/LICENSE.html 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/LICENSE.html 2016-07-12 21:34:50.000000000 +0200
@@ -734,7 +734,7 @@
<body class="article">
<div id="header">
<h1>ccache copyright and license</h1>
-<span id="revnumber">version 3.1.10</span>
+<span id="revnumber">version 3.1.12</span>
<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>
@@ -776,7 +776,7 @@
<div class="listingblock">
<div class="content">
<pre><code> Copyright (C) 2002-2007 Andrew Tridgell
- Copyright (C) 2009-2011 Joel Rosdahl</code></pre>
+ Copyright (C) 2009-2016 Joel Rosdahl</code></pre>
</div></div>
</div>
</div>
@@ -1210,8 +1210,9 @@
<div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
-Version 3.1.10<br />
-Last updated 2014-10-19 19:02:09 CEST
+Version 3.1.12<br />
+Last updated
+ 2016-07-12 21:34:27 CEST
</div>
</div>
</body>
diff -Nru ccache-3.1.10/LICENSE.txt ccache-3.1.12/LICENSE.txt
--- ccache-3.1.10/LICENSE.txt 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/LICENSE.txt 2016-07-12 21:34:50.000000000 +0200
@@ -38,7 +38,7 @@
-------------------------------------------------------------------------------
Copyright (C) 2002-2007 Andrew Tridgell
- Copyright (C) 2009-2011 Joel Rosdahl
+ Copyright (C) 2009-2016 Joel Rosdahl
-------------------------------------------------------------------------------
diff -Nru ccache-3.1.10/MANUAL.html ccache-3.1.12/MANUAL.html
--- ccache-3.1.10/MANUAL.html 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/MANUAL.html 2016-07-12 21:34:50.000000000 +0200
@@ -734,7 +734,7 @@
<body class="article">
<div id="header">
<h1>CCACHE(1)</h1>
-<span id="revnumber">version 3.1.10</span>
+<span id="revnumber">version 3.1.12</span>
<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>
@@ -2014,8 +2014,9 @@
<div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
-Version 3.1.10<br />
-Last updated 2014-10-19 19:02:09 CEST
+Version 3.1.12<br />
+Last updated
+ 2016-07-12 21:34:27 CEST
</div>
</div>
</body>
diff -Nru ccache-3.1.10/NEWS.html ccache-3.1.12/NEWS.html
--- ccache-3.1.10/NEWS.html 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/NEWS.html 2016-07-12 21:34:50.000000000 +0200
@@ -734,7 +734,7 @@
<body class="article">
<div id="header">
<h1>ccache news</h1>
-<span id="revnumber">version 3.1.10</span>
+<span id="revnumber">version 3.1.12</span>
<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>
@@ -742,6 +742,55 @@
</div>
<div id="content">
<div class="sect1">
+<h2 id="_ccache_3_1_12">ccache 3.1.12</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Release date: 2016-07-12</p></div>
+<div class="sect2">
+<h3 id="_bug_fixes">Bug fixes</h3>
+<div class="ulist"><ul>
+<li>
+<p>
+Fixed a bug where (due to ccache rewriting paths) the compiler could choose
+ incorrect include files if <code>CCACHE_BASEDIR</code> is used and the
source file path
+ is absolute and is a symlink.
+</p>
+</li>
+</ul></div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ccache_3_1_11">ccache 3.1.11</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Release date: 2015-03-07</p></div>
+<div class="sect2">
+<h3 id="_bug_fixes_2">Bug fixes</h3>
+<div class="ulist"><ul>
+<li>
+<p>
+Fixed bug which could result in false cache hits when source code contains
+ <code>'"'</code> followed by <code>" /*"</code> or <code>" //"</code> (with
variations).
+</p>
+</li>
+<li>
+<p>
+Made hash of cached result created with and without <code>CCACHE_CPP2</code>
different.
+ This makes it possible to rebuild with <code>CCACHE_CPP2</code> set without
having to
+ clear the cache to get new results.
+</p>
+</li>
+<li>
+<p>
+Don’t try to reset a non-existing stats file. This avoids “No such
file or
+ directory” messages in the ccache log when the cache directory
doesn’t
+ exist.
+</p>
+</li>
+</ul></div>
+</div>
+</div>
+</div>
+<div class="sect1">
<h2 id="_ccache_3_1_10">ccache 3.1.10</h2>
<div class="sectionbody">
<div class="paragraph"><p>Release date: 2014-10-19</p></div>
@@ -785,7 +834,7 @@
<p>
To enable support for precompiled headers (PCH),
<code>CCACHE_SLOPPINESS</code> now also
needs to include the new <code>pch_defines</code> sloppiness. This is
because ccache
- can’t detect changes in the source code when only `#define`s have been
+ can’t detect changes in the source code when only defined macros have
been
changed.
</p>
</li>
@@ -798,7 +847,7 @@
</ul></div>
</div>
<div class="sect2">
-<h3 id="_bug_fixes">Bug fixes</h3>
+<h3 id="_bug_fixes_3">Bug fixes</h3>
<div class="ulist"><ul>
<li>
<p>
@@ -838,7 +887,7 @@
<div class="sectionbody">
<div class="paragraph"><p>Release date: 2013-01-06</p></div>
<div class="sect2">
-<h3 id="_bug_fixes_2">Bug fixes</h3>
+<h3 id="_bug_fixes_4">Bug fixes</h3>
<div class="ulist"><ul>
<li>
<p>
@@ -909,7 +958,7 @@
</ul></div>
</div>
<div class="sect2">
-<h3 id="_bug_fixes_3">Bug fixes</h3>
+<h3 id="_bug_fixes_5">Bug fixes</h3>
<div class="ulist"><ul>
<li>
<p>
@@ -957,7 +1006,7 @@
<div class="sectionbody">
<div class="paragraph"><p>Release date: 2012-01-08</p></div>
<div class="sect2">
-<h3 id="_bug_fixes_4">Bug fixes</h3>
+<h3 id="_bug_fixes_6">Bug fixes</h3>
<div class="ulist"><ul>
<li>
<p>
@@ -1040,7 +1089,7 @@
</ul></div>
</div>
<div class="sect2">
-<h3 id="_bug_fixes_5">Bug fixes</h3>
+<h3 id="_bug_fixes_7">Bug fixes</h3>
<div class="ulist"><ul>
<li>
<p>
@@ -1093,7 +1142,7 @@
</ul></div>
</div>
<div class="sect2">
-<h3 id="_bug_fixes_6">Bug fixes</h3>
+<h3 id="_bug_fixes_8">Bug fixes</h3>
<div class="ulist"><ul>
<li>
<p>
@@ -1126,7 +1175,7 @@
<div class="sectionbody">
<div class="paragraph"><p>Release date: 2011-01-09</p></div>
<div class="sect2">
-<h3 id="_bug_fixes_7">Bug fixes</h3>
+<h3 id="_bug_fixes_9">Bug fixes</h3>
<div class="ulist"><ul>
<li>
<p>
@@ -1159,7 +1208,7 @@
<div class="sectionbody">
<div class="paragraph"><p>Release date: 2010-11-28</p></div>
<div class="sect2">
-<h3 id="_bug_fixes_8">Bug fixes</h3>
+<h3 id="_bug_fixes_10">Bug fixes</h3>
<div class="ulist"><ul>
<li>
<p>
@@ -1186,7 +1235,7 @@
<div class="sectionbody">
<div class="paragraph"><p>Release date: 2010-11-21</p></div>
<div class="sect2">
-<h3 id="_bug_fixes_9">Bug fixes</h3>
+<h3 id="_bug_fixes_11">Bug fixes</h3>
<div class="ulist"><ul>
<li>
<p>
@@ -1234,7 +1283,7 @@
<div class="sectionbody">
<div class="paragraph"><p>Release date: 2010-11-07</p></div>
<div class="sect2">
-<h3 id="_bug_fixes_10">Bug fixes</h3>
+<h3 id="_bug_fixes_12">Bug fixes</h3>
<div class="ulist"><ul>
<li>
<p>
@@ -1356,7 +1405,7 @@
</ul></div>
</div>
<div class="sect2">
-<h3 id="_bug_fixes_11">Bug fixes</h3>
+<h3 id="_bug_fixes_13">Bug fixes</h3>
<div class="ulist"><ul>
<li>
<p>
@@ -1442,7 +1491,7 @@
<div class="sectionbody">
<div class="paragraph"><p>Release date: 2010-07-15</p></div>
<div class="sect2">
-<h3 id="_bug_fixes_12">Bug fixes</h3>
+<h3 id="_bug_fixes_14">Bug fixes</h3>
<div class="ulist"><ul>
<li>
<p>
@@ -1631,7 +1680,7 @@
</ul></div>
</div>
<div class="sect2">
-<h3 id="_bug_fixes_13">Bug fixes</h3>
+<h3 id="_bug_fixes_15">Bug fixes</h3>
<div class="ulist"><ul>
<li>
<p>
@@ -1776,8 +1825,9 @@
<div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
-Version 3.1.10<br />
-Last updated 2014-10-19 19:03:56 CEST
+Version 3.1.12<br />
+Last updated
+ 2016-07-12 21:34:27 CEST
</div>
</div>
</body>
diff -Nru ccache-3.1.10/NEWS.txt ccache-3.1.12/NEWS.txt
--- ccache-3.1.10/NEWS.txt 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/NEWS.txt 2016-07-12 21:34:50.000000000 +0200
@@ -2,6 +2,39 @@
===========
+ccache 3.1.12
+-------------
+Release date: 2016-07-12
+
+
+Bug fixes
+~~~~~~~~~
+
+- Fixed a bug where (due to ccache rewriting paths) the compiler could choose
+ incorrect include files if `CCACHE_BASEDIR` is used and the source file path
+ is absolute and is a symlink.
+
+
+ccache 3.1.11
+-------------
+Release date: 2015-03-07
+
+
+Bug fixes
+~~~~~~~~~
+
+- Fixed bug which could result in false cache hits when source code contains
+ `'"'` followed by `" /*"` or `" //"` (with variations).
+
+- Made hash of cached result created with and without `CCACHE_CPP2` different.
+ This makes it possible to rebuild with `CCACHE_CPP2` set without having to
+ clear the cache to get new results.
+
+- Don't try to reset a non-existing stats file. This avoids ``No such file or
+ directory'' messages in the ccache log when the cache directory doesn't
+ exist.
+
+
ccache 3.1.10
-------------
Release date: 2014-10-19
@@ -27,7 +60,7 @@
- To enable support for precompiled headers (PCH), `CCACHE_SLOPPINESS` now also
needs to include the new `pch_defines` sloppiness. This is because ccache
- can't detect changes in the source code when only `#define`s have been
+ can't detect changes in the source code when only defined macros have been
changed.
- Stale files in the internal temporary directory (`<ccache_dir>/tmp`) are now
diff -Nru ccache-3.1.10/README.html ccache-3.1.12/README.html
--- ccache-3.1.10/README.html 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/README.html 2016-07-12 21:34:50.000000000 +0200
@@ -734,7 +734,7 @@
<body class="article">
<div id="header">
<h1>ccache README</h1>
-<span id="revnumber">version 3.1.10</span>
+<span id="revnumber">version 3.1.12</span>
<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>
@@ -830,8 +830,9 @@
<div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
-Version 3.1.10<br />
-Last updated 2012-11-07 19:42:42 CET
+Version 3.1.12<br />
+Last updated
+ 2016-07-12 21:34:27 CEST
</div>
</div>
</body>
diff -Nru ccache-3.1.10/ccache.1 ccache-3.1.12/ccache.1
--- ccache-3.1.10/ccache.1 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/ccache.1 2016-07-12 21:34:50.000000000 +0200
@@ -2,12 +2,12 @@
.\" Title: ccache
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 10/19/2014
+.\" Date: 07/12/2016
.\" Manual: ccache Manual
-.\" Source: ccache 3.1.10
+.\" Source: ccache 3.1.12
.\" Language: English
.\"
-.TH "CCACHE" "1" "10/19/2014" "ccache 3\&.1\&.10" "ccache Manual"
+.TH "CCACHE" "1" "07/12/2016" "ccache 3\&.1\&.12" "ccache Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
diff -Nru ccache-3.1.10/ccache.c ccache-3.1.12/ccache.c
--- ccache-3.1.10/ccache.c 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/ccache.c 2016-07-12 21:34:50.000000000 +0200
@@ -2,7 +2,7 @@
* ccache -- a fast C/C++ compiler cache
*
* Copyright (C) 2002-2007 Andrew Tridgell
- * Copyright (C) 2009-2014 Joel Rosdahl
+ * Copyright (C) 2009-2016 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
@@ -36,7 +36,7 @@
MYNAME " version %s\n"
"\n"
"Copyright (C) 2002-2007 Andrew Tridgell\n"
-"Copyright (C) 2009-2011 Joel Rosdahl\n"
+"Copyright (C) 2009-2016 Joel Rosdahl\n"
"\n"
"This program is free software; you can redistribute it and/or modify it
under\n"
"the terms of the GNU General Public License as published by the Free
Software\n"
@@ -878,6 +878,8 @@
*/
cpp_stderr = path_stderr;
} else {
+ hash_delimiter(hash, "runsecondcpp");
+ hash_string(hash, "false");
free(path_stderr);
}
@@ -1745,8 +1747,17 @@
goto out;
}
- /* Rewrite to relative to increase hit rate. */
- input_file = make_relative_path(x_strdup(argv[i]));
+ lstat(argv[i], &st);
+ if (S_ISLNK(st.st_mode)) {
+ /* Don't rewrite source file path if it's a symlink
since
+ make_relative_path resolves symlinks using
realpath(3) and this leads
+ to potentially choosing incorrect relative header
files. See the
+ "symlink to source file" test. */
+ input_file = x_strdup(argv[i]);
+ } else {
+ /* Rewrite to relative to increase hit rate. */
+ input_file = make_relative_path(x_strdup(argv[i]));
+ }
}
if (!input_file) {
diff -Nru ccache-3.1.10/debian/changelog ccache-3.1.12/debian/changelog
--- ccache-3.1.10/debian/changelog 2014-10-22 21:21:46.000000000 +0200
+++ ccache-3.1.12/debian/changelog 2016-07-15 19:54:06.000000000 +0200
@@ -1,3 +1,20 @@
+ccache (3.1.12-1) stable; urgency=medium
+
+ * New upstream release 3.1.12 containing important bug fixes (and only
+ bug fixes) made since 3.1.10:
+ - Fixes a bug where (due to ccache rewriting paths) the compiler could
+ choose incorrect include files if CCACHE_BASEDIR is used and the
+ source file path is absolute and is a symlink. (Closes: #829088.)
+ - Fixes a bug which could result in false cache hits when source code
+ contains '"' followed by " /*" or " //" (with variations).
+ - Makes hash of cached result created with and without CCACHE_CPP2
+ different. This makes it possible to rebuild with CCACHE_CPP2 set
+ without having to clear the cache to get new results.
+ - Fixes a bug which could result in "No such file or directory"
+ messages in the ccache log when the cache directory doesn't exist.
+
+ -- Joel Rosdahl <j...@debian.org> Fri, 15 Jul 2016 19:47:17 +0200
+
ccache (3.1.10-1) unstable; urgency=medium
* Update Vcs-git and Vcs-Browser to use anonscm.debian.org
@@ -390,4 +407,3 @@
* Initial Release.
-- Paul Russell <pruss...@debian.org> Sun, 31 Mar 2002 14:08:57 +0200
-
diff -Nru ccache-3.1.10/hashutil.c ccache-3.1.12/hashutil.c
--- ccache-3.1.10/hashutil.c 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/hashutil.c 2016-07-12 21:34:50.000000000 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2010, 2012 Joel Rosdahl
+ * Copyright (C) 2009-2015 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
@@ -18,6 +18,7 @@
#include "ccache.h"
#include "hashutil.h"
+#include "macroskip.h"
#include "murmurhashneutral2.h"
unsigned
@@ -56,124 +57,82 @@
} while (0)
/*
- * Hash a string ignoring comments. Returns a bitmask of HASH_SOURCE_CODE_*
- * results.
+ * Search for the strings "__DATE__" and "__TIME__" in str.
+ *
+ * Returns a bitmask with HASH_SOURCE_CODE_FOUND_DATE and
+ * HASH_SOURCE_CODE_FOUND_TIME set appropriately.
*/
int
-hash_source_code_string(
- struct mdfour *hash, const char *str, size_t len, const char *path)
+check_for_temporal_macros(const char *str, size_t len)
{
- const char *p;
- const char *end;
- char hashbuf[64];
- size_t hashbuflen = 0;
- int result = HASH_SOURCE_CODE_OK;
- extern unsigned sloppiness;
- bool seen_backslash;
+ int result = 0;
- p = str;
- end = str + len;
- while (1) {
- if (p >= end) {
- goto end;
- }
- switch (*p) {
- /* Potential start of comment. */
- case '/':
- if (p+1 == end) {
- break;
- }
- switch (*(p+1)) {
- case '*':
- HASH(' '); /* Don't paste tokens together when
removing the comment. */
- p += 2;
- while (p+1 < end && (*p != '*' || *(p+1) !=
'/')) {
- if (*p == '\n') {
- /* Keep line numbers. */
- HASH('\n');
- }
- p++;
- }
- if (p+1 == end) {
- goto end;
- }
- p += 2;
- continue;
-
- case '/':
- p += 2;
- while (p < end && (*p != '\n' || *(p-1) ==
'\\')) {
- p++;
- }
- continue;
-
- default:
- break;
- }
- break;
+ /*
+ * We're using the Boyer-Moore-Horspool algorithm, which searches
starting
+ * from the *end* of the needle. Our needles are 8 characters long, so i
+ * starts at 7.
+ */
+ size_t i = 7;
- /* Start of string. */
- case '"':
- HASH(*p);
- p++;
- seen_backslash = false;
- while (p < end) {
- if (seen_backslash) {
- seen_backslash = false;
- } else if (*p == '"') {
- /* Found end of string. */
- HASH(*p);
- p++;
- break;
- } else if (*p == '\\') {
- seen_backslash = true;
- }
- HASH(*p);
- p++;
- }
- if (p == end) {
- goto end;
+ while (i < len) {
+ /*
+ * Check whether the substring ending at str[i] has the form
"__...E__". On
+ * the assumption that 'E' is less common in source than '_',
we check
+ * str[i-2] first.
+ */
+ if (str[i - 2] == 'E' &&
+ str[i - 0] == '_' &&
+ str[i - 7] == '_' &&
+ str[i - 1] == '_' &&
+ str[i - 6] == '_') {
+ /*
+ * Check the remaining characters to see if the
substring is "__DATE__"
+ * or "__TIME__".
+ */
+ if (str[i - 5] == 'D' && str[i - 4] == 'A' &&
+ str[i - 3] == 'T') {
+ result |= HASH_SOURCE_CODE_FOUND_DATE;
}
- break;
-
- /* Potential start of volatile macro. */
- case '_':
- if (p + 7 < end
- && p[1] == '_' && p[5] == 'E'
- && p[6] == '_' && p[7] == '_') {
- if (p[2] == 'D' && p[3] == 'A'
- && p[4] == 'T') {
- result |= HASH_SOURCE_CODE_FOUND_DATE;
- } else if (p[2] == 'T' && p[3] == 'I'
- && p[4] == 'M') {
- result |= HASH_SOURCE_CODE_FOUND_TIME;
- }
- /*
- * Of course, we can't be sure that we have
found a __{DATE,TIME}__
- * that's actually used, but better safe than
sorry. And if you do
- * something like
- *
- * #define TIME __TI ## ME__
- *
- * in your code, you deserve to get a false
cache hit.
- */
+ else if (str[i - 5] == 'T' && str[i - 4] == 'I' &&
+ str[i - 3] == 'M') {
+ result |= HASH_SOURCE_CODE_FOUND_TIME;
}
- break;
-
- default:
- break;
}
- HASH(*p);
- p++;
+ /*
+ * macro_skip tells us how far we can skip forward upon seeing
str[i] at
+ * the end of a substring.
+ */
+ i += macro_skip[(uint8_t)str[i]];
}
-end:
- hash_buffer(hash, hashbuf, hashbuflen);
+ return result;
+}
- if (sloppiness & SLOPPY_TIME_MACROS) {
- return 0;
+/*
+ * Hash a string ignoring comments. Returns a bitmask of HASH_SOURCE_CODE_*
+ * results.
+ */
+int
+hash_source_code_string(
+ struct mdfour *hash, const char *str, size_t len, const char *path)
+{
+ int result = HASH_SOURCE_CODE_OK;
+ extern unsigned sloppiness;
+
+ /*
+ * Check for __DATE__ and __TIME__ if the sloppiness configuration
tells us
+ * we should.
+ */
+ if (!(sloppiness & SLOPPY_TIME_MACROS)) {
+ result |= check_for_temporal_macros(str, len);
}
+
+ /*
+ * Hash the source string.
+ */
+ hash_buffer(hash, str, len);
+
if (result & HASH_SOURCE_CODE_FOUND_DATE) {
/*
* Make sure that the hash sum changes if the (potential)
expansion of
diff -Nru ccache-3.1.10/hashutil.h ccache-3.1.12/hashutil.h
--- ccache-3.1.10/hashutil.h 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/hashutil.h 2016-07-12 21:34:50.000000000 +0200
@@ -20,6 +20,7 @@
#define HASH_SOURCE_CODE_FOUND_DATE 2
#define HASH_SOURCE_CODE_FOUND_TIME 4
+int check_for_temporal_macros(const char *str, size_t len);
int hash_source_code_string(
struct mdfour *hash, const char *str, size_t len, const char *path);
int hash_source_code_file(struct mdfour *hash, const char *path);
diff -Nru ccache-3.1.10/macroskip.h ccache-3.1.12/macroskip.h
--- ccache-3.1.10/macroskip.h 1970-01-01 01:00:00.000000000 +0100
+++ ccache-3.1.12/macroskip.h 2016-07-12 21:34:50.000000000 +0200
@@ -0,0 +1,56 @@
+/*
+ * A Boyer-Moore-Horspool skip table used for searching for the strings
+ * "__TIME__" and "__DATE__".
+ *
+ * macro_skip[c] = 8 for all c not in "__TIME__" and "__DATE__".
+ *
+ * The other characters map as follows:
+ *
+ * _ -> 1
+ * A -> 4
+ * D -> 5
+ * E -> 2
+ * I -> 4
+ * M -> 3
+ * T -> 3
+ *
+ *
+ * This was generated with the following Python script:
+ *
+ * m = {'_': 1,
+ * 'A': 4,
+ * 'D': 5,
+ * 'E': 2,
+ * 'I': 4,
+ * 'M': 3,
+ * 'T': 3}
+ *
+ * for i in range(0, 256):
+ * if chr(i) in m:
+ * num = m[chr(i)]
+ * else:
+ * num = 8
+ * print ("%d, " % num),
+ *
+ * if i % 16 == 15:
+ * print ""
+ */
+
+static const uint32_t macro_skip[] = {
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 4, 8, 8, 5, 2, 8, 8, 8, 4, 8, 8, 8, 3, 8, 8,
+ 8, 8, 8, 8, 3, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+};
diff -Nru ccache-3.1.10/stats.c ccache-3.1.12/stats.c
--- ccache-3.1.10/stats.c 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/stats.c 2016-07-12 21:34:50.000000000 +0200
@@ -347,7 +347,13 @@
for (dir = 0; dir <= 0xF; dir++) {
struct counters *counters = counters_init(STATS_END);
+ struct stat st;
fname = format("%s/%1x/stats", cache_dir, dir);
+ if (stat(fname, &st) != 0) {
+ /* No point in trying to reset the stats file if it
doesn't exist. */
+ free(fname);
+ continue;
+ }
if (lockfile_acquire(fname, lock_staleness_limit)) {
stats_read(fname, counters);
for (i = 0; stats_info[i].message; i++) {
diff -Nru ccache-3.1.10/test/test_hashutil.c ccache-3.1.12/test/test_hashutil.c
--- ccache-3.1.10/test/test_hashutil.c 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/test/test_hashutil.c 2016-07-12 21:34:50.000000000 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2012 Joel Rosdahl
+ * Copyright (C) 2010-2015 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
@@ -109,83 +109,82 @@
CHECK_STR_EQ_FREE2("a448017aaf21d8525fc10ae87aa6729d-3",
hash_result(&h));
}
-TEST(hash_source_code_with_c_style_comment)
+TEST(check_for_temporal_macros)
{
- struct mdfour h;
- char input[] = "a/*b*/c";
- size_t input_len = strlen(input);
-
- hash_start(&h);
- hash_source_code_string(&h, input, input_len, "");
- CHECK_STR_EQ_FREE2("1c2c87080ee03418fb1279e3b1f09a68-3",
hash_result(&h));
-
- input[3] = 'd';
- hash_start(&h);
- hash_source_code_string(&h, input, input_len, "");
- CHECK_STR_EQ_FREE2("1c2c87080ee03418fb1279e3b1f09a68-3",
hash_result(&h));
-}
-
-TEST(hash_source_code_with_cplusplus_style_comment)
-{
- struct mdfour h;
- char input[] = "a//b\nc";
- size_t input_len = strlen(input);
-
- hash_start(&h);
- hash_source_code_string(&h, input, input_len, "");
- CHECK_STR_EQ_FREE2("4a3fbbe3c140fa193227dba3814db6e6-3",
hash_result(&h));
-
- input[3] = 'd';
- hash_start(&h);
- hash_source_code_string(&h, input, input_len, "");
- CHECK_STR_EQ_FREE2("4a3fbbe3c140fa193227dba3814db6e6-3",
hash_result(&h));
-}
-
-TEST(hash_source_code_with_comment_inside_string)
-{
- struct mdfour h;
- char input[] = "a\"//b\"c";
- size_t input_len = strlen(input);
-
- hash_start(&h);
- hash_source_code_string(&h, input, input_len, "");
- CHECK_STR_EQ_FREE2("4c2fa74b0843d8f93df5c04c98ccb0a4-7",
hash_result(&h));
-
- input[4] = 'd';
- hash_start(&h);
- hash_source_code_string(&h, input, input_len, "");
- CHECK_STR_EQ_FREE2("f0069218ec640008cbfa2d150c1061bb-7",
hash_result(&h));
-}
-
-TEST(hash_source_code_with_quote_in_string)
-{
- struct mdfour h;
- char input[] = "a\"\\\"b//c\""; /* a"\"b//c" */
- size_t input_len = strlen(input);
-
- hash_start(&h);
- hash_source_code_string(&h, input, input_len, "");
- CHECK_STR_EQ_FREE2("c4e45e7a7f6f29b000a51f187dc4cf06-9",
hash_result(&h));
-
- hash_start(&h);
- input[7] = 'd';
- hash_source_code_string(&h, input, input_len, "");
- CHECK_STR_EQ_FREE2("bef8fb852dddcee189b91b068a621c55-9",
hash_result(&h));
-}
-
-TEST(hash_source_code_with_backslash_at_string_end)
-{
- struct mdfour h;
- char input[] = "a\"\\\\\"b//c"; /* a"\\"b//c */
- size_t input_len = strlen(input);
-
- hash_start(&h);
- hash_source_code_string(&h, input, input_len, "");
- CHECK_STR_EQ_FREE2("7f3ccf27edadad1b90cb2cffb59775d6-6",
hash_result(&h));
-
- input[input_len - 1] = 'd';
- hash_source_code_string(&h, input, input_len, "");
- CHECK_STR_EQ_FREE2("7f3ccf27edadad1b90cb2cffb59775d6-6",
hash_result(&h));
+ const char time_start[] =
+ "__TIME__\n"
+ "int a;\n";
+ const char time_middle[] =
+ "#define a __TIME__\n"
+ "int a;\n";
+ const char time_end[] =
+ "#define a __TIME__";
+
+ const char date_start[] =
+ "__DATE__\n"
+ "int ab;\n";
+ const char date_middle[] =
+ "#define ab __DATE__\n"
+ "int ab;\n";
+ const char date_end[] =
+ "#define ab __DATE__";
+
+ const char no_temporal[] =
+ "#define ab _ _DATE__\n"
+ "#define ab __ DATE__\n"
+ "#define ab __D ATE__\n"
+ "#define ab __DA TE__\n"
+ "#define ab __DAT E__\n"
+ "#define ab __DATE __\n"
+ "#define ab __DATE_ _\n"
+ "#define ab _ _TIME__\n"
+ "#define ab __ TIME__\n"
+ "#define ab __T IME__\n"
+ "#define ab __TI ME__\n"
+ "#define ab __TIM E__\n"
+ "#define ab __TIME __\n"
+ "#define ab __TIME_ _\n";
+
+ CHECK(check_for_temporal_macros(time_start + 0, sizeof(time_start) -
0));
+ CHECK(!check_for_temporal_macros(time_start + 1, sizeof(time_start) -
1));
+
+ CHECK(check_for_temporal_macros(time_middle + 0, sizeof(time_middle) -
0));
+ CHECK(check_for_temporal_macros(time_middle + 1, sizeof(time_middle) -
1));
+ CHECK(check_for_temporal_macros(time_middle + 2, sizeof(time_middle) -
2));
+ CHECK(check_for_temporal_macros(time_middle + 3, sizeof(time_middle) -
3));
+ CHECK(check_for_temporal_macros(time_middle + 4, sizeof(time_middle) -
4));
+ CHECK(check_for_temporal_macros(time_middle + 5, sizeof(time_middle) -
5));
+ CHECK(check_for_temporal_macros(time_middle + 6, sizeof(time_middle) -
6));
+ CHECK(check_for_temporal_macros(time_middle + 7, sizeof(time_middle) -
7));
+
+ CHECK(check_for_temporal_macros(time_end + 0, sizeof(time_end) - 0));
+ CHECK(check_for_temporal_macros(time_end + sizeof(time_end) - 9, 9));
+ CHECK(!check_for_temporal_macros(time_end + sizeof(time_end) - 8, 8));
+
+ CHECK(check_for_temporal_macros(date_start + 0, sizeof(date_start) -
0));
+ CHECK(!check_for_temporal_macros(date_start + 1, sizeof(date_start) -
1));
+
+ CHECK(check_for_temporal_macros(date_middle + 0, sizeof(date_middle) -
0));
+ CHECK(check_for_temporal_macros(date_middle + 1, sizeof(date_middle) -
1));
+ CHECK(check_for_temporal_macros(date_middle + 2, sizeof(date_middle) -
2));
+ CHECK(check_for_temporal_macros(date_middle + 3, sizeof(date_middle) -
3));
+ CHECK(check_for_temporal_macros(date_middle + 4, sizeof(date_middle) -
4));
+ CHECK(check_for_temporal_macros(date_middle + 5, sizeof(date_middle) -
5));
+ CHECK(check_for_temporal_macros(date_middle + 6, sizeof(date_middle) -
6));
+ CHECK(check_for_temporal_macros(date_middle + 7, sizeof(date_middle) -
7));
+
+ CHECK(check_for_temporal_macros(date_end + 0, sizeof(date_end) - 0));
+ CHECK(check_for_temporal_macros(date_end + sizeof(date_end) - 9, 9));
+ CHECK(!check_for_temporal_macros(date_end + sizeof(date_end) - 8, 8));
+
+ CHECK(!check_for_temporal_macros(no_temporal + 0, sizeof(no_temporal) -
0));
+ CHECK(!check_for_temporal_macros(no_temporal + 1, sizeof(no_temporal) -
1));
+ CHECK(!check_for_temporal_macros(no_temporal + 2, sizeof(no_temporal) -
2));
+ CHECK(!check_for_temporal_macros(no_temporal + 3, sizeof(no_temporal) -
3));
+ CHECK(!check_for_temporal_macros(no_temporal + 4, sizeof(no_temporal) -
4));
+ CHECK(!check_for_temporal_macros(no_temporal + 5, sizeof(no_temporal) -
5));
+ CHECK(!check_for_temporal_macros(no_temporal + 6, sizeof(no_temporal) -
6));
+ CHECK(!check_for_temporal_macros(no_temporal + 7, sizeof(no_temporal) -
7));
}
TEST_SUITE_END
diff -Nru ccache-3.1.10/test.sh ccache-3.1.12/test.sh
--- ccache-3.1.10/test.sh 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/test.sh 2016-07-12 21:34:50.000000000 +0200
@@ -3,7 +3,7 @@
# A simple test suite for ccache.
#
# Copyright (C) 2002-2007 Andrew Tridgell
-# Copyright (C) 2009-2014 Joel Rosdahl
+# Copyright (C) 2009-2016 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
@@ -219,7 +219,7 @@
mv $CCACHE_DIR $CCACHE_DIR.saved
CCACHE_DISABLE=1 $CCACHE_COMPILE -c test1.c 2> /dev/null
if [ -d $CCACHE_DIR ]; then
- test_failed "$CCACHE_DIR created dispite CCACHE_DISABLE being set"
+ test_failed "$CCACHE_DIR created despite CCACHE_DISABLE being set"
fi
mv $CCACHE_DIR.saved $CCACHE_DIR
checkstat 'cache hit (preprocessed)' 3
@@ -245,10 +245,10 @@
checkstat 'cache hit (preprocessed)' 5
checkstat 'cache miss' 4
- # strictly speaking should be 3 - RECACHE causes a double counting!
+ # strictly speaking should be 4 - RECACHE causes a double counting!
checkstat 'files in cache' 4
$CCACHE -c > /dev/null
- checkstat 'files in cache' 3
+ checkstat 'files in cache' 4
testname="CCACHE_HASHDIR"
CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O
@@ -258,7 +258,7 @@
CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O
checkstat 'cache hit (preprocessed)' 6
checkstat 'cache miss' 5
- checkstat 'files in cache' 4
+ checkstat 'files in cache' 5
testname="comments"
echo '/* a silly comment */' > test1-comment.c
@@ -286,7 +286,7 @@
done
checkstat 'cache hit (preprocessed)' 8
checkstat 'cache miss' 37
- checkstat 'files in cache' 36
+ checkstat 'files in cache' 37
$CCACHE -C >/dev/null
@@ -344,9 +344,15 @@
CCACHE_CPP2=1 $CCACHE_COMPILE -c -finput-charset=latin1 latin1.c
checkstat 'cache hit (preprocessed)' 14
checkstat 'cache miss' 40
- $CCACHE_COMPILE -c -finput-charset=latin1 latin1.c
+ CCACHE_CPP2=1 $CCACHE_COMPILE -c -finput-charset=latin1 latin1.c
checkstat 'cache hit (preprocessed)' 15
checkstat 'cache miss' 40
+ $CCACHE_COMPILE -c -finput-charset=latin1 latin1.c
+ checkstat 'cache hit (preprocessed)' 15
+ checkstat 'cache miss' 41
+ $CCACHE_COMPILE -c -finput-charset=latin1 latin1.c
+ checkstat 'cache hit (preprocessed)' 16
+ checkstat 'cache miss' 41
fi
fi
@@ -898,45 +904,6 @@
checkfile stderr-mf.txt "`cat stderr-orig.txt`"
##################################################################
- # Check that changes in comments are ignored when hashing.
- testname="changes in comments"
- $CCACHE -C >/dev/null
- $CCACHE -z >/dev/null
- cat <<EOF >comments.h
-/*
- * /* foo comment
- */
-EOF
- backdate comments.h
- cat <<'EOF' >comments.c
-#include "comments.h"
-char test[] = "\
-/* apple */ // banana"; // foo comment
-EOF
-
- $CCACHE $COMPILER -c comments.c
- checkstat 'cache hit (direct)' 0
- checkstat 'cache hit (preprocessed)' 0
- checkstat 'cache miss' 1
-
- sed_in_place 's/foo/ignored/' comments.h comments.c
- backdate comments.h
-
- $CCACHE $COMPILER -c comments.c
- checkstat 'cache hit (direct)' 1
- checkstat 'cache hit (preprocessed)' 0
- checkstat 'cache miss' 1
-
- # Check that comment-like string contents are hashed.
- sed_in_place 's/apple/orange/' comments.c
- backdate comments.h
-
- $CCACHE $COMPILER -c comments.c
- checkstat 'cache hit (direct)' 1
- checkstat 'cache hit (preprocessed)' 0
- checkstat 'cache miss' 2
-
- ##################################################################
# Check that it's possible to compile and cache an empty source code file.
testname="empty source file"
$CCACHE -Cz >/dev/null
@@ -1203,6 +1170,23 @@
checkstat 'cache hit (direct)' 2
checkstat 'cache hit (preprocessed)' 0
checkstat 'cache miss' 2
+
+ testname="comment in strings"
+ $CCACHE -Cz >/dev/null
+ echo 'char *comment = " /* \\\\u" "foo" " */";' >comment.c
+ $CCACHE $COMPILER -c comment.c
+ checkstat 'cache hit (direct)' 0
+ checkstat 'cache hit (preprocessed)' 0
+ checkstat 'cache miss' 1
+ $CCACHE $COMPILER -c comment.c
+ checkstat 'cache hit (direct)' 1
+ checkstat 'cache hit (preprocessed)' 0
+ checkstat 'cache miss' 1
+ echo 'char *comment = " /* \\\\u" "goo" " */";' >comment.c
+ $CCACHE $COMPILER -c comment.c
+ checkstat 'cache hit (direct)' 1
+ checkstat 'cache hit (preprocessed)' 0
+ checkstat 'cache miss' 2
}
basedir_suite() {
@@ -1853,6 +1837,59 @@
checkstat 'cache miss' 2
}
+symlinks_suite() {
+ ##################################################################
+ testname="symlink to source directory"
+
+ mkdir dir
+ cd dir
+ mkdir -p d1/d2
+ echo '#define A "OK"' >d1/h.h
+ cat <<EOF >d1/d2/c.c
+#include <stdio.h>
+#include "../h.h"
+int main() { printf("%s\n", A); }
+EOF
+ echo '#define A "BUG"' >h.h
+ ln -s d1/d2 d3
+
+ CCACHE_BASEDIR=/ $CCACHE $COMPILER -c $PWD/d3/c.c
+ $COMPILER -c $PWD/d3/c.c
+ $COMPILER c.o -o c
+ result=$(./c)
+ if [ "$result" != OK ]; then
+ test_failed "Incorrect header file used"
+ fi
+
+ cd ..
+ rm -rf dir
+
+ ##################################################################
+ testname="symlink to source file"
+
+ mkdir dir
+ cd dir
+ mkdir d
+ echo '#define A "BUG"' >d/h.h
+ cat <<EOF >d/c.c
+#include <stdio.h>
+#include "h.h"
+int main() { printf("%s\n", A); }
+EOF
+ echo '#define A "OK"' >h.h
+ ln -s d/c.c c.c
+
+ CCACHE_BASEDIR=/ $CCACHE $COMPILER -c $PWD/c.c
+ $COMPILER c.o -o c
+ result=$(./c)
+ if [ "$result" != OK ]; then
+ test_failed "Incorrect header file used"
+ fi
+
+ cd ..
+ rm -rf dir
+}
+
######################################################################
# main program
@@ -1892,7 +1929,6 @@
base
link !win32
hardlink
-cpp2
nlevels4
nlevels1
basedir !win32
@@ -1902,6 +1938,7 @@
extrafiles
cleanup
pch
+symlinks
"
host_os="`uname -s`"
diff -Nru ccache-3.1.10/version.c ccache-3.1.12/version.c
--- ccache-3.1.10/version.c 2014-10-19 19:12:05.000000000 +0200
+++ ccache-3.1.12/version.c 2016-07-12 21:34:50.000000000 +0200
@@ -1 +1 @@
-const char CCACHE_VERSION[] = "3.1.10";
+const char CCACHE_VERSION[] = "3.1.12";
--- End Message ---