Skip to content

[Explicit Module Builds] Do not attempt to re-load module dependency from interface for index. #68152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions include/swift/Index/IndexRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool indexAndRecord(SourceFile *primarySourceFile, StringRef indexUnitToken,
StringRef indexStorePath, bool indexClangModules,
bool indexSystemModules, bool skipStdlib,
bool includeLocals, bool isDebugCompilation,
StringRef targetTriple,
bool isExplicitModuleBuild, StringRef targetTriple,
const DependencyTracker &dependencyTracker,
const PathRemapper &pathRemapper);

Expand Down Expand Up @@ -99,7 +99,8 @@ bool indexAndRecord(ModuleDecl *module, ArrayRef<std::string> indexUnitTokens,
StringRef moduleUnitToken, StringRef indexStorePath,
bool indexClangModules, bool indexSystemModules,
bool skipStdlib, bool includeLocals,
bool isDebugCompilation, StringRef targetTriple,
bool isDebugCompilation, bool isExplicitModuleBuild,
StringRef targetTriple,
const DependencyTracker &dependencyTracker,
const PathRemapper &pathRemapper);
// FIXME: indexUnitTokens could be StringRef, but that creates an impedance
Expand Down
2 changes: 2 additions & 0 deletions lib/FrontendTool/FrontendTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,7 @@ static void emitIndexDataForSourceFile(SourceFile *PrimarySourceFile,
opts.IndexIgnoreStdlib,
opts.IndexIncludeLocals,
isDebugCompilation,
opts.DisableImplicitModules,
Invocation.getTargetTriple(),
*Instance.getDependencyTracker(),
Invocation.getIRGenOptions().FilePrefixMap);
Expand All @@ -1929,6 +1930,7 @@ static void emitIndexDataForSourceFile(SourceFile *PrimarySourceFile,
opts.IndexIgnoreStdlib,
opts.IndexIncludeLocals,
isDebugCompilation,
opts.DisableImplicitModules,
Invocation.getTargetTriple(),
*Instance.getDependencyTracker(),
Invocation.getIRGenOptions().FilePrefixMap);
Expand Down
29 changes: 20 additions & 9 deletions lib/Index/IndexRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ emitDataForSwiftSerializedModule(ModuleDecl *module,
bool indexSystemModules,
bool skipStdlib,
bool includeLocals,
bool explicitModulebuild,
StringRef targetTriple,
const clang::CompilerInstance &clangCI,
DiagnosticEngine &diags,
Expand Down Expand Up @@ -598,6 +599,7 @@ static void addModuleDependencies(ArrayRef<ImportedModule> imports,
bool indexSystemModules,
bool skipStdlib,
bool includeLocals,
bool explicitModuleBuild,
StringRef targetTriple,
const clang::CompilerInstance &clangCI,
DiagnosticEngine &diags,
Expand Down Expand Up @@ -674,7 +676,9 @@ static void addModuleDependencies(ArrayRef<ImportedModule> imports,
emitDataForSwiftSerializedModule(mod, indexStorePath,
indexClangModules,
indexSystemModules, skipStdlib,
includeLocals, targetTriple,
includeLocals,
explicitModuleBuild,
targetTriple,
clangCI, diags,
unitWriter,
pathRemapper,
Expand Down Expand Up @@ -719,6 +723,7 @@ emitDataForSwiftSerializedModule(ModuleDecl *module,
bool indexSystemModules,
bool skipStdlib,
bool includeLocals,
bool explicitModuleBuild,
StringRef targetTriple,
const clang::CompilerInstance &clangCI,
DiagnosticEngine &diags,
Expand Down Expand Up @@ -747,7 +752,9 @@ emitDataForSwiftSerializedModule(ModuleDecl *module,
// Reload resilient modules from swiftinterface to avoid indexing
// internal details.
bool skipIndexingModule = false;
if (module->getResilienceStrategy() == ResilienceStrategy::Resilient &&
// Note, we are unable to reload from interface on an explicit module build
if (!explicitModuleBuild &&
module->getResilienceStrategy() == ResilienceStrategy::Resilient &&
!module->isBuiltFromInterface() &&
!module->isStdlibModule()) {
module->getASTContext().setIgnoreAdjacentModules(true);
Expand Down Expand Up @@ -867,6 +874,7 @@ emitDataForSwiftSerializedModule(ModuleDecl *module,
StringScratchSpace moduleNameScratch;
addModuleDependencies(imports, indexStorePath, indexClangModules,
indexSystemModules, skipStdlib, includeLocals,
explicitModuleBuild,
targetTriple, clangCI, diags, unitWriter,
moduleNameScratch, pathRemapper, initialFile);

Expand All @@ -883,7 +891,7 @@ recordSourceFileUnit(SourceFile *primarySourceFile, StringRef indexUnitToken,
StringRef indexStorePath, bool indexClangModules,
bool indexSystemModules, bool skipStdlib,
bool includeLocals, bool isDebugCompilation,
StringRef targetTriple,
bool isExplicitModuleBuild, StringRef targetTriple,
ArrayRef<const clang::FileEntry *> fileDependencies,
const clang::CompilerInstance &clangCI,
const PathRemapper &pathRemapper,
Expand All @@ -909,8 +917,9 @@ recordSourceFileUnit(SourceFile *primarySourceFile, StringRef indexUnitToken,
StringScratchSpace moduleNameScratch;
addModuleDependencies(imports, indexStorePath, indexClangModules,
indexSystemModules, skipStdlib, includeLocals,
targetTriple, clangCI, diags, unitWriter,
moduleNameScratch, pathRemapper, primarySourceFile);
isExplicitModuleBuild, targetTriple, clangCI, diags,
unitWriter, moduleNameScratch, pathRemapper,
primarySourceFile);

// File dependencies.
for (auto *F : fileDependencies)
Expand Down Expand Up @@ -965,6 +974,7 @@ bool index::indexAndRecord(SourceFile *primarySourceFile,
bool skipStdlib,
bool includeLocals,
bool isDebugCompilation,
bool isExplicitModuleBuild,
StringRef targetTriple,
const DependencyTracker &dependencyTracker,
const PathRemapper &pathRemapper) {
Expand Down Expand Up @@ -994,8 +1004,8 @@ bool index::indexAndRecord(SourceFile *primarySourceFile,
return recordSourceFileUnit(primarySourceFile, indexUnitToken,
indexStorePath, indexClangModules,
indexSystemModules, skipStdlib, includeLocals,
isDebugCompilation, targetTriple,
fileDependencies.getArrayRef(),
isDebugCompilation, isExplicitModuleBuild,
targetTriple, fileDependencies.getArrayRef(),
clangCI, pathRemapper, diags);
}

Expand All @@ -1008,6 +1018,7 @@ bool index::indexAndRecord(ModuleDecl *module,
bool skipStdlib,
bool includeLocals,
bool isDebugCompilation,
bool isExplicitModuleBuild,
StringRef targetTriple,
const DependencyTracker &dependencyTracker,
const PathRemapper &pathRemapper) {
Expand Down Expand Up @@ -1045,8 +1056,8 @@ bool index::indexAndRecord(ModuleDecl *module,
if (recordSourceFileUnit(SF, indexUnitTokens[unitIndex],
indexStorePath, indexClangModules,
indexSystemModules, skipStdlib, includeLocals,
isDebugCompilation, targetTriple,
fileDependencies.getArrayRef(),
isDebugCompilation, isExplicitModuleBuild,
targetTriple, fileDependencies.getArrayRef(),
clangCI, pathRemapper, diags))
return true;
unitIndex += 1;
Expand Down
1 change: 1 addition & 0 deletions tools/SourceKit/lib/SwiftLang/SwiftIndexing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ static void emitIndexDataForSourceFile(SourceFile &PrimarySourceFile,
Opts.IndexIgnoreStdlib,
Opts.IndexIncludeLocals,
isDebugCompilation,
Opts.DisableImplicitModules,
Invocation.getTargetTriple(),
*Instance.getDependencyTracker(),
Invocation.getIRGenOptions().FilePrefixMap);
Expand Down