mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Mirror outputs into CAS using CASOutputBackend
When `-enable-cas` option is used, mirror the output into CAS so it can be fetched from CAS with the cache key in the future.
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "swift/Basic/FileTypes.h"
|
||||
#include "swift/Basic/SourceManager.h"
|
||||
#include "swift/Basic/Statistic.h"
|
||||
#include "swift/Frontend/CachingUtils.h"
|
||||
#include "swift/Frontend/CompileJobCacheKey.h"
|
||||
#include "swift/Frontend/ModuleInterfaceLoader.h"
|
||||
#include "swift/Parse/Lexer.h"
|
||||
@@ -448,6 +449,15 @@ void CompilerInstance::setupOutputBackend() {
|
||||
OutputBackend =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::OnDiskOutputBackend>();
|
||||
|
||||
// Mirror the output into CAS.
|
||||
if (supportCaching()) {
|
||||
auto CASOutputBackend = createSwiftCachingOutputBackend(
|
||||
*CAS, *ResultCache, *CompileJobBaseKey,
|
||||
Invocation.getFrontendOptions().InputsAndOutputs);
|
||||
OutputBackend =
|
||||
llvm::vfs::makeMirroringOutputBackend(OutputBackend, CASOutputBackend);
|
||||
}
|
||||
|
||||
// Setup verification backend.
|
||||
// Create a mirroring outputbackend to produce hash for output files.
|
||||
// We cannot skip disk here since swift compiler is expecting to read back
|
||||
@@ -1043,6 +1053,14 @@ bool CompilerInstance::canImportCxxShim() const {
|
||||
!Invocation.getFrontendOptions().InputsAndOutputs.hasModuleInterfaceOutputPath();
|
||||
}
|
||||
|
||||
bool CompilerInstance::supportCaching() const {
|
||||
if (!Invocation.getFrontendOptions().EnableCAS)
|
||||
return false;
|
||||
|
||||
return FrontendOptions::supportCompilationCaching(
|
||||
Invocation.getFrontendOptions().RequestedAction);
|
||||
}
|
||||
|
||||
ImplicitImportInfo CompilerInstance::getImplicitImportInfo() const {
|
||||
auto &frontendOpts = Invocation.getFrontendOptions();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user