|
|
055636 |
From 3bde9d98aa48b9c7eba9fe559dee6c66d8b57634 Mon Sep 17 00:00:00 2001
|
|
|
055636 |
From: Khem Raj <raj.khem@gmail.com>
|
|
|
055636 |
Date: Sat, 4 Sep 2021 17:28:17 -0700
|
|
|
055636 |
Subject: [PATCH] orc: Fix build with clang >= 13
|
|
|
055636 |
|
|
|
055636 |
Fixes errors like
|
|
|
055636 |
src/ast/bpforc/bpforcv2.cpp:3:9: error: constructor for 'bpftrace::BpfOrc' must explicitly initialize the member 'ES' which does not have a default constructor
|
|
|
055636 |
BpfOrc::BpfOrc(TargetMachine *TM, DataLayout DL)
|
|
|
055636 |
^
|
|
|
055636 |
|
|
|
055636 |
Fixes https://github.com/iovisor/bpftrace/issues/1963
|
|
|
055636 |
|
|
|
055636 |
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
|
|
055636 |
---
|
|
|
055636 |
src/bpforc.h | 23 ++++++++++++++++++++++-
|
|
|
055636 |
src/bpforcv2.cpp | 23 +++++++++++++++--------
|
|
|
055636 |
2 files changed, 37 insertions(+), 9 deletions(-)
|
|
|
055636 |
|
|
|
055636 |
diff --git a/src/bpforc.h b/src/bpforc.h
|
|
|
055636 |
index 5634c544..1900e497 100644
|
|
|
055636 |
--- a/src/bpforc.h
|
|
|
055636 |
+++ b/src/bpforc.h
|
|
|
055636 |
@@ -20,6 +20,9 @@
|
|
|
055636 |
#ifdef LLVM_ORC_V2
|
|
|
055636 |
#include <llvm/ExecutionEngine/Orc/Core.h>
|
|
|
055636 |
#include <llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h>
|
|
|
055636 |
+#if LLVM_VERSION_MAJOR >= 13
|
|
|
055636 |
+#include <llvm/ExecutionEngine/Orc/ExecutorProcessControl.h>
|
|
|
055636 |
+#endif
|
|
|
055636 |
#endif
|
|
|
055636 |
|
|
|
055636 |
#include <optional>
|
|
|
055636 |
@@ -66,8 +69,12 @@ class BpfOrc
|
|
|
055636 |
std::unique_ptr<TargetMachine> TM;
|
|
|
055636 |
DataLayout DL;
|
|
|
055636 |
#if LLVM_VERSION_MAJOR >= 7
|
|
|
055636 |
+#ifdef LLVM_ORC_V2
|
|
|
055636 |
+ std::unique_ptr<ExecutionSession> ES;
|
|
|
055636 |
+#else // LLVM_ORC_V1
|
|
|
055636 |
ExecutionSession ES;
|
|
|
055636 |
#endif
|
|
|
055636 |
+#endif
|
|
|
055636 |
#if LLVM_VERSION_MAJOR >= 7 && LLVM_VERSION_MAJOR < 12
|
|
|
055636 |
std::shared_ptr<SymbolResolver> Resolver;
|
|
|
055636 |
#endif
|
|
|
055636 |
@@ -92,7 +99,21 @@ class BpfOrc
|
|
|
055636 |
#endif
|
|
|
055636 |
|
|
|
055636 |
public:
|
|
|
055636 |
+#if LLVM_VERSION_MAJOR >= 13
|
|
|
055636 |
+ ~BpfOrc()
|
|
|
055636 |
+ {
|
|
|
055636 |
+ if (auto Err = ES->endSession())
|
|
|
055636 |
+ ES->reportError(std::move(Err));
|
|
|
055636 |
+ }
|
|
|
055636 |
+#endif
|
|
|
055636 |
+#ifdef LLVM_ORC_V2
|
|
|
055636 |
+ BpfOrc(TargetMachine *TM,
|
|
|
055636 |
+ DataLayout DL,
|
|
|
055636 |
+ std::unique_ptr<ExecutionSession> ES);
|
|
|
055636 |
+#else
|
|
|
055636 |
BpfOrc(TargetMachine *TM, DataLayout DL);
|
|
|
055636 |
+#endif
|
|
|
055636 |
+
|
|
|
055636 |
void compile(std::unique_ptr<Module> M);
|
|
|
055636 |
|
|
|
055636 |
/* Helper for creating a orc object, responsible for creating internal objects
|
|
|
055636 |
@@ -125,7 +146,7 @@ class BpfOrc
|
|
|
055636 |
#ifdef LLVM_ORC_V2
|
|
|
055636 |
Expected<JITEvaluatedSymbol> lookup(StringRef Name)
|
|
|
055636 |
{
|
|
|
055636 |
- return ES.lookup({ &MainJD }, Mangle(Name.str()));
|
|
|
055636 |
+ return ES->lookup({ &MainJD }, Mangle(Name.str()));
|
|
|
055636 |
}
|
|
|
055636 |
#endif
|
|
|
055636 |
};
|
|
|
055636 |
diff --git a/src/bpforcv2.cpp b/src/bpforcv2.cpp
|
|
|
055636 |
index 209e08e5..104213b0 100644
|
|
|
055636 |
--- a/src/bpforcv2.cpp
|
|
|
055636 |
+++ b/src/bpforcv2.cpp
|
|
|
055636 |
@@ -1,24 +1,26 @@
|
|
|
055636 |
// Included by bpforc.cpp
|
|
|
055636 |
|
|
|
055636 |
-BpfOrc::BpfOrc(TargetMachine *TM, DataLayout DL)
|
|
|
055636 |
+BpfOrc::BpfOrc(TargetMachine *TM,
|
|
|
055636 |
+ DataLayout DL,
|
|
|
055636 |
+ std::unique_ptr<ExecutionSession> ES)
|
|
|
055636 |
: TM(std::move(TM)),
|
|
|
055636 |
DL(std::move(DL)),
|
|
|
055636 |
- ObjectLayer(ES,
|
|
|
055636 |
+ ES(std::move(ES)),
|
|
|
055636 |
+ ObjectLayer(*(this->ES),
|
|
|
055636 |
[this]() {
|
|
|
055636 |
return std::make_unique<MemoryManager>(sections_);
|
|
|
055636 |
}),
|
|
|
055636 |
- CompileLayer(ES,
|
|
|
055636 |
+ CompileLayer(*this->ES,
|
|
|
055636 |
ObjectLayer,
|
|
|
055636 |
std::make_unique<SimpleCompiler>(*this->TM)),
|
|
|
055636 |
- Mangle(ES, this->DL),
|
|
|
055636 |
+ Mangle(*this->ES, this->DL),
|
|
|
055636 |
CTX(std::make_unique<LLVMContext>()),
|
|
|
055636 |
- MainJD(cantFail(ES.createJITDylib("<main>")))
|
|
|
055636 |
+ MainJD(cantFail(this->ES->createJITDylib("<main>")))
|
|
|
055636 |
{
|
|
|
055636 |
MainJD.addGenerator(
|
|
|
055636 |
cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess(
|
|
|
055636 |
DL.getGlobalPrefix())));
|
|
|
055636 |
}
|
|
|
055636 |
-
|
|
|
055636 |
LLVMContext &BpfOrc::getContext()
|
|
|
055636 |
{
|
|
|
055636 |
return *CTX.getContext();
|
|
|
055636 |
@@ -37,8 +39,13 @@ std::unique_ptr<BpfOrc> BpfOrc::Create()
|
|
|
055636 |
// return unique_ptrs
|
|
|
055636 |
auto DL = cantFail(JTMB.getDefaultDataLayoutForTarget());
|
|
|
055636 |
auto TM = cantFail(JTMB.createTargetMachine());
|
|
|
055636 |
-
|
|
|
055636 |
- return std::make_unique<BpfOrc>(TM.release(), std::move(DL));
|
|
|
055636 |
+#if LLVM_VERSION_MAJOR >= 13
|
|
|
055636 |
+ auto EPC = SelfExecutorProcessControl::Create();
|
|
|
055636 |
+ auto ES = std::make_unique<ExecutionSession>(std::move(*EPC));
|
|
|
055636 |
+#else
|
|
|
055636 |
+ auto ES = std::make_unique<ExecutionSession>();
|
|
|
055636 |
+#endif
|
|
|
055636 |
+ return std::make_unique<BpfOrc>(TM.release(), std::move(DL), std::move(ES));
|
|
|
055636 |
}
|
|
|
055636 |
|
|
|
055636 |
void BpfOrc::compile(std::unique_ptr<Module> M)
|
|
|
055636 |
--
|
|
|
055636 |
2.31.1
|
|
|
055636 |
|