Skip to content

Commit d7e22f4

Browse files
authored
Merge pull request #70275 from kubamracek/dump-search-paths
Make -Rmodule-loading dump the module search paths
2 parents f5eb65c + 6e54a71 commit d7e22f4

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

include/swift/AST/SearchPathOptions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,8 @@ class SearchPathOptions {
555555
llvm::hash_code getModuleScanningHashComponents() const {
556556
return getPCHHashComponents();
557557
}
558+
559+
void dump(bool isDarwin) const;
558560
};
559561
}
560562

lib/AST/SearchPathOptions.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,35 @@ void ModuleSearchPathLookup::rebuildLookupTable(const SearchPathOptions *Opts,
7979
State.IsPopulated = true;
8080
}
8181

82+
void SearchPathOptions::dump(bool isDarwin) const {
83+
llvm::errs() << "Module import search paths (non system):\n";
84+
for (auto Entry : llvm::enumerate(getImportSearchPaths())) {
85+
llvm::errs() << " [" << Entry.index() << "] " << Entry.value() << "\n";
86+
}
87+
88+
llvm::errs() << "Framework search paths:\n";
89+
for (auto Entry : llvm::enumerate(getFrameworkSearchPaths())) {
90+
llvm::errs() << " [" << Entry.index() << "] "
91+
<< (Entry.value().IsSystem ? "(system) " : "(non-system) ")
92+
<< Entry.value().Path << "\n";
93+
}
94+
95+
if (isDarwin) {
96+
llvm::errs() << "Darwin implicit framework search paths:\n";
97+
for (auto Entry :
98+
llvm::enumerate(getDarwinImplicitFrameworkSearchPaths())) {
99+
llvm::errs() << " [" << Entry.index() << "] " << Entry.value() << "\n";
100+
}
101+
}
102+
103+
llvm::errs() << "Runtime library import search paths:\n";
104+
for (auto Entry : llvm::enumerate(getRuntimeLibraryImportPaths())) {
105+
llvm::errs() << " [" << Entry.index() << "] " << Entry.value() << "\n";
106+
}
107+
108+
llvm::errs() << "(End of search path lists.)\n";
109+
}
110+
82111
SmallVector<const ModuleSearchPath *, 4>
83112
ModuleSearchPathLookup::searchPathsContainingFile(
84113
const SearchPathOptions *Opts, llvm::ArrayRef<std::string> Filenames,

lib/Frontend/Frontend.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,12 @@ bool CompilerInstance::setup(const CompilerInvocation &Invoke,
538538
// DiagConsumers are added.
539539
setupCachingDiagnosticsProcessorIfNeeded();
540540

541+
// Dump module search paths if -Rmodule-loading is on.
542+
const auto &LangOpts = Invocation.getLangOptions();
543+
if (LangOpts.EnableModuleLoadingRemarks) {
544+
Invocation.getSearchPathOptions().dump(LangOpts.Target.isOSDarwin());
545+
}
546+
541547
// If we expect an implicit stdlib import, load in the standard library. If we
542548
// either fail to find it or encounter an error while loading it, bail early. Continuing will at best
543549
// trigger a bunch of other errors due to the stdlib being missing, or at

0 commit comments

Comments
 (0)