Blame SOURCES/bpftrace-0.13.1-Fix-libbtf-0.6.0-build.patch

bd8a9c
From d26accaba6f911cf82be7e9791bf6440213c5627 Mon Sep 17 00:00:00 2001
bd8a9c
From: Jerome Marchand <jmarchan@redhat.com>
bd8a9c
Date: Wed, 23 Mar 2022 09:47:25 +0100
bd8a9c
Subject: [PATCH 4/6] Fix libbtf 0.6.0 build
bd8a9c
bd8a9c
Libbtf 0.6.0 introduced a new version of btf_dump__new(). The new
bd8a9c
version is btf_dump__new_v0_6_0() while the old version was renamed
bd8a9c
btf_dump__new_deprecated(). btf_dump__new() is now overloaded,
bd8a9c
unfortunately the macro doesn't work on cpp, at least with LLVM 12.
bd8a9c
Let's call btf_dump__new_deprecated() explicitely when it's defined.
bd8a9c
bd8a9c
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
bd8a9c
---
bd8a9c
 src/btf.cpp | 9 +++++++++
bd8a9c
 1 file changed, 9 insertions(+)
bd8a9c
bd8a9c
diff --git a/src/btf.cpp b/src/btf.cpp
bd8a9c
index a5a5e2c0..fccf0a00 100644
bd8a9c
--- a/src/btf.cpp
bd8a9c
+++ b/src/btf.cpp
bd8a9c
@@ -24,6 +24,15 @@
bd8a9c
 #pragma GCC diagnostic pop
bd8a9c
 #include <bpf/libbpf.h>
bd8a9c
 
bd8a9c
+/*
bd8a9c
+ * Since libbtf 0.6, btf_dump__new() has been overloaded and now can design
bd8a9c
+ * either btf_dump__new_v0_6_0() or btf_dump__new_deprecated(), which is the
bd8a9c
+ * same as btf_dump__new() for libbtf < 0.6, and the one we still use.
bd8a9c
+ */
bd8a9c
+#if LIBBPF_MAJOR_VERSION == 0 && LIBBPF_MINOR_VERSION >= 6
bd8a9c
+#define btf_dump__new(a1, a2, a3, a4) btf_dump__new_deprecated(a1, a2, a3, a4)
bd8a9c
+#endif
bd8a9c
+
bd8a9c
 #include "bpftrace.h"
bd8a9c
 
bd8a9c
 namespace bpftrace {
bd8a9c
-- 
bd8a9c
2.35.3
bd8a9c