Files
swift-mirror/userdocs/diagnostics/compilation-caching.md
2025-07-02 22:44:31 -07:00

1.1 KiB

Compilation caching (CompilationCaching)

Errors and warnings related to the compiler's CAS compilation caching.

Overview

Compilation caching allows Swift compiler to reuse previously compiled outputs if the identical compilation has been done before.

When compilation caching is enabled (via -cache-compile-job flag), the build commands are expected to be generated by Swift driver, and the command-line of compilation tasks contains CASIDs that are objects constructed during planning phase. These CAS objects need to be backed by CAS storage and in a specific scheme accepted by the compiler. Any malformed command-line will cause error in this category. If the inputs changed, always fallback to re-run swiftc command to plan the new build commands.

The other category of error is unexpected failures when performing reads/writes to Content Addressable Storage. Please refer to the error message (contains errors provided by CAS storage) for clues. If the error persists, consider clearing the cache. To clear the cache, delete the directory pointed to by the -cas-path option. Note that the CAS directory should only be deleted as a whole when not used.