[all-commits] [llvm/llvm-project] 513f89: Add functionality to load dynamic libraries tempor...

Michael Holman via All-commits all-commits at lists.llvm.org
Mon Oct 3 16:21:07 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 513f89dc8d894df7d72460943012c3488f2aeec7
      https://github.com/llvm/llvm-project/commit/513f89dc8d894df7d72460943012c3488f2aeec7
  Author: Michael Holman <michael.holman at microsoft.com>
  Date:   2022-10-03 (Mon, 03 Oct 2022)

  Changed paths:
    M llvm/include/llvm/Support/DynamicLibrary.h
    M llvm/lib/Support/DynamicLibrary.cpp

  Log Message:
  -----------
  Add functionality to load dynamic libraries temporarily

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.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D134763




More information about the All-commits mailing list