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)
Joel Rosdahl [Thu, 1 Oct 2020 11:00:30 +0000 (13:00 +0200)]
Handle missing .gcno file gracefully
GCC ≥9 has changed behavior for -ftest-coverage and --coverage in
combination with -fprofile-dir=dir:
- Without -fprofile-dir=dir the file is placed next to the object file
but with a “.gcno” extension.
- With -fprofile-dir=dir the file is also place next to the object file
(i.e. not in the specified profile directory) but the same style of
name as used for “.gcda” files (full pathname with slashes replaced
with hash characters).
Fix this by:
- Checking if the expected (GCC <9) .gcno file is present. If not, fall
back to running the compiler and increment the “unsupported option”
counter.
- Making sure to perform the above check before copying the object file
to the cache so that a later ccache invocation won’t believe that
there is a result in the cache.
- Improving the copy_file routine to not create the destination file
until it knows that there is a source file to copy from.
Joel Rosdahl [Wed, 30 Sep 2020 20:18:09 +0000 (22:18 +0200)]
Simplify source package generation
Since it now works to build from “git archive” archives, use such an
archive as the official source code release archive instead of using
CPack with a custom install script for modifying the source code. We can
revisit this in the future when and if we want a source code release
archive that is not simply an export of the version-controlled source
code.
Joel Rosdahl [Wed, 30 Sep 2020 15:13:48 +0000 (17:13 +0200)]
Make it possible to build from “git archive” source archives
The ccache CMake scripts currently support building from an official
release archive or in a Git repository but not from a source archive
created by “git archive”.
Improve this by adding directives so that “git archive” substitutes
needed information when exporting the source tree.
Joel Rosdahl [Mon, 28 Sep 2020 12:56:43 +0000 (14:56 +0200)]
Use ubuntu-18.04 instead of ubuntu-20.04 for Clang-Tidy
The ubuntu-20.04 VM has intermittent build errors that look like this:
sudo apt-get install libzstd-dev clang-tidy
[...]
The following packages have unmet dependencies:
clang-tidy : Depends: clang-tidy-10 (>= 10~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Clang-Tidy 9 also found “function ... has a definition with different
parameter names” warnings that needed to be fixed as part of this.
Joel Rosdahl [Sun, 27 Sep 2020 14:53:09 +0000 (16:53 +0200)]
Handle short read when writing result files
Result::Write::write_embedded_file_entry assumes that read(2) never
performs a “short read” (fewer bytes than the supplied count) for files.
A short read can however happen if the process is interrupted by a
signal, for instance on NFS with the “intr” mount option.
Fix this by properly reducing the remaining bytes counter by the amount
of actually read bytes.
Joel Rosdahl [Thu, 24 Sep 2020 19:14:11 +0000 (21:14 +0200)]
Improve CMake targets related to documentation
- Rename the documentation target to doc-html.
- Rename the manpage target to doc-man-page.
- Make the doc-html target not recreate documentation files each time it
is run by using the OUTPUT form of add_custom_command.
- Similar for the doc-man-page target.
- Add doc target which builds both HTML documentation and man page.
Reducing file lengths should be beneficial since it reduces the number
of needed system calls when scanning many files in the cache. The effect
is very small but there is no real downside. See also b16001a67f4389956ef6e7ccf7d8023684b57119.
Base32 is chosen since the encoding algorithm is very simple compared to
e.g. base36. Base64 cannot be used since the encoded digest string is
used in filenames and the cache directory may be located on a case
insensitive filesystem. The base32hex variant is chosen instead of the
other base32 variants since it feels more natural and there are no
visual ambiguity issues.
The first two bytes are encoded as base16 to maintain compatibility with
the cleanup algorithm in older ccache versions and to allow for up to
four uniform cache levels.
Joel Rosdahl [Tue, 22 Sep 2020 06:13:13 +0000 (08:13 +0200)]
Fix base32hex code
- Const-ified input parameter.
- Use non-reserved macro for the include guard.
- Use unsigned int buffer to avoid “left shift of 1236923897 by 8 places
cannot be represented in type int” reported by Clang’s
UndefinedBehaviorSanitizer.