@@ -304,26 +304,26 @@ MacroDefinition MacroDefinitionRequest::evaluate(
304304}
305305
306306// / Load a plugin library based on a module name.
307- static void *loadPluginByName (StringRef searchPath, StringRef moduleName, llvm::vfs::FileSystem &fs) {
307+ static void *loadPluginByName (StringRef searchPath,
308+ StringRef moduleName,
309+ llvm::vfs::FileSystem &fs,
310+ PluginRegistry *registry) {
308311 SmallString<128 > fullPath (searchPath);
309312 llvm::sys::path::append (fullPath, " lib" + moduleName + LTDL_SHLIB_EXT);
310313 if (fs.getRealPath (fullPath, fullPath))
311314 return nullptr ;
312-
313- #if defined(_WIN32)
314- return LoadLibraryA (fullPath.c_str ());
315- #else
316- return dlopen (fullPath.c_str (), RTLD_LAZY);
317- #endif
315+ auto loadResult = registry->loadLibraryPlugin (fullPath);
316+ return loadResult ? *loadResult : nullptr ;
318317}
319318
320319void *CompilerPluginLoadRequest::evaluate (
321320 Evaluator &evaluator, ASTContext *ctx, Identifier moduleName
322321) const {
323322 auto fs = ctx->SourceMgr .getFileSystem ();
324323 auto &searchPathOpts = ctx->SearchPathOpts ;
324+ auto *registry = ctx->getPluginRegistry ();
325325 for (const auto &path : searchPathOpts.PluginSearchPaths ) {
326- if (auto found = loadPluginByName (path, moduleName.str (), *fs))
326+ if (auto found = loadPluginByName (path, moduleName.str (), *fs, registry ))
327327 return found;
328328 }
329329
0 commit comments