Joel Rosdahl [Sun, 14 Jan 2024 09:46:54 +0000 (10:46 +0100)]
fix: Disable caching for modified source/include files
On a cache miss, ccache opts out of the direct mode when a "too new"
include file is found. This is done to avoid a race condition in the
direct mode when a header file if modified after ccache is invoked but
before the compiler is executed. Modifying the main source code file is
not a race condition when "run_second_cpp = false", which was the case
at the time the direct mode was introduced. However, the default of
run_second_cpp was changed to true in ccache 3.3, and the potiential
race condition then exists for both the source and the include files.
Fix this by disabling caching completely (not only the direct mode) when
modification of a source/include file is detected.
Joel Rosdahl [Sat, 2 Dec 2023 11:24:07 +0000 (12:24 +0100)]
feat: Improve processing of input file arguments
Instead of checking if a non-option argument has a known file extension,
switch to the better heuristic of checking if the file exists or not: if
it doesn't exist it isn't an input argument.
Rafael Kitover [Sun, 29 Oct 2023 08:33:09 +0000 (08:33 +0000)]
fix: Devmode unused function warnings on new MSVC (#1342)
MSVC apparently has overrides for the two definitions of operator== in
unittest/test_util_string.cpp in the <utility> header, raising a warning
about them being local unused functions:
Rafael Kitover [Sun, 29 Oct 2023 08:31:15 +0000 (08:31 +0000)]
feat: cmake -DOFFLINE=TRUE for offline builds (#1341)
Add the cmake option OFFLINE, defaulting to the value of the standard
variable FETCHCONTENT_FULLY_DISCONNECTED, which is OFF by default, to
disable downloading anything from the internet.
When ON, set FETCHCONTENT_FULLY_DISCONNECTED to ON, ZSTD_FROM_INTERNET
to OFF and HIREDIS_FROM_INTERNET to OFF.
When downloading is OFF and either library is not found, throw an error
using find_package_handle_standard_args().
Add the option to INSTALL.md doc.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Rafael Kitover [Sun, 29 Oct 2023 08:28:15 +0000 (08:28 +0000)]
fix: cmake -DSTATIC_LINK=ON on Linux/macOS (#1340)
Make linking dependent libraries as static a hard requirement when
STATIC_LINK is ON, as opposed to the previous behavior of falling back
to dynamic libraries.
A side-effect of this is that if only a dynamic zstd/hiredis is
available on a system, it will not be found, and the download and build
code will be invoked to build a static version from the internet.
Add a general case to handle Linux, macOS and similar by linking
libgcc/libstdc++ statically on gcc/clang.
Move the code into cmake/StaticLinkSupport.cmake and include it from the
main file.
Fix #1330
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Joel Rosdahl [Mon, 16 Oct 2023 17:33:31 +0000 (19:33 +0200)]
fix: Let DirEntry::size_on_disk return likely size on disk
st_blocks in struct stat cannot be trusted for some filesystems that do
transparent compression or deduplication. For instance, ZFS can adjust
the block count some time in the future when compression is finished.
The only reasonable fix for this seems to be to just guess how much
space the file will take using st_size.
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.