From fa857bb4357937a20675ae1ef49cf37e54e2f20c Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Sat, 4 Dec 2021 21:54:07 +0900 Subject: [PATCH] bpftrace: fix build with libbpf 0.6.0 libbpf 0.6.0 relies on typeof in bpf/btf.h to pick the right version of btf_dump__new() but that's not valid c++. see https://github.com/iovisor/bpftrace/issues/2068 --- .../linux/bpftrace/btf-dump-new-0.6.0.patch | 39 +++++++++++++++++++ pkgs/os-specific/linux/bpftrace/default.nix | 5 +++ 2 files changed, 44 insertions(+) create mode 100644 pkgs/os-specific/linux/bpftrace/btf-dump-new-0.6.0.patch diff --git a/pkgs/os-specific/linux/bpftrace/btf-dump-new-0.6.0.patch b/pkgs/os-specific/linux/bpftrace/btf-dump-new-0.6.0.patch new file mode 100644 index 000000000000..b5037192203c --- /dev/null +++ b/pkgs/os-specific/linux/bpftrace/btf-dump-new-0.6.0.patch @@ -0,0 +1,39 @@ +diff -ur source/src/btf.cpp new/src/btf.cpp +--- source/src/btf.cpp 1970-01-01 09:00:01.000000000 +0900 ++++ new/src/btf.cpp 2021-12-04 21:46:59.337023489 +0900 +@@ -225,7 +225,7 @@ + char err_buf[256]; + int err; + +- dump = btf_dump__new(btf, nullptr, &opts, dump_printf); ++ dump = btf_dump__new_deprecated(btf, nullptr, &opts, dump_printf); + err = libbpf_get_error(dump); + if (err) + { +@@ -496,7 +496,7 @@ + char err_buf[256]; + int err; + +- dump = btf_dump__new(btf, nullptr, &opts, dump_printf); ++ dump = btf_dump__new_deprecated(btf, nullptr, &opts, dump_printf); + err = libbpf_get_error(dump); + if (err) + { +@@ -554,7 +554,7 @@ + char err_buf[256]; + int err; + +- dump = btf_dump__new(btf, nullptr, &opts, dump_printf); ++ dump = btf_dump__new_deprecated(btf, nullptr, &opts, dump_printf); + err = libbpf_get_error(dump); + if (err) + { +@@ -648,7 +648,7 @@ + char err_buf[256]; + int err; + +- dump = btf_dump__new(btf, nullptr, &opts, dump_printf); ++ dump = btf_dump__new_deprecated(btf, nullptr, &opts, dump_printf); + err = libbpf_get_error(dump); + if (err) + { diff --git a/pkgs/os-specific/linux/bpftrace/default.nix b/pkgs/os-specific/linux/bpftrace/default.nix index b69514e8080f..9a197b4c78c8 100644 --- a/pkgs/os-specific/linux/bpftrace/default.nix +++ b/pkgs/os-specific/linux/bpftrace/default.nix @@ -17,6 +17,11 @@ stdenv.mkDerivation rec { sha256 = "sha256-rlaajNfpoiMtU/4aNAnbQ0VixPz9/302TZMarGzsb58="; }; + # libbpf 0.6.0 relies on typeof in bpf/btf.h to pick the right version of + # btf_dump__new() but that's not valid c++. + # see https://github.com/iovisor/bpftrace/issues/2068 + patches = [ ./btf-dump-new-0.6.0.patch ]; + buildInputs = with llvmPackages; [ llvm libclang elfutils libelf bcc