[Macros] Emit loaded module trace for plugins loaded from search paths

When loading plugins from `-plugin-path`, use the global `PluginRegistry` to keep a record of what's loaded. Emit these dependencies to the loaded module trace.
This commit is contained in:
Richard Wei
2023-03-06 02:15:04 -08:00
parent eb3cbdeb1c
commit c6139f2f78
6 changed files with 29 additions and 17 deletions

View File

@@ -15,6 +15,7 @@
#include "swift/AST/DiagnosticEngine.h"
#include "swift/AST/DiagnosticsFrontend.h"
#include "swift/AST/Module.h"
#include "swift/AST/PluginRegistry.h"
#include "swift/Basic/FileTypes.h"
#include "swift/Basic/JSONSerialization.h"
#include "swift/Frontend/FrontendOptions.h"
@@ -764,6 +765,11 @@ bool swift::emitLoadedModuleTraceIfNeeded(ModuleDecl *mainModule,
std::make_pair(loadedDecl->getModuleFilename(), loadedDecl));
}
// Add compiler plugin libraries as dependencies.
auto *pluginRegistry = ctxt.getPluginRegistry();
for (auto &pluginEntry : pluginRegistry->getLoadedLibraryPlugins())
depTracker->addDependency(pluginEntry.getKey(), /*IsSystem*/ false);
std::vector<SwiftModuleTraceInfo> swiftModules;
computeSwiftModuleTraceInfo(ctxt, abiDependencies, pathToModuleDecl,
*depTracker, opts.PrebuiltModuleCachePath,