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