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

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