LLVM 20.0.0git
|
Mediates between MachO initialization and ExecutionSession state. More...
#include "llvm/ExecutionEngine/Orc/MachOPlatform.h"
Classes | |
struct | HeaderOptions |
Configuration for the mach-o header of a JITDylib. More... | |
struct | MachOJITDylibDepInfo |
Public Types | |
enum class | MachOExecutorSymbolFlags : uint8_t { None = 0 , Weak = 1U << 0 , Callable = 1U << 1 } |
using | MachOJITDylibDepInfoMap = std::vector< std::pair< ExecutorAddr, MachOJITDylibDepInfo > > |
using | MachOHeaderMUBuilder = unique_function< std::unique_ptr< MaterializationUnit >(MachOPlatform &MOP, HeaderOptions Opts)> |
Used by setupJITDylib to create MachO header MaterializationUnits for JITDylibs. | |
Public Member Functions | |
ExecutionSession & | getExecutionSession () const |
ObjectLinkingLayer & | getObjectLinkingLayer () const |
NonOwningSymbolStringPtr | getMachOHeaderStartSymbol () const |
Error | setupJITDylib (JITDylib &JD) override |
This method will be called outside the session lock each time a JITDylib is created (unless it is created with EmptyJITDylib set) to allow the Platform to install any JITDylib specific standard symbols (e.g __dso_handle). | |
Error | setupJITDylib (JITDylib &JD, HeaderOptions Opts) |
Install any platform-specific symbols (e.g. | |
Error | teardownJITDylib (JITDylib &JD) override |
This method will be called outside the session lock each time a JITDylib is removed to allow the Platform to remove any JITDylib-specific data. | |
Error | notifyAdding (ResourceTracker &RT, const MaterializationUnit &MU) override |
This method will be called under the ExecutionSession lock each time a MaterializationUnit is added to a JITDylib. | |
Error | notifyRemoving (ResourceTracker &RT) override |
This method will be called under the ExecutionSession lock when a ResourceTracker is removed. | |
Public Member Functions inherited from llvm::orc::Platform | |
virtual | ~Platform () |
virtual Error | setupJITDylib (JITDylib &JD)=0 |
This method will be called outside the session lock each time a JITDylib is created (unless it is created with EmptyJITDylib set) to allow the Platform to install any JITDylib specific standard symbols (e.g __dso_handle). | |
virtual Error | teardownJITDylib (JITDylib &JD)=0 |
This method will be called outside the session lock each time a JITDylib is removed to allow the Platform to remove any JITDylib-specific data. | |
virtual Error | notifyAdding (ResourceTracker &RT, const MaterializationUnit &MU)=0 |
This method will be called under the ExecutionSession lock each time a MaterializationUnit is added to a JITDylib. | |
virtual Error | notifyRemoving (ResourceTracker &RT)=0 |
This method will be called under the ExecutionSession lock when a ResourceTracker is removed. | |
Static Public Member Functions | |
static std::unique_ptr< MaterializationUnit > | buildSimpleMachOHeaderMU (MachOPlatform &MOP, HeaderOptions Opts) |
Simple MachO header graph builder. | |
static Expected< std::unique_ptr< MachOPlatform > > | Create (ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD, std::unique_ptr< DefinitionGenerator > OrcRuntime, HeaderOptions PlatformJDOpts={}, MachOHeaderMUBuilder BuildMachOHeaderMU=buildSimpleMachOHeaderMU, std::optional< SymbolAliasMap > RuntimeAliases=std::nullopt) |
Try to create a MachOPlatform instance, adding the ORC runtime to the given JITDylib. | |
static Expected< std::unique_ptr< MachOPlatform > > | Create (ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD, const char *OrcRuntimePath, HeaderOptions PlatformJDOpts={}, MachOHeaderMUBuilder BuildMachOHeaderMU=buildSimpleMachOHeaderMU, std::optional< SymbolAliasMap > RuntimeAliases=std::nullopt) |
Construct using a path to the ORC runtime. | |
static SymbolAliasMap | standardPlatformAliases (ExecutionSession &ES) |
Returns an AliasMap containing the default aliases for the MachOPlatform. | |
static ArrayRef< std::pair< const char *, const char * > > | requiredCXXAliases () |
Returns the array of required CXX aliases. | |
static ArrayRef< std::pair< const char *, const char * > > | standardRuntimeUtilityAliases () |
Returns the array of standard runtime utility aliases for MachO. | |
Static Public Member Functions inherited from llvm::orc::Platform | |
static Expected< DenseMap< JITDylib *, SymbolMap > > | lookupInitSymbols (ExecutionSession &ES, const DenseMap< JITDylib *, SymbolLookupSet > &InitSyms) |
A utility function for looking up initializer symbols. | |
static void | lookupInitSymbolsAsync (unique_function< void(Error)> OnComplete, ExecutionSession &ES, const DenseMap< JITDylib *, SymbolLookupSet > &InitSyms) |
Performs an async lookup for the given symbols in each of the given JITDylibs, calling the given handler once all lookups have completed. | |
Mediates between MachO initialization and ExecutionSession state.
Definition at line 30 of file MachOPlatform.h.
using llvm::orc::MachOPlatform::MachOHeaderMUBuilder = unique_function<std::unique_ptr<MaterializationUnit>(MachOPlatform &MOP, HeaderOptions Opts)> |
Used by setupJITDylib to create MachO header MaterializationUnits for JITDylibs.
Definition at line 89 of file MachOPlatform.h.
using llvm::orc::MachOPlatform::MachOJITDylibDepInfoMap = std::vector<std::pair<ExecutorAddr, MachOJITDylibDepInfo> > |
Definition at line 39 of file MachOPlatform.h.
|
strong |
Enumerator | |
---|---|
None | |
Weak | |
Callable |
Definition at line 43 of file MachOPlatform.h.
|
inlinestatic |
Simple MachO header graph builder.
Definition at line 416 of file MachOPlatform.h.
|
static |
Construct using a path to the ORC runtime.
Definition at line 337 of file MachOPlatform.cpp.
References Create(), and llvm::orc::StaticLibraryDefinitionGenerator::Load().
|
static |
Try to create a MachOPlatform instance, adding the ORC runtime to the given JITDylib.
The ORC runtime requires access to a number of symbols in libc++, and requires access to symbols in libobjc, and libswiftCore to support Objective-C and Swift code. It is up to the caller to ensure that the required symbols can be referenced by code added to PlatformJD. The standard way to achieve this is to first attach dynamic library search generators for either the given process, or for the specific required libraries, to PlatformJD, then to create the platform instance:
Alternatively, these symbols could be added to another JITDylib that PlatformJD links against.
Clients are also responsible for ensuring that any JIT'd code that depends on runtime functions (including any code using TLV or static destructors) can reference the runtime symbols. This is usually achieved by linking any JITDylibs containing regular code against PlatformJD.
By default, MachOPlatform will add the set of aliases returned by the standardPlatformAliases function. This includes both required aliases (e.g. __cxa_atexit -> __orc_rt_macho_cxa_atexit for static destructor support), and optional aliases that provide JIT versions of common functions (e.g. dlopen -> __orc_rt_macho_jit_dlopen). Clients can override these defaults by passing a non-None value for the RuntimeAliases function, in which case the client is responsible for setting up all aliases (including the required ones).
Definition at line 294 of file MachOPlatform.cpp.
References llvm::orc::absoluteSymbols(), llvm::orc::JITDylib::define(), llvm::JITSymbolFlags::Exported, llvm::orc::ExecutionSession::getExecutorProcessControl(), llvm::orc::ExecutionSession::getTargetTriple(), llvm::inconvertibleErrorCode(), llvm::orc::ExecutionSession::intern(), P, standardPlatformAliases(), llvm::Triple::str(), llvm::Error::success(), and llvm::orc::symbolAliases().
Referenced by Create(), and llvm::orc::ExecutorNativePlatform::operator()().
|
inline |
Definition at line 150 of file MachOPlatform.h.
Referenced by llvm::orc::SimpleMachOHeaderMU::createHeaderBlock(), and llvm::orc::createHeaderBlock().
|
inline |
Definition at line 153 of file MachOPlatform.h.
|
inline |
Definition at line 151 of file MachOPlatform.h.
Referenced by llvm::orc::SimpleMachOHeaderMU::materialize().
|
overridevirtual |
This method will be called under the ExecutionSession lock each time a MaterializationUnit is added to a JITDylib.
Implements llvm::orc::Platform.
Definition at line 379 of file MachOPlatform.cpp.
References llvm::dbgs(), llvm::orc::MaterializationUnit::getInitializerSymbol(), llvm::orc::ResourceTracker::getJITDylib(), llvm::orc::MaterializationUnit::getName(), LLVM_DEBUG, llvm::Error::success(), and llvm::orc::WeaklyReferencedSymbol.
|
overridevirtual |
This method will be called under the ExecutionSession lock when a ResourceTracker is removed.
Implements llvm::orc::Platform.
Definition at line 395 of file MachOPlatform.cpp.
References llvm_unreachable.
|
static |
Returns the array of required CXX aliases.
Definition at line 417 of file MachOPlatform.cpp.
Referenced by standardPlatformAliases().
This method will be called outside the session lock each time a JITDylib is created (unless it is created with EmptyJITDylib set) to allow the Platform to install any JITDylib specific standard symbols (e.g __dso_handle).
Implements llvm::orc::Platform.
Definition at line 355 of file MachOPlatform.cpp.
References setupJITDylib().
Referenced by setupJITDylib().
Error llvm::orc::MachOPlatform::setupJITDylib | ( | JITDylib & | JD, |
HeaderOptions | Opts | ||
) |
Install any platform-specific symbols (e.g.
__dso_handle
) and create a mach-o header based on the given options.
Definition at line 359 of file MachOPlatform.cpp.
References llvm::orc::JITDylib::define().
|
static |
Returns an AliasMap containing the default aliases for the MachOPlatform.
This can be modified by clients when constructing the platform to add or remove aliases.
Definition at line 409 of file MachOPlatform.cpp.
References llvm::orc::addAliases(), requiredCXXAliases(), and standardRuntimeUtilityAliases().
Referenced by Create().
|
static |
Returns the array of standard runtime utility aliases for MachO.
Definition at line 425 of file MachOPlatform.cpp.
Referenced by standardPlatformAliases().
This method will be called outside the session lock each time a JITDylib is removed to allow the Platform to remove any JITDylib-specific data.
Implements llvm::orc::Platform.
Definition at line 366 of file MachOPlatform.cpp.
References assert(), I, and llvm::Error::success().