Joel Rosdahl [Thu, 26 Mar 2026 08:13:39 +0000 (09:13 +0100)]
fix: Disable base directory when using MSVC's /Yc option
When creating a precompiled header (PCH), MSVC does not like relative
paths for /Yc and /FI arguments, so don't rewrite paths to relative in
that case.
Björn Svensson [Mon, 23 Mar 2026 19:29:32 +0000 (20:29 +0100)]
fix(http): Treat HTTP 2xx with empty body as cache miss (#1707)
fix(storage): Treat empty remote storage entries as errors
A remote storage backend returning a value with an empty body indicates
a corrupt or misconfigured entry, not a cache miss. Check for empty
values in the storage layer so that all current and future backends are
covered. The error is logged but the backend is not marked as failed,
since other entries may still be valid.
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
The POSIX error for a missing command is not stable across systems. Some
environments report the posix_spawnp failure directly, while others
return a shell-style "Non-zero exit code: 127" instead.
Accept both outcomes in the test and capture the actual error string to
make future failures easier to diagnose.
Joel Rosdahl [Sat, 14 Mar 2026 12:06:18 +0000 (13:06 +0100)]
test: Don't check `.ltrans0.ltrans.su` files in `-flto` tests (#1704)
Different compilers produce different stack-usage files when linking
object files compiled with `-fstack-usage -flto`. Since ccache does not
cache linking anyway, skip checking the linking results to avoid
compiler-specific expectations.
Joel Rosdahl [Sun, 8 Mar 2026 12:19:11 +0000 (13:19 +0100)]
fix: Use OS-specific methods to reliably find the ccache executable path
argv[0] is not guaranteed to reflect the actual location of the
executable (e.g. when invoked via a symlink). Use platform-specific APIs
instead. Fall back to the argv[0]-based approach if the OS method fails.
Joel Rosdahl [Sat, 7 Mar 2026 21:42:11 +0000 (22:42 +0100)]
fix: Search for storage helper in libexec before PATH
Previously ccache searched for storage helpers in PATH before libexec
directories. The idea was that users could easily override a
system-installed helper by placing a newer version earlier in PATH.
However, this also meant that PATH was consulted even when a libexec
directory had been explicitly configured, or when the helper was
installed in the intended system location. In these cases, helpers found
in PATH could take precedence over the expected libexec helper.
Since installing helpers in a libexec directory is the intended
deployment model, prefer libexec locations over PATH.
Joel Rosdahl [Thu, 26 Feb 2026 10:40:43 +0000 (11:40 +0100)]
feat: Add support for directory-specific configuration file
Ccache now searches for a ccache.conf file (separate from the
cache-specific config) in the current working directory and its parent
directories. This allows per-project configuration without modifying the
user's cache-specific config.
Directory config has higher priority than other config files but lower
priority than environment variables.
The search stops when reaching a ceiling_dirs entry (default: $HOME), a
ceiling_marker (default: .git), a mount point or a directory owned by
another user. A found file is accepted only if it is owned by the
effective user and not world-writable.
For security, unsafe settings are rejected by default, where unsafe
means affecting which commands to execute, which files to write and
which network connections to make. They are only allowed when the
directory config file is under a trusted path listed in safe_dirs.
Joel Rosdahl [Thu, 12 Feb 2026 20:05:30 +0000 (21:05 +0100)]
refactor: Generalize "already preprocessed" compiler language slightly (#1684)
- Rename ArgsInfo::direct_i_file to preprocess_input_file, since that's
what it now means.
- Add "ir" as a language and let "-fthinlto-index=" use that language
implicitly instead of piggybacking on "assembler".
CMake will call `enable_language` for all languages passed to `project`.
This deduplicates the work and only enables one assembler depending on
the platform.
Joel Rosdahl [Sun, 18 Jan 2026 13:48:06 +0000 (14:48 +0100)]
feat: Add support for remote storage helpers
This commit adds support for communicating with a remote storage server
using a long-lived local helper process, started by ccache on demand.
The helper process can keep connections alive (thus amortizing the
session setup cost), and knowledge about remote storage protocols can be
kept out of the ccache code base, making it possible to develop and
release support for different storage server protocols independently.
The storage helper listens to a Unix-domain socket on POSIX systems and
a named pipe on Windows systems. Ccache communicates with it using a
custom IPC protocol, described in doc/remote_storage_helper_spec.md. The
helper is named ccache-storage-<scheme> (e.g. ccache-storage-https) and
can be placed in $PATH, next to the ccache executable or in ccache's
libexec directory. Storage helpers time terminate after a while on
inactivity.
Built-in support for http and redis is kept for now but will likely be
removed in a future ccache release.
- The syntax of the remote_storage/CCACHE_REMOTE_STORAGE configuration
option has been improved (in a backward compatible way): What used to
be called "attributes" are now split into "properties" and "custom
attributes", where properties are things that ccache knows about and
acts on (e.g. read-only and shards) while attributes are custom
key-value pairs sent to the helper without ccache knowing or caring
about them. Syntax: A property is "key=value", a custom attribute is
"@key=value".
- Properties/attributes are now separated by whitespace instead of pipe
characters.
New remote storage properties:
- data-timeout: Timeout for send/receive data transfer. Resets whenever
data is received or can be sent. Default: 1s.
- request-timeout: Timeout for the whole request. Default: 10s.
- idle-timeout: Timeout for the helper process to wait before exiting
after client inactivity (0s: stay up indefinitely). Default: 10m.
- helper: Override which storage helper to spawn (either a filename or a
full path). This is mainly useful when developing or testing new
helpers.
The new command line option "--stop-storage-helpers" can be used to ask
spawned storage helpers to stop immediately.
A new "libexec_dirs" configuration option is available for overriding
the default libexec determined at build time.