Skip to content

Make -Rmodule-loading dump the module search paths #70275

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
Dec 7, 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
2 changes: 2 additions & 0 deletions include/swift/AST/SearchPathOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,8 @@ class SearchPathOptions {
llvm::hash_code getModuleScanningHashComponents() const {
return getPCHHashComponents();
}

void dump(bool isDarwin) const;
};
}

Expand Down
29 changes: 29 additions & 0 deletions lib/AST/SearchPathOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,35 @@ void ModuleSearchPathLookup::rebuildLookupTable(const SearchPathOptions *Opts,
State.IsPopulated = true;
}

void SearchPathOptions::dump(bool isDarwin) const {
llvm::errs() << "Module import search paths (non system):\n";
for (auto Entry : llvm::enumerate(getImportSearchPaths())) {
llvm::errs() << " [" << Entry.index() << "] " << Entry.value() << "\n";
}

llvm::errs() << "Framework search paths:\n";
for (auto Entry : llvm::enumerate(getFrameworkSearchPaths())) {
llvm::errs() << " [" << Entry.index() << "] "
<< (Entry.value().IsSystem ? "(system) " : "(non-system) ")
<< Entry.value().Path << "\n";
}

if (isDarwin) {
llvm::errs() << "Darwin implicit framework search paths:\n";
for (auto Entry :
llvm::enumerate(getDarwinImplicitFrameworkSearchPaths())) {
llvm::errs() << " [" << Entry.index() << "] " << Entry.value() << "\n";
}
}

llvm::errs() << "Runtime library import search paths:\n";
for (auto Entry : llvm::enumerate(getRuntimeLibraryImportPaths())) {
llvm::errs() << " [" << Entry.index() << "] " << Entry.value() << "\n";
}

llvm::errs() << "(End of search path lists.)\n";
}

SmallVector<const ModuleSearchPath *, 4>
ModuleSearchPathLookup::searchPathsContainingFile(
const SearchPathOptions *Opts, llvm::ArrayRef<std::string> Filenames,
Expand Down
6 changes: 6 additions & 0 deletions lib/Frontend/Frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,12 @@ bool CompilerInstance::setup(const CompilerInvocation &Invoke,
// DiagConsumers are added.
setupCachingDiagnosticsProcessorIfNeeded();

// Dump module search paths if -Rmodule-loading is on.
const auto &LangOpts = Invocation.getLangOptions();
if (LangOpts.EnableModuleLoadingRemarks) {
Invocation.getSearchPathOptions().dump(LangOpts.Target.isOSDarwin());
}

// If we expect an implicit stdlib import, load in the standard library. If we
// either fail to find it or encounter an error while loading it, bail early. Continuing will at best
// trigger a bunch of other errors due to the stdlib being missing, or at
Expand Down