diff --git a/include/swift/AST/DiagnosticsFrontend.def b/include/swift/AST/DiagnosticsFrontend.def index 9e8abe5412ad3..58309227dfe23 100644 --- a/include/swift/AST/DiagnosticsFrontend.def +++ b/include/swift/AST/DiagnosticsFrontend.def @@ -494,7 +494,6 @@ REMARK(replay_output, none, "replay output file '%0': key '%1'", (StringRef, Str REMARK(output_cache_miss, none, "cache miss output file '%0': key '%1'", (StringRef, StringRef)) // CAS related diagnostics -ERROR(error_create_cas, none, "failed to create CAS '%0' (%1)", (StringRef, StringRef)) ERROR(error_invalid_cas_id, none, "invalid CASID '%0' (%1)", (StringRef, StringRef)) ERROR(error_cas, none, "CAS error encountered: %0", (StringRef)) diff --git a/include/swift/AST/ModuleDependencies.h b/include/swift/AST/ModuleDependencies.h index dde8b9ef26984..50b7a9ca98671 100644 --- a/include/swift/AST/ModuleDependencies.h +++ b/include/swift/AST/ModuleDependencies.h @@ -20,6 +20,7 @@ #include "swift/Basic/LLVM.h" #include "swift/AST/Import.h" +#include "clang/CAS/CASOptions.h" #include "clang/Tooling/DependencyScanning/DependencyScanningService.h" #include "clang/Tooling/DependencyScanning/DependencyScanningTool.h" #include "llvm/ADT/ArrayRef.h" @@ -767,6 +768,9 @@ class SwiftDependencyScanningService { ModuleDependenciesKindMap ModuleDependenciesMap; }; + /// The CASOption created the Scanning Service if used. + llvm::Optional CASOpts; + /// The persistent Clang dependency scanner service Optional ClangScanningService; @@ -863,7 +867,7 @@ class SwiftDependencyScanningService { void overlaySharedFilesystemCacheForCompilation(CompilerInstance &Instance); /// Setup caching service. - void setupCachingDependencyScanningService(CompilerInstance &Instance); + bool setupCachingDependencyScanningService(CompilerInstance &Instance); private: /// Enforce clients not being allowed to query this cache directly, it must be /// wrapped in an instance of `ModuleDependenciesCache`. diff --git a/include/swift/Basic/LangOptions.h b/include/swift/Basic/LangOptions.h index ccd39bb2a26cd..6423117361a6a 100644 --- a/include/swift/Basic/LangOptions.h +++ b/include/swift/Basic/LangOptions.h @@ -23,6 +23,7 @@ #include "swift/Basic/LLVM.h" #include "swift/Basic/Version.h" #include "swift/Config.h" +#include "clang/CAS/CASOptions.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Hashing.h" #include "llvm/ADT/SmallString.h" @@ -820,7 +821,7 @@ namespace swift { std::string Optimization; /// clang CASOptions. - std::string CASPath; + llvm::Optional CASOpts; /// Cache key for imported bridging header. std::string BridgingHeaderPCHCacheKey; diff --git a/include/swift/Frontend/CachingUtils.h b/include/swift/Frontend/CachingUtils.h index 501a65415d38e..343de5ccdc3da 100644 --- a/include/swift/Frontend/CachingUtils.h +++ b/include/swift/Frontend/CachingUtils.h @@ -39,7 +39,7 @@ bool replayCachedCompilerOutputs( llvm::cas::ObjectStore &CAS, llvm::cas::ActionCache &Cache, llvm::cas::ObjectRef BaseKey, DiagnosticEngine &Diag, const FrontendInputsAndOutputs &InputsAndOutputs, - CachingDiagnosticsProcessor &CDP); + CachingDiagnosticsProcessor &CDP, bool CacheRemarks); /// Load the cached compile result from cache. std::unique_ptr loadCachedCompileResultFromCacheKey( diff --git a/include/swift/Frontend/FrontendOptions.h b/include/swift/Frontend/FrontendOptions.h index d19af926aafc8..b328bf417be7f 100644 --- a/include/swift/Frontend/FrontendOptions.h +++ b/include/swift/Frontend/FrontendOptions.h @@ -21,6 +21,7 @@ #include "llvm/ADT/Hashing.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringMap.h" +#include "clang/CAS/CASOptions.h" #include #include @@ -122,11 +123,17 @@ class FrontendOptions { /// The module for which we should verify all of the generic signatures. std::string VerifyGenericSignaturesInModule; - /// Use CAS. - bool EnableCAS = false; + /// Enable compiler caching. + bool EnableCaching = false; - /// The CAS Path. - std::string CASPath; + /// Enable compiler caching remarks. + bool EnableCachingRemarks = false; + + /// Skip replaying outputs from cache. + bool CacheSkipReplay = false; + + /// CASOptions + clang::CASOptions CASOpts; /// CASFS Root. std::vector CASFSRootIDs; diff --git a/include/swift/Option/FrontendOptions.td b/include/swift/Option/FrontendOptions.td index b88be4acad09a..e9770c6ff6ace 100644 --- a/include/swift/Option/FrontendOptions.td +++ b/include/swift/Option/FrontendOptions.td @@ -1217,6 +1217,23 @@ def always_compile_output_files : Flag<["-"], "always-compile-output-files">, HelpText<"Always compile output files even it might not change the results">; +// CAS/Caching related options. +def allow_unstable_cache_key_for_testing: Flag<["-"], "allow-unstable-cache-key-for-testing">, + HelpText<"Allow compilation caching with unstable inputs for testing purpose">; + +def bridging_header_pch_key : Separate<["-"], "bridging-header-pch-key">, + HelpText<"Cache Key for bridging header pch">; + +def clang_include_tree: Flag<["-"], "clang-include-tree">, + HelpText<"Use clang include tree">; + +def cas_fs: Separate<["-"], "cas-fs">, + HelpText<"Root CASID for CAS FileSystem">, MetaVarName<"">; + +def clang_include_tree_root: Separate<["-"], "clang-include-tree-root">, + HelpText<"Clang Include Tree CASID">, MetaVarName<"">; + + def experimental_spi_only_imports : Flag<["-"], "experimental-spi-only-imports">, HelpText<"Enable use of @_spiOnly imports">; diff --git a/include/swift/Option/Options.td b/include/swift/Option/Options.td index dba97b91132e0..510242c95e092 100644 --- a/include/swift/Option/Options.td +++ b/include/swift/Option/Options.td @@ -1812,36 +1812,32 @@ def gcc_toolchain: Separate<["-"], "gcc-toolchain">, MetaVarName<"">, HelpText<"Specify a directory where the clang importer and clang linker can find headers and libraries">; -def cas_path: Separate<["-"], "cas-path">, +def cache_compile_job: Flag<["-"], "cache-compile-job">, Flags<[FrontendOption, NewDriverOnlyOption]>, - HelpText<"Path to CAS">, MetaVarName<"">; + HelpText<"Enable compiler caching">; -def allow_unstable_cache_key_for_testing: Flag<["-"], "allow-unstable-cache-key-for-testing">, - Flags<[FrontendOption, HelpHidden, NoDriverOption]>, - HelpText<"Allow compilation caching with unstable inputs for testing purpose">; - -def bridging_header_pch_key : Separate<["-"], "bridging-header-pch-key">, - Flags<[FrontendOption, HelpHidden, ArgumentIsPath]>, - HelpText<"Cache Key for bridging header pch">; +def cache_remarks: Flag<["-"], "cache-remarks">, + Flags<[FrontendOption, NewDriverOnlyOption]>, + HelpText<"Show remarks for compiler caching">; -def clang_include_tree: Flag<["-"], "clang-include-tree">, - Flags<[FrontendOption, NoDriverOption]>, - HelpText<"Use clang include tree">; +def cache_disable_replay: Flag<["-"], "cache-disable-replay">, + Flags<[FrontendOption, NewDriverOnlyOption]>, + HelpText<"Skip loading the compilation result from cache">; +def cas_path: Separate<["-"], "cas-path">, + Flags<[FrontendOption, NewDriverOnlyOption]>, + HelpText<"Path to CAS">, MetaVarName<"">; -// END ONLY SUPPORTED IN NEW DRIVER +def cas_plugin_path: Separate<["-"], "cas-plugin-path">, + Flags<[FrontendOption, NewDriverOnlyOption]>, + HelpText<"Path to CAS Plugin">, MetaVarName<"">; -def enable_cas: Flag<["-"], "enable-cas">, - Flags<[FrontendOption, NoDriverOption]>, - HelpText<"Enable CAS for swift-frontend">; +def cas_plugin_option: Separate<["-"], "cas-plugin-option">, + Flags<[FrontendOption, NewDriverOnlyOption]>, + HelpText<"Option pass to CAS Plugin">, MetaVarName<"=