Joel Rosdahl [Tue, 11 Aug 2020 19:05:15 +0000 (21:05 +0200)]
Add new absolute_paths_in_stderr (CCACHE_ABSSTDERR) feature
Motivation for the feature: When using the “Unix Makefiles” generator
with CMake, the compiler is executed in a different CWD than the “make”
command. This works well since absolute paths are passed to the
compiler. But combined with ccache’s base_dir feature the paths in
compiler error or warning messages will be incorrect since they will be
relative to the CWD of the compiler, not the CWD where the user or IDE
ran “make”. absolute_paths_in_stderr helps with this problem by
rewriting relative paths to absolute paths in the compiler’s stderr
output so that the user or IDE will see valid paths.
Joel Rosdahl [Sat, 8 Aug 2020 18:41:18 +0000 (20:41 +0200)]
Use XDG base directories by default
ccache will now follow the XDG Base Directory Specification
(https://specifications.freedesktop.org/basedir-spec/) by default so
that:
- the cache directory is $XDG_CACHE_HOME/ccache (or $HOME/.cache/ccache
if XDG_CACHE_HOME is not set), and
- the (primary) configuration file is
$XDG_CONFIG_HOME/ccache/ccache.conf (or
$HOME/.config/ccache/ccache.conf if XDG_CONFIG_HOME is not set).
On macOS, the fallback cache directory is $HOME/Library/Caches/ccache
and the fallback configuration file is
$HOME/Library/Preferences/ccache/ccache.conf. On Windows, the fallback
cache directory is %APPDATA%/ccache and the fallback configuration file
is %APPDATA%/ccache/ccache.conf.
Exceptions:
1. If CCACHE_CONFIGPATH is set, use that path for the configuration
file.
2. If CCACHE_DIR is set (or ccache_dir in the secondary configuration),
use that path for the cache directory and $CCACHE_DIR/ccache.conf for
the configuration file.
3. If the legacy $HOME/.ccache directory exists, use that cache
directory and $HOME/.ccache/ccache.conf for the configuration file.
Joel Rosdahl [Thu, 6 Aug 2020 14:21:52 +0000 (16:21 +0200)]
Improve building via Docker
- Simplified names (e.g. ubuntu-14-trusty -> ubuntu-14.04,
debian-9-stretch -> debian-9).
- Enabled debian-9 in misc/test-all-systems since it works.
- Renamed centos to centos-7.
- Added centos-8 and fedora-32.
- Updated dockerfiles/README to match reality after the conversion to
CMake.
- Cleaned up Dockerfiles.
- Improved misc/test-all-systems.
- Removed unsupported Clang build for alpine-3.4, centos-7 and
ubuntu-14.04.
Joel Rosdahl [Thu, 6 Aug 2020 08:42:48 +0000 (10:42 +0200)]
color_diagnostics test: Fix race conditions on some platforms
script(1) returns early on some platforms (leaving a child process
living for a short while) and the output may therefore still be pending.
Work around this by sleeping until the output file has content.
Joel Rosdahl [Thu, 6 Aug 2020 07:41:55 +0000 (09:41 +0200)]
CCACHE_PREFIX test: Fix failure for GCC <4.9
The CCACHE_PREFIX test logs execution of prefixes. After 1c6ccf18c2e04459b1ac76ede4580b3ddcd27bbe (#596) the compiler and
prefixes can be run twice if GCC doesn’t support -fdiagnostics-color and
the test case is not prepared for that. Fix this by letting prefix-a
truncate the log file.
Joel Rosdahl [Tue, 4 Aug 2020 19:09:59 +0000 (21:09 +0200)]
Improve Clang modules test suite
- Backdate modified header so that the test actually tests content and
not bails out early due to too new header timestamp.
- Verify that modifications to module.modulemap are detected, which is
key to how the modules support works.
Joel Rosdahl [Tue, 4 Aug 2020 19:07:09 +0000 (21:07 +0200)]
Remove unnecessary compiler behavior test in modules test suite
The “preprocessor output” test in the modules test suite only tests
compiler behavior, and the string it looks for in the preprocessed
output is different for older and newer Clang versions. It seems like a
kind of a probing call, but I don’t see why we would want to probe the
compiler behavior in this case so I’ll just remove it.
Joel Rosdahl [Mon, 3 Aug 2020 05:04:31 +0000 (07:04 +0200)]
C++-ify logging routines
- Simplified and C++-ified logging code.
- Added Logging::log and Logging::bulk_log functions corresponding to
the old cc_log and cc_bulklog functions. The new functions pass their
arguments to fmt::format.
- Replacements:
* init_log → Logging::init
* cc_log → Logging::log
* cc_bulklog → Logging::bulk_log
* cc_log_argv → Logging::log plus Util::format_argv_for_logging
* cc_dump_debug_log_buffer -> Logging::dump_log
- A legacy cc_log implementation is still available so that logging can
be converted gradually to the new functionality.
Joel Rosdahl [Sat, 1 Aug 2020 14:39:11 +0000 (16:39 +0200)]
Let CCACHE_UMASK apply only to files/directories in the cache directory
Ever since the CCACHE_UMASK setting was added in 75dd382407a36b3ebab36bb1027eb43a07498bec it has applied to all files
created by ccache, including files such as the object files and
executables created when ccache is called for linking. This was
presumably the easy thing to do, but it affects the observable output
from the compiler. There are also two related bugs:
1. CCACHE_UMASK is not used when creating the initial configuration file.
2. CCACHE_UMASK is used when creating the log file.
Fix this by:
- saving the original umask in Context,
- introducing a UmaskScope class,
- using UmaskScope objects to set the original umask when calling the
compiler and when copying result files from the cache, and
- setting the umask after creating the log file but before creating the
initial configuration file.
Joel Rosdahl [Sat, 1 Aug 2020 07:49:45 +0000 (09:49 +0200)]
ResultRetriever: Clear m_dest_data between entries
m_dest_data accidentally keeps its data between result entries so if an
entry has both stderr and dependency file data the stderr data will end
up in the dependency file as well. Fix this by clearing m_dest_data
properly.
Joel Rosdahl [Mon, 27 Jul 2020 18:56:45 +0000 (20:56 +0200)]
Fix build with Clang 10
Clang 10 says “error: explicitly defaulted move constructor is
implicitly deleted [...] note: move constructor of 'TemporaryFile' is
implicitly deleted because base class 'NonCopyable' has a deleted move
constructor”, so we’ll just have to do without NonCopyable. The effect
will be the same in pracice due to the “Fd fd” member not being
copyable.
The argument adds another mechanism to control contents of cache directory. And
is based on the LRU tracking behaviour.
As of now there is no way for ccache to eliminate files which were
are no longer needed. As a result these files stay and are kept around until
either max_files/max_size is reached.
If a particular project is being built regularly but for some reason is allowed
to grow in size, then under such circumstances using the LRU mechanism to control
cache size, lends as perfect solution.
The argument takes a parameter N and performs a cleanup.
While performing cleanup the oldest file in ccache can
only be N seconds old. However this cleanup will not take max_files and
max_old into consideration
Joel Rosdahl [Sat, 25 Jul 2020 18:29:44 +0000 (20:29 +0200)]
Let ResultRetriever collect and operate on the full dependency data
When rewriting the dependency target (#592) the target can in theory
span chunk boundaries, so let ResultRetriever collect and operate on the
full data, just like the stderr output.