return ES->getJITDylibByName(Name);
}
+ /// Load a (real) dynamic library and make its symbols available through a
+ /// new JITDylib with the same name.
+ ///
+ /// If the given *executor* path contains a valid platform dynamic library
+ /// then that library will be loaded, and a new bare JITDylib whose name is
+ /// the given path will be created to make the library's symbols available to
+ /// JIT'd code.
+ Expected<JITDylib &> loadPlatformDynamicLibrary(const char *Path);
+
+ /// Link a static library into the given JITDylib.
+ ///
+ /// If the given MemoryBuffer contains a valid static archive (or a universal
+ /// binary with an archive slice that fits the LLJIT instance's platform /
+ /// architecture) then it will be added to the given JITDylib using a
+ /// StaticLibraryDefinitionGenerator.
+ Error linkStaticLibraryInto(JITDylib &JD,
+ std::unique_ptr<MemoryBuffer> LibBuffer);
+
+ /// Link a static library into the given JITDylib.
+ ///
+ /// If the given *host* path contains a valid static archive (or a universal
+ /// binary with an archive slice that fits the LLJIT instance's platform /
+ /// architecture) then it will be added to the given JITDylib using a
+ /// StaticLibraryDefinitionGenerator.
+ Error linkStaticLibraryInto(JITDylib &JD, const char *Path);
+
/// Create a new JITDylib with the given name and return a reference to it.
///
/// JITDylib names must be unique. If the given name is derived from user
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
#include "llvm/ExecutionEngine/JITLink/EHFrameSupport.h"
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
+#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"
#include "llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/MachOPlatform.h"
ES->reportError(std::move(Err));
}
+Expected<JITDylib &> LLJIT::loadPlatformDynamicLibrary(const char *Path) {
+ auto G = EPCDynamicLibrarySearchGenerator::Load(*ES, Path);
+ if (!G)
+ return G.takeError();
+
+ if (ES->getJITDylibByName(Path))
+ return make_error<StringError>(
+ Twine("LLJIT ExecutionSession already contains a JITDylib named \"") +
+ Path + "\"",
+ inconvertibleErrorCode());
+
+ auto &JD = ES->createBareJITDylib(Path);
+ JD.addGenerator(std::move(*G));
+ return JD;
+}
+
+Error LLJIT::linkStaticLibraryInto(JITDylib &JD,
+ std::unique_ptr<MemoryBuffer> LibBuffer) {
+ auto G = StaticLibraryDefinitionGenerator::Create(*ObjLinkingLayer,
+ std::move(LibBuffer));
+ if (!G)
+ return G.takeError();
+
+ JD.addGenerator(std::move(*G));
+
+ return Error::success();
+}
+
+Error LLJIT::linkStaticLibraryInto(JITDylib &JD, const char *Path) {
+ auto G = StaticLibraryDefinitionGenerator::Load(*ObjLinkingLayer, Path);
+ if (!G)
+ return G.takeError();
+
+ JD.addGenerator(std::move(*G));
+
+ return Error::success();
+}
+
Error LLJIT::addIRModule(ResourceTrackerSP RT, ThreadSafeModule TSM) {
assert(TSM && "Can not add null module");
assert(EAIdx != 0 && "ExtraArchive should have index > 0");
auto JDItr = std::prev(IdxToDylib.lower_bound(EAIdx));
auto &JD = *JDItr->second;
- JD.addGenerator(ExitOnErr(orc::StaticLibraryDefinitionGenerator::Load(
- J->getObjLinkingLayer(), EAItr->c_str())));
+ ExitOnErr(J->linkStaticLibraryInto(JD, EAItr->c_str()));
}
}