Skip to content

Commit a298c75

Browse files
[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 <[email protected]>
1 parent 81a0f98 commit a298c75

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

include/swift/AST/DiagnosticGroups.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ GROUP(StringInterpolationConformance, "string-interpolation-conformance")
7171
GROUP(TemporaryPointers, "temporary-pointers")
7272
GROUP(TrailingClosureMatching, "trailing-closure-matching")
7373
GROUP(UnknownWarningGroup, "unknown-warning-group")
74+
GROUP(CompilationCaching, "compilation-caching")
7475

7576
#define UNDEFINE_DIAGNOSTIC_GROUPS_MACROS
7677
#include "swift/AST/DefineDiagnosticGroupsMacros.h"

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -509,30 +509,30 @@ REMARK(matching_output_produced,none,
509509
"produced matching output file '%0' for deterministic check: hash '%1'", (StringRef, StringRef))
510510

511511
// Caching related diagnostics
512-
ERROR(error_caching_no_cas_fs, none,
512+
GROUPED_ERROR(error_caching_no_cas_fs, CompilationCaching, none,
513513
"caching is enabled without CAS file-system options, input is not immutable", ())
514514
ERROR(error_prefix_mapping, none, "cannot create scanner prefix mapping: '%0'", (StringRef))
515515

516516
REMARK(replay_output, none, "replay output file '%0': key '%1'", (StringRef, StringRef))
517517
REMARK(output_cache_miss, none, "cache miss for input file '%0': key '%1'", (StringRef, StringRef))
518518

519519
// CAS related diagnostics
520-
ERROR(error_invalid_cas_id, none, "CAS cannot parse id '%0': %1", (StringRef, StringRef))
521-
ERROR(error_cas, none, "CAS error encountered during %0: %1", (StringRef, StringRef))
522-
ERROR(error_cas_fs_creation, none, "cannot create CAS filesystem: %0", (StringRef))
523-
ERROR(error_cache_key_creation, none, "cannot create cache key for compilation %0: %1", (StringRef, StringRef))
524-
ERROR(error_cas_file_ref, none, "cannot load file %0 from CAS filesystem", (StringRef))
525-
ERROR(error_cas_conflict_options, none, "cannot setup CAS due to conflicting '-cas-*' options", ())
526-
ERROR(error_cas_initialization, none, "CAS cannot be initialized from the specified '-cas-*' options: %0", (StringRef))
527-
ERROR(error_cas_malformed_input, none, "CAS input '%0' is malformed: %1", (StringRef, StringRef))
528-
WARNING(cache_replay_failed, none, "cache replay failed: %0", (StringRef))
529-
530-
ERROR(error_failed_cached_diag, none, "failed to serialize cached diagnostics: %0", (StringRef))
531-
ERROR(error_replay_cached_diag, none, "failed to replay cached diagnostics: %0", (StringRef))
532-
533-
ERROR(error_load_input_from_cas, none, "failed to load input '%0' from CAS", (StringRef))
534-
535-
ERROR(error_wrong_input_num_for_input_file_key, none, "-input-file-key only support one input file", ())
520+
GROUPED_ERROR(error_invalid_cas_id, CompilationCaching, none, "CAS cannot parse id '%0': %1", (StringRef, StringRef))
521+
GROUPED_ERROR(error_cas, CompilationCaching, none, "CAS error encountered during %0: %1", (StringRef, StringRef))
522+
GROUPED_ERROR(error_cas_fs_creation, CompilationCaching, none, "cannot create CAS filesystem: %0", (StringRef))
523+
GROUPED_ERROR(error_cache_key_creation, CompilationCaching, none, "cannot create cache key for compilation %0: %1", (StringRef, StringRef))
524+
GROUPED_ERROR(error_cas_file_ref, CompilationCaching, none, "cannot load file %0 from CAS filesystem", (StringRef))
525+
GROUPED_ERROR(error_cas_conflict_options, CompilationCaching, none, "cannot setup CAS due to conflicting '-cas-*' options", ())
526+
GROUPED_ERROR(error_cas_initialization, CompilationCaching, none, "CAS cannot be initialized from the specified '-cas-*' options: %0", (StringRef))
527+
GROUPED_ERROR(error_cas_malformed_input, CompilationCaching, none, "CAS input '%0' is malformed: %1", (StringRef, StringRef))
528+
GROUPED_WARNING(cache_replay_failed, CompilationCaching, none, "cache replay failed: %0", (StringRef))
529+
530+
GROUPED_ERROR(error_failed_cached_diag, CompilationCaching, none, "failed to serialize cached diagnostics: %0", (StringRef))
531+
GROUPED_ERROR(error_replay_cached_diag, CompilationCaching, none, "failed to replay cached diagnostics: %0", (StringRef))
532+
533+
GROUPED_ERROR(error_load_input_from_cas, CompilationCaching, none, "failed to load input '%0' from CAS", (StringRef))
534+
535+
GROUPED_ERROR(error_wrong_input_num_for_input_file_key, CompilationCaching, none, "-input-file-key only support one input file", ())
536536

537537
// Dependency Verifier Diagnostics
538538
ERROR(missing_member_dependency,none,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Compilation Caching
2+
3+
Compilation caching allows Swift compiler to reuse previously compiled outputs if the identical
4+
compilation has been done before.
5+
6+
When compilation caching is enabled (via `-cache-compile-job` flag), the build commands are
7+
expected to be generated by Swift driver, and the command-line of compilation tasks contains
8+
CASIDs that are objects constructed during planning phase. These CAS objects need to be backed
9+
by CAS storage and in a specific scheme accepted by the compiler. Any malformed command-line
10+
will cause error in this category. If the inputs changed, always fallback to re-run `swiftc`
11+
command to plan the new build commands.
12+
13+
The other category of error is unexpected failures when performing reads/writes to Content
14+
Addressable Storage. Please refer to the error message (contains errors provided by CAS storage) for clues.
15+
If the error persists, consider clearing the cache. To clear the cache, delete the directory
16+
pointed to by the `-cas-path` option. Note that the CAS directory should only be deleted as a whole when not used.

0 commit comments

Comments
 (0)