[LLJIT] Add convenience methods for loading dylibs and linking static libs.
authorLang Hames <lhames@gmail.com>
Mon, 27 Mar 2023 01:13:15 +0000 (18:13 -0700)
committerLang Hames <lhames@gmail.com>
Mon, 27 Mar 2023 01:20:47 +0000 (18:20 -0700)
commitd02ef707cbdab295aa4b645a068d298bfa85997a
tree93cf80d9dc59aa1060eb5b075c17058662f3dedc
parent6cef325481a8efc039ae9df5630609fd3a84560c
[LLJIT] Add convenience methods for loading dylibs and linking static libs.

LLJIT::loadPlatformDynamicLibrary loads a dynamic library at a given path
(interpreted in the executor process -- the process containing the JIT'd code),
and returns a JITDylib (whose name is the given path) that reflects the symbols
in that library. LLJIT clients wishing to make the given symbols visible to
their JIT'd code can add this JITDylib to the link order of their JITDylib(s)
using JITDylib::addToLinkOrder.

The LLJIT::linkStaticLibraryInto overloads load a static library (or universal
binary) at a given path (interpreted in the controller process -- the process
containing the LLJIT instance) and adds its symbols to the given JITDylib.

The lli tool is updated to use LLJIT::linkStaticLibraryInto to implement the
extra-archive option.

LLJIT::loadPlatformDynamicLibrary is not tested in this patch as we don't have
a good way to produce dylibs in LLVM's regression test suite.
llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
llvm/tools/lli/lli.cpp