From 0ef79ab2c2c59873f55b1261f453915c44e2d04c Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 6 Sep 2022 13:08:16 -0700 Subject: bpftrace: Upgrade to 0.16.0 The patch is already applied upstream so drop it. Signed-off-by: Khem Raj --- ...BTF-api-btf_dump__new-btf_dump__new_v0_6_.patch | 212 --------------------- .../recipes-devtools/bpftrace/bpftrace_0.14.1.bb | 43 ----- .../recipes-devtools/bpftrace/bpftrace_0.16.0.bb | 42 ++++ 3 files changed, 42 insertions(+), 255 deletions(-) delete mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Detect-new-BTF-api-btf_dump__new-btf_dump__new_v0_6_.patch delete mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.14.1.bb create mode 100644 dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.16.0.bb (limited to 'dynamic-layers') diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Detect-new-BTF-api-btf_dump__new-btf_dump__new_v0_6_.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Detect-new-BTF-api-btf_dump__new-btf_dump__new_v0_6_.patch deleted file mode 100644 index 7651764..0000000 --- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-Detect-new-BTF-api-btf_dump__new-btf_dump__new_v0_6_.patch +++ /dev/null @@ -1,212 +0,0 @@ -From c5092eee7dc5f3d28a1de2c33bda6611e9ed9d34 Mon Sep 17 00:00:00 2001 -From: Jiri Olsa -Date: Tue, 22 Feb 2022 16:36:44 +0100 -Subject: [PATCH] Detect new BTF api btf_dump__new/btf_dump__new_v0_6_0 - -Some of the libbpf functions we use got deprecated and -replaced with new versions. - - btf__get_nr_types to btf__type_cnt - btf_dump__new changed arguments - -Adding detection of this and making bpftrace to compile -against latest libbpf. - -Upstream-Status: Backport [https://github.com/iovisor/bpftrace/commit/3d451feeddf725d11bb52dfbc49b616724d24fd0] - -Signed-off-by: Jiri Olsa -Signed-off-by: Khem Raj ---- - CMakeLists.txt | 8 +++++++ - cmake/FindLibBpf.cmake | 25 ++++++++++++++++++++ - src/btf.cpp | 52 +++++++++++++++++++++++++++--------------- - 3 files changed, 66 insertions(+), 19 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index c5959732..8a9b0082 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -274,6 +274,14 @@ if (LIBBPF_BTF_DUMP_FOUND) - endif() - endif(LIBBPF_BTF_DUMP_FOUND) - -+if (HAVE_LIBBPF_BTF_TYPE_CNT) -+ set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" HAVE_LIBBPF_BTF_TYPE_CNT) -+endif(HAVE_LIBBPF_BTF_TYPE_CNT) -+ -+if (HAVE_LIBBPF_BTF_DUMP_NEW_V0_6_0) -+ set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" HAVE_LIBBPF_BTF_DUMP_NEW_V0_6_0) -+endif(HAVE_LIBBPF_BTF_DUMP_NEW_V0_6_0) -+ - if (LIBDW_FOUND) - set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" HAVE_LIBDW) - endif () -diff --git a/cmake/FindLibBpf.cmake b/cmake/FindLibBpf.cmake -index 86eb8050..b088415f 100644 ---- a/cmake/FindLibBpf.cmake -+++ b/cmake/FindLibBpf.cmake -@@ -55,4 +55,29 @@ if (LIBBPF_FOUND) - check_symbol_exists(bpf_link_create "${LIBBPF_INCLUDE_DIRS}/bpf/bpf.h" HAVE_LIBBPF_LINK_CREATE) - SET(CMAKE_REQUIRED_DEFINITIONS) - SET(CMAKE_REQUIRED_LIBRARIES) -+ -+ INCLUDE(CheckCXXSourceCompiles) -+ SET(CMAKE_REQUIRED_INCLUDES ${LIBBPF_INCLUDE_DIRS}) -+ SET(CMAKE_REQUIRED_LIBRARIES ${LIBBPF_LIBRARIES} elf z) -+ CHECK_CXX_SOURCE_COMPILES(" -+#include -+ -+int main(void) { -+ btf__type_cnt(NULL); -+ return 0; -+} -+" HAVE_LIBBPF_BTF_TYPE_CNT) -+ -+ CHECK_CXX_SOURCE_COMPILES(" -+#include -+ -+int main(void) { -+ const struct btf_dump_opts *opts = (const struct btf_dump_opts*) 1; -+ -+ btf_dump__new(NULL, NULL, NULL, opts); -+ return 0; -+} -+" HAVE_LIBBPF_BTF_DUMP_NEW_V0_6_0) -+ SET(CMAKE_REQUIRED_INCLUDES) -+ SET(CMAKE_REQUIRED_LIBRARIES) - endif() -diff --git a/src/btf.cpp b/src/btf.cpp -index 7d83cf68..c08ef17b 100644 ---- a/src/btf.cpp -+++ b/src/btf.cpp -@@ -28,6 +28,15 @@ - - namespace bpftrace { - -+static __u32 type_cnt(const struct btf *btf) -+{ -+#ifdef HAVE_LIBBPF_BTF_TYPE_CNT -+ return btf__type_cnt(btf); -+#else -+ return btf__get_nr_types(btf); -+#endif -+} -+ - static unsigned char *get_data(const char *file, ssize_t *sizep) - { - struct stat st; -@@ -185,6 +194,21 @@ static void dump_printf(void *ctx, const char *fmt, va_list args) - free(str); - } - -+static struct btf_dump *dump_new(const struct btf *btf, -+ btf_dump_printf_fn_t dump_printf, -+ void *ctx) -+{ -+#ifdef HAVE_LIBBPF_BTF_DUMP_NEW_V0_6_0 -+ return btf_dump__new(btf, dump_printf, ctx, nullptr); -+#else -+ struct btf_dump_opts opts = { -+ .ctx = ctx, -+ }; -+ -+ return btf_dump__new(btf, nullptr, &opts, dump_printf); -+#endif -+} -+ - static const char *btf_str(const struct btf *btf, __u32 off) - { - if (!off) -@@ -220,12 +244,11 @@ std::string BTF::c_def(const std::unordered_set &set) const - return std::string(""); - - std::string ret = std::string(""); -- struct btf_dump_opts opts = { .ctx = &ret, }; - struct btf_dump *dump; - char err_buf[256]; - int err; - -- dump = btf_dump__new(btf, nullptr, &opts, dump_printf); -+ dump = dump_new(btf, dump_printf, &ret); - err = libbpf_get_error(dump); - if (err) - { -@@ -235,7 +258,7 @@ std::string BTF::c_def(const std::unordered_set &set) const - } - - std::unordered_set myset(set); -- __s32 id, max = (__s32) btf__get_nr_types(btf); -+ __s32 id, max = (__s32)type_cnt(btf); - - for (id = 1; id <= max && myset.size(); id++) - { -@@ -415,7 +438,7 @@ int BTF::resolve_args(const std::string &func, - if (!has_data()) - throw std::runtime_error("BTF data not available"); - -- __s32 id, max = (__s32)btf__get_nr_types(btf); -+ __s32 id, max = (__s32)type_cnt(btf); - std::string name = func; - - for (id = 1; id <= max; id++) -@@ -486,17 +509,14 @@ int BTF::resolve_args(const std::string &func, - - std::unique_ptr BTF::get_all_funcs() const - { -- __s32 id, max = (__s32)btf__get_nr_types(btf); -+ __s32 id, max = (__s32)type_cnt(btf); - std::string type = std::string(""); -- struct btf_dump_opts opts = { -- .ctx = &type, -- }; - struct btf_dump *dump; - std::string funcs; - char err_buf[256]; - int err; - -- dump = btf_dump__new(btf, nullptr, &opts, dump_printf); -+ dump = dump_new(btf, dump_printf, &type); - err = libbpf_get_error(dump); - if (err) - { -@@ -545,16 +565,13 @@ std::map> BTF::get_params( - const std::set &funcs) const - { - #ifdef HAVE_LIBBPF_BTF_DUMP_EMIT_TYPE_DECL -- __s32 id, max = (__s32)btf__get_nr_types(btf); -+ __s32 id, max = (__s32)type_cnt(btf); - std::string type = std::string(""); -- struct btf_dump_opts opts = { -- .ctx = &type, -- }; - struct btf_dump *dump; - char err_buf[256]; - int err; - -- dump = btf_dump__new(btf, nullptr, &opts, dump_printf); -+ dump = dump_new(btf, dump_printf, &type); - err = libbpf_get_error(dump); - if (err) - { -@@ -639,16 +656,13 @@ std::map> BTF::get_params( - std::set BTF::get_all_structs() const - { - std::set struct_set; -- __s32 id, max = (__s32)btf__get_nr_types(btf); -+ __s32 id, max = (__s32)type_cnt(btf); - std::string types = std::string(""); -- struct btf_dump_opts opts = { -- .ctx = &types, -- }; - struct btf_dump *dump; - char err_buf[256]; - int err; - -- dump = btf_dump__new(btf, nullptr, &opts, dump_printf); -+ dump = dump_new(btf, dump_printf, &types); - err = libbpf_get_error(dump); - if (err) - { --- -2.36.0 - diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.14.1.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.14.1.bb deleted file mode 100644 index 937c61f..0000000 --- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.14.1.bb +++ /dev/null @@ -1,43 +0,0 @@ -SUMMARY = "bpftrace" -HOMEPAGE = "https://github.com/iovisor/bpftrace" -LICENSE = "Apache-2.0" -LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" - -DEPENDS += "bison-native \ - flex-native \ - gzip-native \ - elfutils \ - bcc \ - systemtap \ - libcereal \ - libbpf \ - " - -PV .= "+git${SRCREV}" -RDEPENDS:${PN} += "bash python3 xz" - -SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \ - file://0001-Detect-new-BTF-api-btf_dump__new-btf_dump__new_v0_6_.patch \ -" -SRCREV = "0a318e53343aa51f811183534916a4be65a1871e" - -S = "${WORKDIR}/git" - -inherit cmake - -def llvm_major_version(d): - pvsplit = d.getVar('LLVMVERSION').split('.') - return pvsplit[0] - -LLVM_MAJOR_VERSION = "${@llvm_major_version(d)}" - -EXTRA_OECMAKE = " \ - -DCMAKE_ENABLE_EXPORTS=1 \ - -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_REQUESTED_VERSION=${LLVM_MAJOR_VERSION} \ - -DBUILD_TESTING=OFF \ - -DENABLE_MAN=OFF \ -" - -COMPATIBLE_HOST = "(x86_64.*|aarch64.*|powerpc64.*|riscv64.*)-linux" -COMPATIBLE_HOST:libc-musl = "null" diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.16.0.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.16.0.bb new file mode 100644 index 0000000..d39b01a --- /dev/null +++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.16.0.bb @@ -0,0 +1,42 @@ +SUMMARY = "bpftrace" +HOMEPAGE = "https://github.com/iovisor/bpftrace" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" + +DEPENDS += "bison-native \ + flex-native \ + gzip-native \ + elfutils \ + bcc \ + systemtap \ + libcereal \ + libbpf \ + " + +PV .= "+git${SRCREV}" +RDEPENDS:${PN} += "bash python3 xz" + +SRC_URI = "git://github.com/iovisor/bpftrace;branch=master;protocol=https \ +" +SRCREV = "ed06d87ef19e0b24a96244b1bf50ef85c3f63a37" + +S = "${WORKDIR}/git" + +inherit cmake + +def llvm_major_version(d): + pvsplit = d.getVar('LLVMVERSION').split('.') + return pvsplit[0] + +LLVM_MAJOR_VERSION = "${@llvm_major_version(d)}" + +EXTRA_OECMAKE = " \ + -DCMAKE_ENABLE_EXPORTS=1 \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_REQUESTED_VERSION=${LLVM_MAJOR_VERSION} \ + -DBUILD_TESTING=OFF \ + -DENABLE_MAN=OFF \ +" + +COMPATIBLE_HOST = "(x86_64.*|aarch64.*|powerpc64.*|riscv64.*)-linux" +COMPATIBLE_HOST:libc-musl = "null" -- cgit v1.2.3-54-g00ecf