From af2b2214b4e2717d2114c0b01e3610e0b64a14be Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Wed, 19 Oct 2022 14:58:57 -0700 Subject: [PATCH] [examples][ORC] Make sure eh-frame registration code is linked into an example. Since aedeb8d5570, which switched to EPC-based eh-frame registration, the eh-frame registration functions need to be forcibly linked into the target process. We need a general solution to this problem, but for now just force it in this example to fix the test failures in https://green.lab.llvm.org/green/job/clang-stage1-RA/31497 rdar://101083784 --- .../LLJITWithThinLTOSummaries/LLJITWithThinLTOSummaries.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/llvm/examples/OrcV2Examples/LLJITWithThinLTOSummaries/LLJITWithThinLTOSummaries.cpp b/llvm/examples/OrcV2Examples/LLJITWithThinLTOSummaries/LLJITWithThinLTOSummaries.cpp index a7cb4fc..32c49f6 100644 --- a/llvm/examples/OrcV2Examples/LLJITWithThinLTOSummaries/LLJITWithThinLTOSummaries.cpp +++ b/llvm/examples/OrcV2Examples/LLJITWithThinLTOSummaries/LLJITWithThinLTOSummaries.cpp @@ -37,6 +37,7 @@ #include "llvm/ExecutionEngine/Orc/LLJIT.h" #include "llvm/ExecutionEngine/Orc/ThreadSafeModule.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/TargetExecutionUtils.h" +#include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h" #include "llvm/IR/GlobalValue.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/ModuleSummaryIndex.h" @@ -172,6 +173,12 @@ Expected loadModule(StringRef Path, return ThreadSafeModule(std::move(*M), std::move(TSCtx)); } +// Make sure the eh-frame registration functions get linked into the binary. +LLVM_ATTRIBUTE_USED void linkComponents() { + errs() << (void *)&llvm_orc_registerEHFrameSectionWrapper + << (void *)&llvm_orc_deregisterEHFrameSectionWrapper; +} + int main(int Argc, char *Argv[]) { InitLLVM X(Argc, Argv); -- 2.7.4