<body class="article">\r
<div id="header">\r
<h1>ccache authors</h1>\r
-<span id="revnumber">version 3.1.10</span>\r
+<span id="revnumber">version 3.1.11</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>
<div id="footnotes"><hr /></div>\r
<div id="footer">\r
<div id="footer-text">\r
-Version 3.1.10<br />\r
-Last updated 2014-10-19 19:05:10 CEST\r
+Version 3.1.11<br />\r
+Last updated\r
+ 2015-03-07 16:37:34 CET\r
</div>\r
</div>\r
</body>\r
<body class="article">\r
<div id="header">\r
<h1>ccache installation</h1>\r
-<span id="revnumber">version 3.1.10</span>\r
+<span id="revnumber">version 3.1.11</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>
<div id="footnotes"><hr /></div>\r
<div id="footer">\r
<div id="footer-text">\r
-Version 3.1.10<br />\r
-Last updated 2014-10-19 19:02:09 CEST\r
+Version 3.1.11<br />\r
+Last updated\r
+ 2015-03-07 16:37:34 CET\r
</div>\r
</div>\r
</body>\r
<body class="article">\r
<div id="header">\r
<h1>ccache copyright and license</h1>\r
-<span id="revnumber">version 3.1.10</span>\r
+<span id="revnumber">version 3.1.11</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>
<div id="footnotes"><hr /></div>\r
<div id="footer">\r
<div id="footer-text">\r
-Version 3.1.10<br />\r
-Last updated 2014-10-19 19:02:09 CEST\r
+Version 3.1.11<br />\r
+Last updated\r
+ 2015-03-07 16:37:34 CET\r
</div>\r
</div>\r
</body>\r
<body class="article">\r
<div id="header">\r
<h1>CCACHE(1)</h1>\r
-<span id="revnumber">version 3.1.10</span>\r
+<span id="revnumber">version 3.1.11</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>
<div id="footnotes"><hr /></div>\r
<div id="footer">\r
<div id="footer-text">\r
-Version 3.1.10<br />\r
-Last updated 2014-10-19 19:02:09 CEST\r
+Version 3.1.11<br />\r
+Last updated\r
+ 2015-03-07 16:37:34 CET\r
</div>\r
</div>\r
</body>\r
<body class="article">\r
<div id="header">\r
<h1>ccache news</h1>\r
-<span id="revnumber">version 3.1.10</span>\r
+<span id="revnumber">version 3.1.11</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>
</div>\r
<div id="content">\r
<div class="sect1">\r
+<h2 id="_ccache_3_1_11">ccache 3.1.11</h2>\r
+<div class="sectionbody">\r
+<div class="paragraph"><p>Release date: 2015-03-07</p></div>\r
+<div class="sect2">\r
+<h3 id="_bug_fixes">Bug fixes</h3>\r
+<div class="ulist"><ul>\r
+<li>\r
+<p>\r
+Fixed bug which could result in false cache hits when source code contains\r
+ <code>'"'</code> followed by <code>" /*"</code> or <code>" //"</code> (with variations).\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Made hash of cached result created with and without <code>CCACHE_CPP2</code> different.\r
+ This makes it possible to rebuild with <code>CCACHE_CPP2</code> set without having to\r
+ clear the cache to get new results.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Don’t try to reset a non-existing stats file. This avoids “No such file or\r
+ directory” messages in the ccache log when the cache directory doesn’t\r
+ exist.\r
+</p>\r
+</li>\r
+</ul></div>\r
+</div>\r
+</div>\r
+</div>\r
+<div class="sect1">\r
<h2 id="_ccache_3_1_10">ccache 3.1.10</h2>\r
<div class="sectionbody">\r
<div class="paragraph"><p>Release date: 2014-10-19</p></div>\r
<p>\r
To enable support for precompiled headers (PCH), <code>CCACHE_SLOPPINESS</code> now also\r
needs to include the new <code>pch_defines</code> sloppiness. This is because ccache\r
- can’t detect changes in the source code when only `#define`s have been\r
+ can’t detect changes in the source code when only defined macros have been\r
changed.\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
<div class="sectionbody">\r
<div class="paragraph"><p>Release date: 2013-01-06</p></div>\r
<div class="sect2">\r
-<h3 id="_bug_fixes_2">Bug fixes</h3>\r
+<h3 id="_bug_fixes_3">Bug fixes</h3>\r
<div class="ulist"><ul>\r
<li>\r
<p>\r
</ul></div>\r
</div>\r
<div class="sect2">\r
-<h3 id="_bug_fixes_3">Bug fixes</h3>\r
+<h3 id="_bug_fixes_4">Bug fixes</h3>\r
<div class="ulist"><ul>\r
<li>\r
<p>\r
<div class="sectionbody">\r
<div class="paragraph"><p>Release date: 2012-01-08</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
</ul></div>\r
</div>\r
<div class="sect2">\r
-<h3 id="_bug_fixes_5">Bug fixes</h3>\r
+<h3 id="_bug_fixes_6">Bug fixes</h3>\r
<div class="ulist"><ul>\r
<li>\r
<p>\r
</ul></div>\r
</div>\r
<div class="sect2">\r
-<h3 id="_bug_fixes_6">Bug fixes</h3>\r
+<h3 id="_bug_fixes_7">Bug fixes</h3>\r
<div class="ulist"><ul>\r
<li>\r
<p>\r
<div class="sectionbody">\r
<div class="paragraph"><p>Release date: 2011-01-09</p></div>\r
<div class="sect2">\r
-<h3 id="_bug_fixes_7">Bug fixes</h3>\r
+<h3 id="_bug_fixes_8">Bug fixes</h3>\r
<div class="ulist"><ul>\r
<li>\r
<p>\r
<div class="sectionbody">\r
<div class="paragraph"><p>Release date: 2010-11-28</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
<div class="sectionbody">\r
<div class="paragraph"><p>Release date: 2010-11-21</p></div>\r
<div class="sect2">\r
-<h3 id="_bug_fixes_9">Bug fixes</h3>\r
+<h3 id="_bug_fixes_10">Bug fixes</h3>\r
<div class="ulist"><ul>\r
<li>\r
<p>\r
<div class="sectionbody">\r
<div class="paragraph"><p>Release date: 2010-11-07</p></div>\r
<div class="sect2">\r
-<h3 id="_bug_fixes_10">Bug fixes</h3>\r
+<h3 id="_bug_fixes_11">Bug fixes</h3>\r
<div class="ulist"><ul>\r
<li>\r
<p>\r
</ul></div>\r
</div>\r
<div class="sect2">\r
-<h3 id="_bug_fixes_11">Bug fixes</h3>\r
+<h3 id="_bug_fixes_12">Bug fixes</h3>\r
<div class="ulist"><ul>\r
<li>\r
<p>\r
<div class="sectionbody">\r
<div class="paragraph"><p>Release date: 2010-07-15</p></div>\r
<div class="sect2">\r
-<h3 id="_bug_fixes_12">Bug fixes</h3>\r
+<h3 id="_bug_fixes_13">Bug fixes</h3>\r
<div class="ulist"><ul>\r
<li>\r
<p>\r
</ul></div>\r
</div>\r
<div class="sect2">\r
-<h3 id="_bug_fixes_13">Bug fixes</h3>\r
+<h3 id="_bug_fixes_14">Bug fixes</h3>\r
<div class="ulist"><ul>\r
<li>\r
<p>\r
<div id="footnotes"><hr /></div>\r
<div id="footer">\r
<div id="footer-text">\r
-Version 3.1.10<br />\r
-Last updated 2014-10-19 19:03:56 CEST\r
+Version 3.1.11<br />\r
+Last updated\r
+ 2015-03-07 16:37:34 CET\r
</div>\r
</div>\r
</body>\r
===========
+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
- 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
<body class="article">\r
<div id="header">\r
<h1>ccache README</h1>\r
-<span id="revnumber">version 3.1.10</span>\r
+<span id="revnumber">version 3.1.11</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>
<div id="footnotes"><hr /></div>\r
<div id="footer">\r
<div id="footer-text">\r
-Version 3.1.10<br />\r
-Last updated 2012-11-07 19:42:42 CET\r
+Version 3.1.11<br />\r
+Last updated\r
+ 2012-11-07 19:42:42 CET\r
</div>\r
</div>\r
</body>\r
.\" Title: ccache
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 10/19/2014
+.\" Date: 03/07/2015
.\" Manual: ccache Manual
-.\" Source: ccache 3.1.10
+.\" Source: ccache 3.1.11
.\" Language: English
.\"
-.TH "CCACHE" "1" "10/19/2014" "ccache 3\&.1\&.10" "ccache Manual"
+.TH "CCACHE" "1" "03/07/2015" "ccache 3\&.1\&.11" "ccache Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
* ccache -- a fast C/C++ compiler cache
*
* Copyright (C) 2002-2007 Andrew Tridgell
- * Copyright (C) 2009-2014 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
MYNAME " version %s\n"
"\n"
"Copyright (C) 2002-2007 Andrew Tridgell\n"
-"Copyright (C) 2009-2011 Joel Rosdahl\n"
+"Copyright (C) 2009-2015 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"
*/
cpp_stderr = path_stderr;
} else {
+ hash_delimiter(hash, "runsecondcpp");
+ hash_string(hash, "false");
free(path_stderr);
}
/*
- * 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
#include "ccache.h"
#include "hashutil.h"
+#include "macroskip.h"
#include "murmurhashneutral2.h"
unsigned
} 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;
+ /*
+ * 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;
- case '/':
- p += 2;
- while (p < end && (*p != '\n' || *(p-1) == '\\')) {
- p++;
- }
- continue;
-
- default:
- break;
- }
- break;
-
- /* 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
#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);
--- /dev/null
+/*
+ * 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,
+};
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++) {
# A simple test suite for ccache.
#
# Copyright (C) 2002-2007 Andrew Tridgell
-# Copyright (C) 2009-2014 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 Software
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
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
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
done
checkstat 'cache hit (preprocessed)' 8
checkstat 'cache miss' 37
- checkstat 'files in cache' 36
+ checkstat 'files in cache' 37
$CCACHE -C >/dev/null
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
checkstat 'cache miss' 1
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"
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() {
base
link !win32
hardlink
-cpp2
nlevels4
nlevels1
basedir !win32
/*
- * 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
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
-const char CCACHE_VERSION[] = "3.1.10";
+const char CCACHE_VERSION[] = "3.1.11";