diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2024-01-24 19:17:23 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-19 21:24:44 +0000 |
| commit | ab50317e96e57dee5b3ff4ad3f16f205b2a3359e (patch) | |
| tree | 4b1f388eb6a07e574417aaacecd3ec4a83550718 /contrib/llvm-project/llvm/lib/ExecutionEngine/Orc | |
| parent | 412542983a5ba62902141a8a7e155cceb9196a66 (diff) | |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/ExecutionEngine/Orc')
3 files changed, 48 insertions, 20 deletions
diff --git a/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp index e259c393d07e..833dcb9d5bf2 100644 --- a/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp +++ b/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp @@ -734,6 +734,12 @@ Error LLJITBuilderState::prepareForConstruction() { case Triple::aarch64: UseJITLink = !TT.isOSBinFormatCOFF(); break; + case Triple::arm: + case Triple::armeb: + case Triple::thumb: + case Triple::thumbeb: + UseJITLink = TT.isOSBinFormatELF(); + break; case Triple::x86_64: UseJITLink = !TT.isOSBinFormatCOFF(); break; diff --git a/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp b/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp index 6c17f14aa4c7..377a31e63ec1 100644 --- a/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp +++ b/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp @@ -255,12 +255,11 @@ struct ObjCImageInfoFlags { namespace llvm { namespace orc { -Expected<std::unique_ptr<MachOPlatform>> -MachOPlatform::Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, - JITDylib &PlatformJD, - std::unique_ptr<DefinitionGenerator> OrcRuntime, - MachOHeaderMUBuilder BuildMachOHeaderMU, - std::optional<SymbolAliasMap> RuntimeAliases) { +Expected<std::unique_ptr<MachOPlatform>> MachOPlatform::Create( + ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, + JITDylib &PlatformJD, std::unique_ptr<DefinitionGenerator> OrcRuntime, + HeaderOptions PlatformJDOpts, MachOHeaderMUBuilder BuildMachOHeaderMU, + std::optional<SymbolAliasMap> RuntimeAliases) { // If the target is not supported then bail out immediately. if (!supportedTarget(ES.getTargetTriple())) @@ -290,9 +289,9 @@ MachOPlatform::Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, // Create the instance. Error Err = Error::success(); - auto P = std::unique_ptr<MachOPlatform>( - new MachOPlatform(ES, ObjLinkingLayer, PlatformJD, std::move(OrcRuntime), - std::move(BuildMachOHeaderMU), Err)); + auto P = std::unique_ptr<MachOPlatform>(new MachOPlatform( + ES, ObjLinkingLayer, PlatformJD, std::move(OrcRuntime), + std::move(PlatformJDOpts), std::move(BuildMachOHeaderMU), Err)); if (Err) return std::move(Err); return std::move(P); @@ -301,6 +300,7 @@ MachOPlatform::Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, Expected<std::unique_ptr<MachOPlatform>> MachOPlatform::Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD, const char *OrcRuntimePath, + HeaderOptions PlatformJDOpts, MachOHeaderMUBuilder BuildMachOHeaderMU, std::optional<SymbolAliasMap> RuntimeAliases) { @@ -312,11 +312,16 @@ MachOPlatform::Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, return Create(ES, ObjLinkingLayer, PlatformJD, std::move(*OrcRuntimeArchiveGenerator), - std::move(BuildMachOHeaderMU), std::move(RuntimeAliases)); + std::move(PlatformJDOpts), std::move(BuildMachOHeaderMU), + std::move(RuntimeAliases)); } Error MachOPlatform::setupJITDylib(JITDylib &JD) { - if (auto Err = JD.define(BuildMachOHeaderMU(*this))) + return setupJITDylib(JD, /*Opts=*/{}); +} + +Error MachOPlatform::setupJITDylib(JITDylib &JD, HeaderOptions Opts) { + if (auto Err = JD.define(BuildMachOHeaderMU(*this, std::move(Opts)))) return Err; return ES.lookup({&JD}, MachOHeaderStartSymbol).takeError(); @@ -432,7 +437,8 @@ MachOPlatform::MachOPlatform( ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD, std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator, - MachOHeaderMUBuilder BuildMachOHeaderMU, Error &Err) + HeaderOptions PlatformJDOpts, MachOHeaderMUBuilder BuildMachOHeaderMU, + Error &Err) : ES(ES), PlatformJD(PlatformJD), ObjLinkingLayer(ObjLinkingLayer), BuildMachOHeaderMU(std::move(BuildMachOHeaderMU)) { ErrorAsOutParameter _(&Err); @@ -497,7 +503,8 @@ MachOPlatform::MachOPlatform( // the support methods callable. The bootstrap is now complete. // Step (1) Add header materialization unit and request. - if ((Err = PlatformJD.define(this->BuildMachOHeaderMU(*this)))) + if ((Err = PlatformJD.define( + this->BuildMachOHeaderMU(*this, std::move(PlatformJDOpts))))) return; if ((Err = ES.lookup(&PlatformJD, MachOHeaderStartSymbol).takeError())) return; @@ -1669,9 +1676,10 @@ Error MachOPlatform::MachOPlatformPlugin::addSymbolTableRegistration( } template <typename MachOTraits> -jitlink::Block &createTrivialHeaderBlock(MachOPlatform &MOP, - jitlink::LinkGraph &G, - jitlink::Section &HeaderSection) { +jitlink::Block &createHeaderBlock(MachOPlatform &MOP, + const MachOPlatform::HeaderOptions &Opts, + JITDylib &JD, jitlink::LinkGraph &G, + jitlink::Section &HeaderSection) { auto HdrInfo = getMachOHeaderInfoFromTriple(MOP.getExecutionSession().getTargetTriple()); MachOBuilder<MachOTraits> B(HdrInfo.PageSize); @@ -1680,6 +1688,19 @@ jitlink::Block &createTrivialHeaderBlock(MachOPlatform &MOP, B.Header.cputype = HdrInfo.CPUType; B.Header.cpusubtype = HdrInfo.CPUSubType; + if (Opts.IDDylib) + B.template addLoadCommand<MachO::LC_ID_DYLIB>( + Opts.IDDylib->Name, Opts.IDDylib->Timestamp, + Opts.IDDylib->CurrentVersion, Opts.IDDylib->CompatibilityVersion); + else + B.template addLoadCommand<MachO::LC_ID_DYLIB>(JD.getName(), 0, 0, 0); + + for (auto &D : Opts.LoadDylibs) + B.template addLoadCommand<MachO::LC_LOAD_DYLIB>( + D.Name, D.Timestamp, D.CurrentVersion, D.CompatibilityVersion); + for (auto &P : Opts.RPaths) + B.template addLoadCommand<MachO::LC_RPATH>(P); + auto HeaderContent = G.allocateBuffer(B.layout()); B.write(HeaderContent); @@ -1688,10 +1709,11 @@ jitlink::Block &createTrivialHeaderBlock(MachOPlatform &MOP, } SimpleMachOHeaderMU::SimpleMachOHeaderMU(MachOPlatform &MOP, - SymbolStringPtr HeaderStartSymbol) + SymbolStringPtr HeaderStartSymbol, + MachOPlatform::HeaderOptions Opts) : MaterializationUnit( createHeaderInterface(MOP, std::move(HeaderStartSymbol))), - MOP(MOP) {} + MOP(MOP), Opts(std::move(Opts)) {} void SimpleMachOHeaderMU::materialize( std::unique_ptr<MaterializationResponsibility> R) { @@ -1725,7 +1747,7 @@ SimpleMachOHeaderMU::createHeaderBlock(JITDylib &JD, jitlink::LinkGraph &G, switch (MOP.getExecutionSession().getTargetTriple().getArch()) { case Triple::aarch64: case Triple::x86_64: - return createTrivialHeaderBlock<MachO64LE>(MOP, G, HeaderSection); + return ::createHeaderBlock<MachO64LE>(MOP, Opts, JD, G, HeaderSection); default: llvm_unreachable("Unsupported architecture"); } diff --git a/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp b/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp index 5e0623102d33..f7852b0ca62e 100644 --- a/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp +++ b/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp @@ -323,7 +323,7 @@ static Error InitDebuggingDir(PerfState &State) { return make_error<StringError>(std::move(ErrStr), inconvertibleErrorCode()); } - State.JitPath = std::string(UniqueDebugDir.str()); + State.JitPath = std::string(UniqueDebugDir); return Error::success(); } |
