You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.8 KiB
64 lines
1.8 KiB
2 years ago
|
From 09a6d2c783aba4354fca5ed06438e5d7c9d4778c Mon Sep 17 00:00:00 2001
|
||
|
From: Eugene Zamriy <eugene@zamriy.info>
|
||
|
Date: Sat, 1 Apr 2023 18:25:49 +0300
|
||
|
Subject: [PATCH] Use btf_dump__new_deprecated only if available
|
||
|
|
||
|
---
|
||
|
CMakeLists.txt | 4 ++++
|
||
|
cmake/FindLibBpf.cmake | 10 ++++++++++
|
||
|
src/btf.cpp | 2 ++
|
||
|
3 files changed, 16 insertions(+)
|
||
|
|
||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||
|
index 3cfae6c..dc162f6 100644
|
||
|
--- a/CMakeLists.txt
|
||
|
+++ b/CMakeLists.txt
|
||
|
@@ -261,6 +261,10 @@ if (LIBBPF_BTF_DUMP_FOUND)
|
||
|
endif()
|
||
|
endif(LIBBPF_BTF_DUMP_FOUND)
|
||
|
|
||
|
+if (HAVE_LIBBPF_BTF_DUMP_NEW_DEPRECATED)
|
||
|
+ set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" HAVE_LIBBPF_BTF_DUMP_NEW_DEPRECATED)
|
||
|
+endif(HAVE_LIBBPF_BTF_DUMP_NEW_DEPRECATED)
|
||
|
+
|
||
|
add_subdirectory(src/arch)
|
||
|
add_subdirectory(src/ast)
|
||
|
add_subdirectory(src)
|
||
|
diff --git a/cmake/FindLibBpf.cmake b/cmake/FindLibBpf.cmake
|
||
|
index 86eb805..e55fd03 100644
|
||
|
--- a/cmake/FindLibBpf.cmake
|
||
|
+++ b/cmake/FindLibBpf.cmake
|
||
|
@@ -56,3 +56,13 @@ if (LIBBPF_FOUND)
|
||
|
SET(CMAKE_REQUIRED_DEFINITIONS)
|
||
|
SET(CMAKE_REQUIRED_LIBRARIES)
|
||
|
endif()
|
||
|
+
|
||
|
+if (LIBBPF_BTF_DUMP_FOUND)
|
||
|
+ CHECK_CXX_SOURCE_COMPILES("
|
||
|
+ #include <bpf/btf.h>
|
||
|
+ int main(void) {
|
||
|
+ btf_dump__new_deprecated(NULL, NULL, NULL, NULL);
|
||
|
+ return 0;
|
||
|
+ }
|
||
|
+ " HAVE_LIBBPF_BTF_DUMP_NEW_DEPRECATED)
|
||
|
+endif()
|
||
|
diff --git a/src/btf.cpp b/src/btf.cpp
|
||
|
index fccf0a0..df2eb22 100644
|
||
|
--- a/src/btf.cpp
|
||
|
+++ b/src/btf.cpp
|
||
|
@@ -29,9 +29,11 @@
|
||
|
* either btf_dump__new_v0_6_0() or btf_dump__new_deprecated(), which is the
|
||
|
* same as btf_dump__new() for libbtf < 0.6, and the one we still use.
|
||
|
*/
|
||
|
+#ifdef HAVE_LIBBPF_BTF_DUMP_NEW_DEPRECATED
|
||
|
#if LIBBPF_MAJOR_VERSION == 0 && LIBBPF_MINOR_VERSION >= 6
|
||
|
#define btf_dump__new(a1, a2, a3, a4) btf_dump__new_deprecated(a1, a2, a3, a4)
|
||
|
#endif
|
||
|
+#endif
|
||
|
|
||
|
#include "bpftrace.h"
|
||
|
|
||
|
--
|
||
|
2.39.2
|
||
|
|