Skip to content

Commit

Permalink
bpftrace: Fix build with llvm 17
Browse files Browse the repository at this point in the history
Signed-off-by: Khem Raj <[email protected]>
  • Loading branch information
kraj committed Jul 10, 2023
1 parent 9dcbac8 commit 6c835e5
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
From 3aa0c5caadb03b1c30d0ac366dbc7b592076dc43 Mon Sep 17 00:00:00 2001
From: Khem Raj <[email protected]>
Date: Thu, 6 Jul 2023 08:59:41 -0700
Subject: [PATCH] Adjust to build with llvm 17

PassManagerBuilder has been removed in llvm 17
itaniumDemangle() API signature has changed too

Upstream-Status: Submitted [https://github.com/iovisor/bpftrace/pull/2667]
Signed-off-by: Khem Raj <[email protected]>
---
src/ast/passes/codegen_llvm.cpp | 4 ++++
src/cxxdemangler/cxxdemangler_llvm.cpp | 4 ++++
2 files changed, 8 insertions(+)

diff --git a/src/ast/passes/codegen_llvm.cpp b/src/ast/passes/codegen_llvm.cpp
index 1af2a23e..49ab8c9d 100644
--- a/src/ast/passes/codegen_llvm.cpp
+++ b/src/ast/passes/codegen_llvm.cpp
@@ -7,7 +7,9 @@
#include <ctime>
#include <fstream>

+#if LLVM_VERSION_MAJOR <= 16
#include <llvm-c/Transforms/IPO.h>
+#endif
#include <llvm/IR/Constants.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/LegacyPassManager.h>
@@ -17,7 +19,9 @@
#include <llvm/Passes/PassBuilder.h>
#endif
#include <llvm/Transforms/IPO.h>
+#if LLVM_VERSION_MAJOR <= 16
#include <llvm/Transforms/IPO/PassManagerBuilder.h>
+#endif
#if LLVM_VERSION_MAJOR >= 14
#include <llvm/MC/TargetRegistry.h>
#else
diff --git a/src/cxxdemangler/cxxdemangler_llvm.cpp b/src/cxxdemangler/cxxdemangler_llvm.cpp
index e9a9db24..1b0bf7ea 100644
--- a/src/cxxdemangler/cxxdemangler_llvm.cpp
+++ b/src/cxxdemangler/cxxdemangler_llvm.cpp
@@ -6,7 +6,11 @@ namespace bpftrace {

char* cxxdemangle(const char* mangled)
{
+#if LLVM_VERSION_MAJOR <= 16
return llvm::itaniumDemangle(mangled, nullptr, nullptr, nullptr);
+#else
+ return llvm::itaniumDemangle(mangled);
+#endif
}

} // namespace bpftrace
--
2.41.0

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ RDEPENDS:${PN} += "bash python3 xz"

SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \
file://0001-cmake-Raise-max-llvm-major-version-to-16.patch \
file://0001-Adjust-to-build-with-llvm-17.patch \
file://run-ptest \
"
SRCREV = "e199c7e73da84bff9fe744d1e3402c2b505aa5a2"
Expand Down

0 comments on commit 6c835e5

Please sign in to comment.