Merge pull request #71497 from cachemeifyoucan/eng/PR-122423965

[Caching] Use subInvocation to verify interface
This commit is contained in:
Steven Wu
2024-02-13 09:18:40 -08:00
committed by GitHub
36 changed files with 294 additions and 220 deletions

View File

@@ -1053,7 +1053,7 @@ class ModuleInterfaceLoaderImpl {
}
InterfaceSubContextDelegateImpl astDelegate(
ctx.SourceMgr, &ctx.Diags, ctx.SearchPathOpts, ctx.LangOpts,
ctx.ClangImporterOpts, Opts,
ctx.ClangImporterOpts, ctx.CASOpts, Opts,
/*buildModuleCacheDirIfAbsent*/ true, cacheDir, prebuiltCacheDir,
backupInterfaceDir,
/*serializeDependencyHashes*/ false, trackSystemDependencies,
@@ -1379,17 +1379,16 @@ bool ModuleInterfaceCheckerImpl::tryEmitForwardingModule(
bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
SourceManager &SourceMgr, DiagnosticEngine &Diags,
const SearchPathOptions &SearchPathOpts, const LangOptions &LangOpts,
const ClangImporterOptions &ClangOpts, StringRef CacheDir,
StringRef PrebuiltCacheDir, StringRef BackupInterfaceDir,
StringRef ModuleName, StringRef InPath,
StringRef OutPath, StringRef ABIOutputPath,
bool SerializeDependencyHashes,
const ClangImporterOptions &ClangOpts, const CASOptions &CASOpts,
StringRef CacheDir, StringRef PrebuiltCacheDir,
StringRef BackupInterfaceDir, StringRef ModuleName, StringRef InPath,
StringRef OutPath, StringRef ABIOutputPath, bool SerializeDependencyHashes,
bool TrackSystemDependencies, ModuleInterfaceLoaderOptions LoaderOpts,
RequireOSSAModules_t RequireOSSAModules,
RequireNoncopyableGenerics_t RequireNCGenerics,
bool silenceInterfaceDiagnostics) {
InterfaceSubContextDelegateImpl astDelegate(
SourceMgr, &Diags, SearchPathOpts, LangOpts, ClangOpts, LoaderOpts,
SourceMgr, &Diags, SearchPathOpts, LangOpts, ClangOpts, CASOpts, LoaderOpts,
/*CreateCacheDirIfAbsent*/ true, CacheDir, PrebuiltCacheDir,
BackupInterfaceDir,
SerializeDependencyHashes, TrackSystemDependencies,
@@ -1565,7 +1564,7 @@ void ModuleInterfaceLoader::collectVisibleTopLevelModuleNames(
void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
const SearchPathOptions &SearchPathOpts, const LangOptions &LangOpts,
const ClangImporterOptions &clangImporterOpts,
const ClangImporterOptions &clangImporterOpts, const CASOptions &casOpts,
bool suppressRemarks, RequireOSSAModules_t RequireOSSAModules,
RequireNoncopyableGenerics_t requireNCGenerics) {
GenericArgs.push_back("-frontend");
@@ -1681,23 +1680,11 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
GenericArgs.push_back(clangImporterOpts.BuildSessionFilePath);
}
if (clangImporterOpts.CASOpts) {
genericSubInvocation.getClangImporterOptions().CASOpts =
clangImporterOpts.CASOpts;
GenericArgs.push_back("-cache-compile-job");
if (!clangImporterOpts.CASOpts->CASPath.empty()) {
GenericArgs.push_back("-cas-path");
GenericArgs.push_back(clangImporterOpts.CASOpts->CASPath);
}
if (!clangImporterOpts.CASOpts->PluginPath.empty()) {
GenericArgs.push_back("-cas-plugin-path");
GenericArgs.push_back(clangImporterOpts.CASOpts->PluginPath);
for (auto Opt : clangImporterOpts.CASOpts->PluginOptions) {
GenericArgs.push_back("-cas-plugin-option");
std::string pair = (llvm::Twine(Opt.first) + "=" + Opt.second).str();
GenericArgs.push_back(ArgSaver.save(pair));
}
}
if (casOpts.EnableCaching) {
genericSubInvocation.getCASOptions().EnableCaching = casOpts.EnableCaching;
genericSubInvocation.getCASOptions().CASOpts = casOpts.CASOpts;
casOpts.enumerateCASConfigurationFlags(
[&](StringRef Arg) { GenericArgs.push_back(ArgSaver.save(Arg)); });
}
if (!clangImporterOpts.UseClangIncludeTree) {
@@ -1733,7 +1720,7 @@ bool InterfaceSubContextDelegateImpl::extractSwiftInterfaceVersionAndArgs(
InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
SourceManager &SM, DiagnosticEngine *Diags,
const SearchPathOptions &searchPathOpts, const LangOptions &langOpts,
const ClangImporterOptions &clangImporterOpts,
const ClangImporterOptions &clangImporterOpts, const CASOptions &casOpts,
ModuleInterfaceLoaderOptions LoaderOpts, bool buildModuleCacheDirIfAbsent,
StringRef moduleCachePath, StringRef prebuiltCachePath,
StringRef backupModuleInterfaceDir,
@@ -1743,7 +1730,7 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
: SM(SM), Diags(Diags), ArgSaver(Allocator) {
genericSubInvocation.setMainExecutablePath(LoaderOpts.mainExecutablePath);
inheritOptionsForBuildingInterface(searchPathOpts, langOpts,
clangImporterOpts,
clangImporterOpts, casOpts,
Diags->getSuppressRemarks(),
requireOSSAModules,
requireNCGenerics);
@@ -1800,7 +1787,6 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
// required by sourcekitd.
subClangImporterOpts.DetailedPreprocessingRecord =
clangImporterOpts.DetailedPreprocessingRecord;
subClangImporterOpts.CASOpts = clangImporterOpts.CASOpts;
std::vector<std::string> inheritedParentContextClangArgs;
if (LoaderOpts.requestedAction ==