Files
swift-mirror/userdocs/diagnostics/compilation-caching.md
Steven Wu a298c7532e [Caching] Put caching diagnostics into its own DiagnosticGroups (#82507)
Add explanation and documentation for swift caching diagnostics.

rdar://154335823

<!--
If this pull request is targeting a release branch, please fill out the
following form:

https://github.com/swiftlang/.github/blob/main/PULL_REQUEST_TEMPLATE/release.md?plain=1

Otherwise, replace this comment with a description of your changes and
rationale. Provide links to external references/discussions if
appropriate.
If this pull request resolves any GitHub issues, link them like so:

  Resolves <link to issue>, resolves <link to another issue>.

For more information about linking a pull request to an issue, see:

https://docs.github.com/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
-->

<!--
Before merging this pull request, you must run the Swift continuous
integration tests.
For information about triggering CI builds via @swift-ci, see:

https://github.com/apple/swift/blob/main/docs/ContinuousIntegration.md#swift-ci

Thank you for your contribution to Swift!
-->

---------

Co-authored-by: Allan Shortlidge <tshortli@gmail.com>
2025-06-27 15:15:12 -07:00

1.0 KiB

Compilation Caching

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.