mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Frontend: teach the compiler to use a backup directory to find .swiftinterface files to compile
This mechanism allows the compiler to use a backup interface file to build into a binary module when a corresponding interface file from the SDK is failing for whatever reasons. This mechansim should be entirely opaque to end users except several diagnostic messages communicating backup interfaces are used. Part of rdar://77676064
This commit is contained in:
@@ -336,17 +336,25 @@ class ModuleInterfaceCheckerImpl: public ModuleInterfaceChecker {
|
||||
ASTContext &Ctx;
|
||||
std::string CacheDir;
|
||||
std::string PrebuiltCacheDir;
|
||||
std::string BackupInterfaceDir;
|
||||
ModuleInterfaceLoaderOptions Opts;
|
||||
RequireOSSAModules_t RequiresOSSAModules;
|
||||
|
||||
public:
|
||||
explicit ModuleInterfaceCheckerImpl(ASTContext &Ctx, StringRef cacheDir,
|
||||
StringRef prebuiltCacheDir,
|
||||
StringRef BackupInterfaceDir,
|
||||
ModuleInterfaceLoaderOptions opts,
|
||||
RequireOSSAModules_t requiresOSSAModules)
|
||||
: Ctx(Ctx), CacheDir(cacheDir), PrebuiltCacheDir(prebuiltCacheDir),
|
||||
BackupInterfaceDir(BackupInterfaceDir),
|
||||
Opts(opts), RequiresOSSAModules(requiresOSSAModules) {}
|
||||
|
||||
explicit ModuleInterfaceCheckerImpl(ASTContext &Ctx, StringRef cacheDir,
|
||||
StringRef prebuiltCacheDir,
|
||||
ModuleInterfaceLoaderOptions opts,
|
||||
RequireOSSAModules_t requiresOSSAModules):
|
||||
ModuleInterfaceCheckerImpl(Ctx, cacheDir, prebuiltCacheDir, StringRef(),
|
||||
opts, requiresOSSAModules) {}
|
||||
std::vector<std::string>
|
||||
getCompiledModuleCandidatesForInterface(StringRef moduleName,
|
||||
StringRef interfacePath) override;
|
||||
@@ -359,6 +367,8 @@ public:
|
||||
ArrayRef<std::string> candidates,
|
||||
StringRef outPath) override;
|
||||
bool isCached(StringRef DepPath);
|
||||
std::string getBackupPublicModuleInterfacePath(StringRef moduleName,
|
||||
StringRef interfacePath) override;
|
||||
};
|
||||
|
||||
/// A ModuleLoader that runs a subordinate \c CompilerInvocation and
|
||||
@@ -414,7 +424,8 @@ public:
|
||||
SourceManager &SourceMgr, DiagnosticEngine &Diags,
|
||||
const SearchPathOptions &SearchPathOpts, const LangOptions &LangOpts,
|
||||
const ClangImporterOptions &ClangOpts, StringRef CacheDir,
|
||||
StringRef PrebuiltCacheDir, StringRef ModuleName, StringRef InPath,
|
||||
StringRef PrebuiltCacheDir, StringRef BackupInterfaceDir,
|
||||
StringRef ModuleName, StringRef InPath,
|
||||
StringRef OutPath, bool SerializeDependencyHashes,
|
||||
bool TrackSystemDependencies, ModuleInterfaceLoaderOptions Opts,
|
||||
RequireOSSAModules_t RequireOSSAModules);
|
||||
@@ -423,7 +434,9 @@ public:
|
||||
struct InterfaceSubContextDelegateImpl: InterfaceSubContextDelegate {
|
||||
private:
|
||||
SourceManager &SM;
|
||||
DiagnosticEngine &Diags;
|
||||
public:
|
||||
DiagnosticEngine *Diags;
|
||||
private:
|
||||
llvm::BumpPtrAllocator Allocator;
|
||||
llvm::StringSaver ArgSaver;
|
||||
std::vector<StringRef> GenericArgs;
|
||||
@@ -439,7 +452,7 @@ private:
|
||||
// Diagnose this inside the interface file, if possible.
|
||||
loc = SM.getLocFromExternalSource(interfacePath, 1, 1);
|
||||
}
|
||||
return Diags.diagnose(loc, ID, std::move(Args)...);
|
||||
return Diags->diagnose(loc, ID, std::move(Args)...);
|
||||
}
|
||||
void
|
||||
inheritOptionsForBuildingInterface(const SearchPathOptions &SearchPathOpts,
|
||||
@@ -452,11 +465,12 @@ private:
|
||||
SourceLoc diagnosticLoc);
|
||||
public:
|
||||
InterfaceSubContextDelegateImpl(
|
||||
SourceManager &SM, DiagnosticEngine &Diags,
|
||||
SourceManager &SM, DiagnosticEngine *Diags,
|
||||
const SearchPathOptions &searchPathOpts, const LangOptions &langOpts,
|
||||
const ClangImporterOptions &clangImporterOpts,
|
||||
ModuleInterfaceLoaderOptions LoaderOpts, bool buildModuleCacheDirIfAbsent,
|
||||
StringRef moduleCachePath, StringRef prebuiltCachePath,
|
||||
StringRef backupModuleInterfaceDir,
|
||||
bool serializeDependencyHashes, bool trackSystemDependencies,
|
||||
RequireOSSAModules_t requireOSSAModules);
|
||||
std::error_code runInSubContext(StringRef moduleName,
|
||||
|
||||
Reference in New Issue
Block a user