Joel Rosdahl [Thu, 19 Nov 2020 20:31:41 +0000 (21:31 +0100)]
Fix bug in depfile when output filename includes special characters
The rewriting of the dependency file content introduced in 2ab31632 just
replaces the object file part of the dependency file with the raw
filename. This is incorrect if the filename includes special characters
such as space or dollar.
Fix this by escaping the filename properly. Note that newlines are not
treated specially since Make cannot handle them anyway.
See also the similar bug fix for the depend mode (but for parsing
instead of escaping in that case) in 1d2b5bf4.
Joel Rosdahl [Mon, 9 Nov 2020 18:35:02 +0000 (19:35 +0100)]
Fix conditional compilation of robust mutex code in inode cache
213d9883 added code for using a “robust mutex” to be able to recover a
mutex left in an inconsistent state. The code is enabled if the
PTHREAD_MUTEX_ROBUST macro is defined. On all Linux systems I have
tested, PTHREAD_MUTEX_ROBUST is not a macro but an enum value, so the
code is dead.
Fix this by adding a configure-time check whether it’s possible to use
pthread_mutexattr_setrobust(..., PTHREAD_MUTEX_ROBUST).
Joel Rosdahl [Sat, 7 Nov 2020 19:25:10 +0000 (20:25 +0100)]
Add possibility of overriding compiler type guess
This commit adds a new compiler_type (CCACHE_COMPILERTYPE) configuration
option which makes it possible to force a compiler type, for instance
from a compiler wrapper script not named like a known compiler.
Joel Rosdahl [Wed, 4 Nov 2020 20:21:41 +0000 (21:21 +0100)]
Add docbook-{xml,xsl} packages to Ubuntu environments
Without docbook-xml and docbook-xsl, xsltproc (run by a2x to create the
ccache.1 man page) fetches stuff from the Internet, making man page
generation very slow.
Joel Rosdahl [Mon, 2 Nov 2020 21:09:56 +0000 (22:09 +0100)]
Retain given color diagnostics options when forcing colored output
ccache currently filters out both -fdiagnostics-color and
-fcolor-diagnostics options when adding -fdiagnostics-color (GCC) or
-fcolor-diagnostics (Clang) to force colored output. The idea in #224
was that only -fdiagnostics-color options should be filtered out when
the compiler is GCC, but -fcolor-diagnostics is also removed, something
which was missed in the code review. This has the unintended side effect
that “ccache gcc -fcolor-diagnostics -c example.c” works since ccache in
effect removes -fcolor-diagnostics in the actual call to the compiler.
The bug can fixed by removing only the compiler-specific options when
forcing colored output, but a more robust method would be to retain all
color diagnostics options as is but exclude them from the input hash.
This commit makes that change and also simplifies the logic for color
diagnostics option handling.
Erik Flodin [Fri, 30 Oct 2020 09:41:58 +0000 (10:41 +0100)]
Disable some AVX features on old Apple clang versions (#704)
Disable avx2 and avx512 support on some apple clang versions as the compile
fails even though the compiler seems to accept the -m flags that are used to
enable the feature.
Joel Rosdahl [Wed, 28 Oct 2020 20:26:42 +0000 (21:26 +0100)]
Restore original umask after finalize_at_exit
If umask (CCACHE_UMASK) has been configured, ccache restores the
original umask before executing external programs so that the configured
umask is only used for files created by ccache itself. After a
refactoring of how flushing of statistics is done
(dd8f65aa5589709ca55bbb782050424a0010e8b8), the original umask is
restored before calling finalize_at_exit. If ccache hasn’t created a
result file (i.e., the result is not a cache miss, for example when
called for linking), finalize_stats_and_trigger_cleanup (called by
finalize_at_exit) chooses a random stats file and implicitly also
creates any missing cache directories. Such cache directories will
therefore be created without applying the configured umask.
Fix this by restoring the original mask after calling finalize_at_exit.
Joel Rosdahl [Tue, 20 Oct 2020 18:49:50 +0000 (20:49 +0200)]
Detect errors in log strings at compile time
fmtlib can detect format string errors at compile time if (1) applying
FMT_STRING to the format string literal and (2) compiling for C++14 or
higher.
Requirement 1 is implemented by introducing a LOG macro which applies
FMT_STRING to the first argument and calls Logging::log (if logging is
enabled). Also added are a companion LOG_RAW macro (since C++11 requires
at least one argument for the “...” part in variadic macros) and a
BULK_LOG macro which calls Logging::bulk_log (if logging is enabled).
Requirement 2 is implemented by setting CMAKE_CXX_STANDARD to 14 for one
CI build with a known C++14-capable compiler. We can’t set it to 14 by
default since we still want the code to be buildable with C++11
compilers.
This will catch errors such as the one fixed by PR #691.
Olle Liljenzin [Mon, 12 Oct 2020 18:53:02 +0000 (20:53 +0200)]
Fix expect_perm to work with SELinux (#681)
Test case CCACHE_UMASK fails when running it in an SELinux context because
/bin/ls adds a trailing dot to the output. Thus truncate the output to expected
length.
Joel Rosdahl [Tue, 6 Oct 2020 13:01:01 +0000 (15:01 +0200)]
Fix broken dependency file when using base_dir
If a path in the dependency file matches base_dir, the dependency file
will be completely broken since newlines won’t be not retained by
use_relative_paths_in_depfile. Fix this by tokenizing lines instead of
the full file content once again.
Joel Rosdahl [Mon, 5 Oct 2020 17:03:19 +0000 (19:03 +0200)]
Improve consistency of terms in the manual
* configuration setting -> configuration option
* option -> command line option, configuration option, compiler option,
value or sloppiness (unless it’s obvious from the context what
“option” refers to)