[PATCH] D134763: Add functionality to load dynamic libraries temporarily

Michael Holman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 27 14:12:49 PDT 2022


Holman created this revision.
Holman added reviewers: nhaehnle, v.g.vassilev.
Herald added subscribers: bzcheeseman, rriddle, hiraditya.
Herald added a project: All.
Holman requested review of this revision.
Herald added subscribers: llvm-commits, stephenneuendorffer.
Herald added a project: LLVM.

Previously, it was possible to load dynamic libraries which would be unloaded on llvm_shutdown(), but recently ManagedStatic removal changed this so that loaded libraries really can't ever be unloaded. This functionality was very useful, and so to add it back in a more explicit way, I've added new getLibrary() and closeLibrary() methods to allow callers to use the very convenient platform independent abstraction that LLVM has for dynamic libraries.

As a specific use case, the onnx-mlir project was using this functionality with an API that allows instancing LLVM so you can compile a shared library, and then load that library, and eventually close the instance (and library) and compile something else. This change to llvm_shutdown causes libraries to leak and also locks the libraries for the entire duration of the program which prevents reusing library names.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134763

Files:
  llvm/include/llvm/Support/DynamicLibrary.h
  llvm/lib/Support/DynamicLibrary.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134763.463331.patch
Type: text/x-patch
Size: 14427 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220927/c9585143/attachment-0001.bin>


More information about the llvm-commits mailing list