Joel Rosdahl [Sat, 29 Aug 2015 16:09:37 +0000 (18:09 +0200)]
Improve signal handling
* Block signals while manipulating data read by the signal handler.
* If ccache receives SIGTERM, kill compiler as well. (Other signals like
SIGINT are sent to the whole process group.)
* Die appropriately at the end of the signal handler by resending the
signal instead of exiting.
Joel Rosdahl [Mon, 17 Aug 2015 17:05:14 +0000 (19:05 +0200)]
Fix regression in recent change related to zlib in nonstandard location
To allow for specifying a -L flag in LDFLAGS and have it take effect for
-lz, 0220de9c8ebfb18caae2ac1aa163d060e98ceade put -lz in extra_libs
instead of extra_ldflags. However, extra_libs is supposed to contain
paths to libraries which are prerequisites of the ccache link rule, and
some older versions of make got confused by seeing -lz as a
prerequisite.
Joel Rosdahl [Sun, 9 Aug 2015 20:07:11 +0000 (22:07 +0200)]
Exit properly from exit handler
This fixes a problem where two SIGINT (Ctrl+C) signals were needed to
terminate an ongoing compilation. (The first SIGINT terminated the
compiler which exited with non-zero status, which ccache then went on
interpreting as an ordinary failed compilation, leading to rerunning the
compiler via failed().)
Store the coverage notes (.gcno file) in the cache, next to the object.
If called on a file without actual code, like a header, then generate an
empty file in the cache to be able to separate this case from file missing.
Newer versions of gcc will generate a small file instead of not generating.
In the object file generated with -fprofile-arcs, the runtime output file
for the coverage data (.gcda file) is created from the output filename.
Make sure to hash this path to avoid cache hits with another absolute path.
Also make sure to use the source file path, since this is in the notes.
Jiang Jiang [Tue, 2 Dec 2014 16:23:16 +0000 (17:23 +0100)]
Support syntax CCACHE_COMPILERCHECK=string:<value>
This can be faster than running a command directly, because the
command to run might just produce the same result for every ccache
invocation. By reading it from config file or environment variable
we can just run that command once and store the result in the string
following "string:" and reusing it.
For example when we want to use clang revision for clang built from
SVN trunk, we can just call clang --version once and store the
revision number like:
Joel Rosdahl [Sat, 7 Mar 2015 16:39:54 +0000 (17:39 +0100)]
Avoid unnecessary copy of object file on cache miss
As noted by Chiaki Ishikawa, ccache performs an unnecessary copy of the
object file from the cache on a cache miss. This was an refactoring
oversight in 18a645451194becb832bd1ff4fee1c1e9f3d0dc5.
Joel Rosdahl [Fri, 20 Feb 2015 19:32:33 +0000 (20:32 +0100)]
Fix comment scanning bug in hash_source_code_string
hash_source_code_string tries to ignore __DATE__/__TIME strings in
comments, but fails to parse code that contains character literal of a
double quote. This could result in false cache hits when the source code
happens to contain '"' followed by " /*" or " //" (with variations).
The fix is to do like it's already done in ccache 3.2: Don't try to be
overly clever about __DATE__/__TIME__, just check for those strings
anywhere in the source code string.
ryb [Sat, 7 Feb 2015 14:30:16 +0000 (15:30 +0100)]
Don't clean up the clang diagnostics file in failure cases
It isn't necessary to remove the file as it will be overwritten when re-running
the compiler in failed(). tmp_unlink() is the wrong function to use in any case,
as the file is not temporary and could be on an NFS volume (see the comment for
tmp_unlink()).
ryb [Sat, 7 Feb 2015 14:01:34 +0000 (15:01 +0100)]
Don't delete the clang diagnostics file after compiler failures
move_file() returns an error when called with the same source and destination,
causing the diagnostics file to be removed.
As of 18a645451 ("Create destination file and then copy into cache instead of
the opposite") it is no longer necessary to move the diagnostics file at all
after a compiler failure.
ryb [Sat, 7 Feb 2015 13:28:48 +0000 (14:28 +0100)]
Remove incorrect preconditions for outputting captured stderr
errno is set in an unrelated system call. In my tests involving compiler
failures, it is last set to ENOENT in from_cache() when calling stat() for the
cached object, accidentally making "errno == ENOENT" true.
The condition was no longer necessary as of 18a645451 ("Create destination file
and then copy into cache instead of the opposite"), as the temp output file no
longer needed to be moved.
Joel Rosdahl [Wed, 28 Jan 2015 22:15:01 +0000 (23:15 +0100)]
Various fixes in WIN32-specific code
* Avoid potential buffer overflow in add_exe_ext_if_no_to_fullpath.
* Avoid using zero-padding strncpy function.
* Removed superfluous newline characters from log messages.
* For consistency, moved variable declarations to the top of the scope
to please older compilers.
* For consistency, used C89-style comments to please older compilers.
* Fixed source code formatting.
Joel Rosdahl [Fri, 26 Dec 2014 09:07:25 +0000 (10:07 +0100)]
Include info on CCACHE_CPP2 in hash
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.
It turned out to be a bad idea to use mkstemp for temporary files that are
renamed into files to save in the cache since mkstemp creates the file with
permissions 0600.
Joel Rosdahl [Wed, 19 Nov 2014 20:23:20 +0000 (21:23 +0100)]
Pass -fdiagnostics-color=auto to the compiler even if stderr is redirected
This fixes a problem when e.g. a configure test probes if the compiler
(wrapped via ccache) supports -fdiagnostics-color=auto. If ccache discards
the option since configure redirects stderr, then configure will
erroneously think that the compiler supports the option and the build will
fail later on (if stderr refers to a TTY).