From 3c131c2bac5ca105270a1ab075632f13cf8d8485 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Sat, 4 Sep 2021 17:41:52 -0700 Subject: bpftrace: Fix build with clang >= 13 Signed-off-by: Khem Raj --- .../0001-support-clang-upto-version-13.patch | 15 +-- .../0002-orc-Fix-build-with-clang-13.patch | 119 +++++++++++++++++++++ .../recipes-devtools/bpftrace/bpftrace_0.13.0.bb | 1 + 3 files changed, 128 insertions(+), 7 deletions(-) create mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0002-orc-Fix-build-with-clang-13.patch (limited to 'dynamic-layers') diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-support-clang-upto-version-13.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-support-clang-upto-version-13.patch index c881904..6da2fae 100644 --- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-support-clang-upto-version-13.patch +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-support-clang-upto-version-13.patch @@ -1,26 +1,27 @@ -From 7b2f02a7b7d246b24cf029b3a75d8595b7b3c250 Mon Sep 17 00:00:00 2001 +From a01f0fb44e704a8439e431acf47d6fb0eff5bf9d Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Thu, 5 Aug 2021 22:15:27 -0700 Subject: [PATCH 1/2] support clang upto version 13 -Upstream-Status: Submitted [https://github.com/iovisor/bpftrace/pull/1962] +Upstream-Status: Submitted [https://github.com/iovisor/bpftrace/pull/1993] Signed-off-by: Khem Raj --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt -index 86daa195..73744207 100644 +index 596b6766..7aab66f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -162,7 +162,7 @@ else() +@@ -164,7 +164,7 @@ else() find_package(LLVM REQUIRED) endif() - + - if((${LLVM_VERSION_MAJOR} VERSION_LESS 6) OR (${LLVM_VERSION_MAJOR} VERSION_GREATER 12)) + if((${LLVM_VERSION_MAJOR} VERSION_LESS 6) OR (${LLVM_VERSION_MAJOR} VERSION_GREATER 13)) message(SEND_ERROR "Unsupported LLVM version found: ${LLVM_INCLUDE_DIRS}") message(SEND_ERROR "Specify an LLVM major version using LLVM_REQUESTED_VERSION=") endif() --- -2.32.0 +-- +2.33.0 + diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0002-orc-Fix-build-with-clang-13.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0002-orc-Fix-build-with-clang-13.patch new file mode 100644 index 0000000..a00b006 --- /dev/null +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0002-orc-Fix-build-with-clang-13.patch @@ -0,0 +1,119 @@ +From fbdf215a0ee9002ae65e87673d50dd40d0cfcf78 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sat, 4 Sep 2021 17:28:17 -0700 +Subject: [PATCH 2/2] orc: Fix build with clang >= 13 + +Fixes errors like +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 +BpfOrc::BpfOrc(TargetMachine *TM, DataLayout DL) + ^ + +Fixes https://github.com/iovisor/bpftrace/issues/1963 + +Upstream-Status: Submitted [https://github.com/iovisor/bpftrace/pull/1993] +Signed-off-by: Khem Raj +--- + src/ast/bpforc/bpforc.h | 17 ++++++++++++++++- + src/ast/bpforc/bpforcv2.cpp | 28 ++++++++++++++++++++++++++-- + 2 files changed, 42 insertions(+), 3 deletions(-) + +diff --git a/src/ast/bpforc/bpforc.h b/src/ast/bpforc/bpforc.h +index 1b929dfd..fedfe975 100644 +--- a/src/ast/bpforc/bpforc.h ++++ b/src/ast/bpforc/bpforc.h +@@ -72,8 +72,12 @@ private: + std::unique_ptr TM; + DataLayout DL; + #if LLVM_VERSION_MAJOR >= 7 ++#ifdef LLVM_ORC_V2 ++ std::unique_ptr ES; ++#else // LLVM_ORC_V1 + ExecutionSession ES; + #endif ++#endif + #if LLVM_VERSION_MAJOR >= 7 && LLVM_VERSION_MAJOR < 12 + std::shared_ptr Resolver; + #endif +@@ -98,7 +102,18 @@ private: + #endif + + public: ++#ifdef LLVM_ORC_V2 ++ ~BpfOrc() ++ { ++ if (auto Err = ES->endSession()) ++ ES->reportError(std::move(Err)); ++ } ++ BpfOrc(TargetMachine *TM, ++ DataLayout DL, ++ std::unique_ptr ES); ++#else // LLVM_ORC_V1 + BpfOrc(TargetMachine *TM, DataLayout DL); ++#endif + void compile(std::unique_ptr M); + + /* Helper for creating a orc object, responsible for creating internal objects +@@ -134,7 +149,7 @@ public: + #ifdef LLVM_ORC_V2 + Expected lookup(StringRef Name) + { +- return ES.lookup({ &MainJD }, Mangle(Name.str())); ++ return ES->lookup({ &MainJD }, Mangle(Name.str())); + } + #endif + }; +diff --git a/src/ast/bpforc/bpforcv2.cpp b/src/ast/bpforc/bpforcv2.cpp +index 9876625b..41ec7ca3 100644 +--- a/src/ast/bpforc/bpforcv2.cpp ++++ b/src/ast/bpforc/bpforcv2.cpp +@@ -1,5 +1,23 @@ + // Included by bpforc.cpp + ++#if LLVM_VERSION_MAJOR >= 13 ++BpfOrc::BpfOrc(TargetMachine *TM, ++ DataLayout DL, ++ std::unique_ptr ES) ++ : TM(std::move(TM)), ++ DL(std::move(DL)), ++ ES(std::move(ES)), ++ ObjectLayer(*this->ES, ++ []() { return std::make_unique(); }), ++ CompileLayer(*this->ES, ++ ObjectLayer, ++ std::make_unique(*this->TM)), ++ Mangle(*this->ES, this->DL), ++ CTX(std::make_unique()), ++ MainJD(cantFail(this->ES->createJITDylib("
"))) ++{ ++} ++#else + BpfOrc::BpfOrc(TargetMachine *TM, DataLayout DL) + : TM(std::move(TM)), + DL(std::move(DL)), +@@ -16,6 +34,7 @@ BpfOrc::BpfOrc(TargetMachine *TM, DataLayout DL) + { + } + ++#endif + LLVMContext &BpfOrc::getContext() + { + return *CTX.getContext(); +@@ -34,8 +53,13 @@ std::unique_ptr BpfOrc::Create() + // return unique_ptrs + auto DL = cantFail(JTMB.getDefaultDataLayoutForTarget()); + auto TM = cantFail(JTMB.createTargetMachine()); +- +- return std::make_unique(TM.release(), std::move(DL)); ++#if LLVM_VERSION_MAJOR >= 13 ++ auto EPC = SelfExecutorProcessControl::Create(); ++ auto ES = std::make_unique(std::move(*EPC)); ++ return std::make_unique(TM.release(), std::move(DL), std::move(ES)); ++#else ++ return std::make_unique(TM.release(), std::move(DL), 0); ++#endif + } + + void BpfOrc::compile(std::unique_ptr M) +-- +2.33.0 + diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.13.0.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.13.0.bb index 952a66f..09d1fd2 100644 --- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.13.0.bb +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.13.0.bb @@ -18,6 +18,7 @@ RDEPENDS:${PN} += "bash python3 xz" SRC_URI = "git://github.com/iovisor/bpftrace;branch=master \ file://0001-support-clang-upto-version-13.patch \ + file://0002-orc-Fix-build-with-clang-13.patch \ " SRCREV = "283fe526dfc262fdecddec4beb921835ea0cc89e" -- cgit v1.2.3-54-g00ecf