Joel Rosdahl [Fri, 18 Aug 2023 20:17:40 +0000 (22:17 +0200)]
fix: Fix bookkeeping of raw files
Ccache 4.8-4.8.2 notes the size and count of raw files (written to the
cache if hard link or file clone mode is enabled) to a level 2 stats
file. However, the new cleanup algorithm (also introduced in 4.8)
assumes that all size/count statistics are placed in a level 1 stats
file. After a "ccache -c", the raw files will be "rediscovered" and
noted in level 1 stats files, thus duplicating bookkeeping in level 2
stats files, resulting in a too high cache size figure in "ccache -s".
To fix this, ccache will now:
- Note size/count of raw files in the proper level 1 stats file.
- When storing an entry on a cache miss, detect if the corresponding
level 2 stats file has non-zero size/count statistics and propagate
them to the level 1 stats file if so.
- Zero out files/count statistics for level 2 stats file on "ccache -c".
This means that the reported cache size will gradually correct itself
automatically. Alternatively, the user can run "ccache -c" to fix all
counters immediately.
Joel Rosdahl [Tue, 6 Jun 2023 19:42:12 +0000 (21:42 +0200)]
fix: Don't pass -v to the preprocessor
The -v option tells the compiler to print various diagnostics to stdout,
including randomly generated filenames. When ccache calls the
preprocessor and -v is on the command line, the random information will
become part of the input hash, making the preprocessor mode always
produce cache misses.
Fix this by only passing -v when compiling, not preprocessing.
Rafael Kitover [Tue, 23 May 2023 21:42:12 +0000 (21:42 +0000)]
fix: Quiet cmake warning for extracted timestamps
For zstd and hiredis downloaded from the Internet, set cmake policy
CMP0135 to NEW to set the timestamps of extracted archive members to the
time of extraction to suppress the cmake dev warning on newer versions
of cmake.
Check that the policy exists so that this works on older versions of
cmake.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Joel Rosdahl [Mon, 22 May 2023 17:58:41 +0000 (19:58 +0200)]
fix: Fix undefined behavior in util::read_file_part for zero count
If util::read_file_part's count argument is 0 (which can currently only
happen in unit tests), we'll do &result[0] where result is
default-initialized std::unique_ptr<uint8_t[]>. This is not allowed even
though we won't actually dereference the pointer. Found by compiling
with -D_GLIBCXX_ASSERTIONS.
With the depend mode enabled, ccache executes the original command line
verbatim, potentially with the addition of a few extra options. However,
for clang or clang-cl it is not possible to simply append the additional
options to the end of the original command line since there may be a
"--" option to indicate the end of options.
Fix this by inserting the additional options directly after the compiler
instead of at the end.
Joel Rosdahl [Mon, 17 Apr 2023 16:08:24 +0000 (18:08 +0200)]
fix: Find Ccache version from lightweight Git tag
Ccache calculates its version from a matching Git tag by using the "git
describe" command, which only considers annotated tags. All ccache tags
are annotated. However, when running a GitHub action job for a tag the
local Git repository is (at least by default) a shallow clone with the
tag being converted to a lightweight tag. This makes "git describe" not
see the tag.
Fix this by adding --tags to "git describe" to make it consider
lightweight tags as well.
Joel Rosdahl [Mon, 17 Apr 2023 06:26:13 +0000 (08:26 +0200)]
ci: Disable Windows 64-bit MSBuild jobs for now
The Windows VS2019 64-bit MSBuild and Windows VS2022 64-bit MSBuild
GitHub actions jobs have started failing on master due to some changes
in the CI environment. See issue #1278.
Tobias Hieta [Tue, 28 Mar 2023 19:45:37 +0000 (21:45 +0200)]
feat: Don't treat /Zi as unsupported for clang-cl (#1266)
For MSVC /Zi is unsupported since it writes a additional
.pdb file per each .obj file and it creates some messy
interaction with ccache. But for clang-cl /Zi is actually
treated as /Z7 and only embeds the debug info in the .obj
file so it makes sense to allow this flag when compiling
with clang-cl.
Joel Rosdahl [Wed, 8 Mar 2023 07:10:27 +0000 (08:10 +0100)]
feat: Support overriding MSVC /Z* options
MSVC options /Zi and /ZI are too hard since they produce separate PDB
files. /Z7 is OK, but if the command line contains /Zi or /ZI followed
by /Z7, MSVC will use the latter (with a warning) but ccache will still
consider the command line too hard.
This commit makes ccache understand that only the last /Z* option will
be used and thus accepts the command line if the last /Z* option is /Z7.
Joel Rosdahl [Thu, 2 Mar 2023 17:14:49 +0000 (18:14 +0100)]
feat: Improve cache size presentation and specification
Aligned how cache size is presented (in "ccache --show-stats", "ccache
--show-compression", "ccache --recompress", debug logs, etc.) and
specified (in configuration files, "ccache --max-size" and "ccache
--trim-max-size"). The size units are now formatted according to the
type of size unit prefix used for the max_size/CCACHE_MAXSIZE setting: a
decimal size unit prefix (k/M/G/T with or without B for bytes) in
max_size means using decimal size unit prefix for presented sizes, and
similar for binary size unit prefixes (Ki/Mi/Gi/Ti with or without B for
bytes). If no unit is specified, GiB is assumed, . For example, "ccache -M
10" means 10 GiB.
Also aligned how cache sizes are calculated. Now all sizes are computed
as "apparent size", i.e., rounded up to the disk block size. This means
that the cache size in "--show-stats" and the sizes presented in
"--show-compression" and "--recompress" now match.
Joel Rosdahl [Wed, 8 Feb 2023 21:24:01 +0000 (22:24 +0100)]
fix: Log config and command line before finding compiler
If the compiler can't be found then ccache exits early and doesn't print
the config and command line to the log. This makes it harder to debug
problems with finding the compiler, like issue #1249.
Improve this by logging "safe things" before searching for the compiler.
Joel Rosdahl [Fri, 3 Feb 2023 12:11:57 +0000 (13:11 +0100)]
fix: Handle Unix-style paths as non-options to MSVC
For MSVC, ccache treats all arguments starting with a slash as an
option, which makes it fail to detect the source code file if it's
passed as a Unix-style absolute path.
Fix this by not treating an argument as an option if it's (a) an unknown
option, and (b) the argument exists as a file in the file system.
Joel Rosdahl [Mon, 30 Jan 2023 20:23:43 +0000 (21:23 +0100)]
build: Fix Zstd and Hiredis downloads for unstable GitHub archives
The content of the Zstd and Hiredis GitHub source achive URLs like
<https://github.com/$X/$Y/archive/$tag.tar.gz> apparently change from
time to time. Color me surprised. [1] says that this is intentional
(although, at the time of writing, reverted temporarily). Let's use
another URL for Zstd and not verify the checksum for Hiredis (since
there is no release source archive).
Joel Rosdahl [Sun, 29 Jan 2023 12:12:30 +0000 (13:12 +0100)]
fix: Cache path relativization in preprocessed output
After PR #1033 and [1], a stat call is made each time a note about an
include file is found in the preprocessed output. Such calls are very
performant on Linux (and therefore unnoticed until now), but apparently
costly on Windows.
Fix this by caching the calculation of relative paths in
process_preprocessed_file.
Joel Rosdahl [Mon, 23 Jan 2023 21:14:54 +0000 (22:14 +0100)]
fix: Disable inode cache if filesystem risks getting full soon
Some filesystems, for instance btrfs with compression enabled,
apparently make a posix_fallocate call succeed without actually
allocating the requested space for the file. This means that if the file
is mapped into memory, like done by the inode cache, the process can
crash when accessing the memory if the filesystem is full.
This commit implements a workaround: the inode cache is disabled if the
filesystem reports that it has less than 100 MiB free space. The free
space check is valid for one second before it is done again. This should
hopefully make crashes very rare in practice.
Joel Rosdahl [Fri, 27 Jan 2023 12:09:25 +0000 (13:09 +0100)]
feat: Allow forcing download of zstd and hiredis again
Before it was possible to force downloading of the Zstandard library
using "-D ZSTD_FROM_INTERNET=ON" and similar for Hiredis. That ability
was lost in 2c742c2c7ca9, so if you for some reason want to not use a
locally installed library you're out of luck.
Improve this by letting ZSTD_FROM_INTERNET and HIREDIS_FROM_INTERNET be
tristate variables:
ON: Always download
AUTO (default): Download if local installation not found
OFF: Never download