[arch-commits] Commit in bpftrace/trunk (PKGBUILD bcc-025.patch binutils-239.patch)

Anatol Pomozov anatolik at gemini.archlinux.org
Mon Aug 29 17:08:45 UTC 2022


    Date: Monday, August 29, 2022 @ 17:08:45
  Author: anatolik
Revision: 1285432

FS#75718: rebuild against the latest bcc and binutils

Added:
  bpftrace/trunk/bcc-025.patch
  bpftrace/trunk/binutils-239.patch
Modified:
  bpftrace/trunk/PKGBUILD

--------------------+
 PKGBUILD           |   16 +++++++--
 bcc-025.patch      |   88 +++++++++++++++++++++++++++++++++++++++++++++++++++
 binutils-239.patch |   82 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 183 insertions(+), 3 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2022-08-29 17:04:44 UTC (rev 1285431)
+++ PKGBUILD	2022-08-29 17:08:45 UTC (rev 1285432)
@@ -3,7 +3,7 @@
 
 pkgname=bpftrace
 pkgver=0.15.0
-pkgrel=2
+pkgrel=3
 pkgdesc='High-level tracing language for Linux eBPF'
 arch=('x86_64')
 url='https://github.com/iovisor/bpftrace'
@@ -12,9 +12,19 @@
 makedepends=('cmake' 'llvm13' 'git' 'linux-headers' 'ninja' 'gtest' 'cereal'
              'asciidoctor' 'xxd')
 options=(!strip)
-source=("https://github.com/iovisor/bpftrace/archive/v$pkgver/bpftrace-$pkgver.tar.gz")
-sha512sums=('916e9afeab301e62472e570ef77a3b9b27b43251880b64f1c5f151583c59a6c61e9ede50f3607044b27c5a6ce1a654f290153bf3f9237ebc0a823b5e6356187a')
+source=("https://github.com/iovisor/bpftrace/archive/v$pkgver/bpftrace-$pkgver.tar.gz"
+        binutils-239.patch
+        bcc-025.patch)
+sha512sums=('916e9afeab301e62472e570ef77a3b9b27b43251880b64f1c5f151583c59a6c61e9ede50f3607044b27c5a6ce1a654f290153bf3f9237ebc0a823b5e6356187a'
+            '49d168b4a40898eef688196dfed12423392cd56635c63c2a32e3c5a5fb4a8757fee3f4b31df9ba43736d7c0a3ad38a14d6ceb07cdfc73d8598b48d6c17727ba2'
+            '22ef3d05790416b4286ea9931646c3940877da8cf02b9645edbc753a4adb75e90f233b533d0c2c790eb62592c6af6487c02a502ecca8d547ec3d329a2aa71f64')
 
+prepare() {
+  cd bpftrace-$pkgver
+  patch -p1 < ../bcc-025.patch # https://github.com/iovisor/bpftrace/issues/2340
+  patch -p1 < ../binutils-239.patch # https://github.com/iovisor/bpftrace/pull/2287
+}
+
 build() {
   cd bpftrace-$pkgver
 

Added: bcc-025.patch
===================================================================
--- bcc-025.patch	                        (rev 0)
+++ bcc-025.patch	2022-08-29 17:08:45 UTC (rev 1285432)
@@ -0,0 +1,88 @@
+From f86c3bde84d9e75ec2780a51a1ca7dc20a4740e6 Mon Sep 17 00:00:00 2001
+From: Dominique Martinet <asmadeus at codewreck.org>
+Date: Thu, 25 Aug 2022 21:47:30 +0900
+Subject: [PATCH] Fix builds against bcc >= 0.25.0
+
+libbpf 1.0.0 removed bpf_load_program_attr in
+https://github.com/libbpf/libbpf/commit/9476dce6fe905a6bf1d4c483f7b2b8575c4ffb2d
+and bcc 0.25.0 in turn changed bcc_prog_load_xattr to use
+bpf_prog_load_opts instead in
+https://github.com/iovisor/bcc/commit/185143bdec6134255363446f644acd766ffb3825
+
+Add a compile check to use the appropriate version
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index c5c4c39630d2..f23b2ba52740 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -138,7 +138,7 @@ check_symbol_exists(bpf_attach_kfunc "${LIBBCC_INCLUDE_DIRS}/bcc/libbpf.h" HAVE_
+ check_symbol_exists(bcc_usdt_addsem_probe "${LIBBCC_INCLUDE_DIRS}/bcc/bcc_usdt.h" HAVE_BCC_USDT_ADDSEM)
+ check_symbol_exists(bcc_procutils_which_so "${LIBBCC_INCLUDE_DIRS}/bcc/bcc_proc.h" HAVE_BCC_WHICH_SO)
+ 
+-# bcc_prog_load_xattr needs struct bpf_load_program_attr,
++# bcc_prog_load_xattr needs struct bpf_prog_load_opts or bpf_load_program_attr,
+ # which is defined in libbpf
+ if (LIBBPF_FOUND)
+   check_symbol_exists(bcc_prog_load_xattr "${LIBBCC_INCLUDE_DIRS}/bcc/libbpf.h" HAVE_BCC_PROG_LOAD_XATTR)
+@@ -236,6 +236,10 @@ if(LIBBCC_ATTACH_UPROBE_SEVEN_ARGS_SIGNATURE)
+   set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" LIBBCC_ATTACH_UPROBE_SEVEN_ARGS_SIGNATURE)
+ endif(LIBBCC_ATTACH_UPROBE_SEVEN_ARGS_SIGNATURE)
+ 
++if(LIBBCC_PROG_LOAD_XATTRS_WITH_OPTS)
++  set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" LIBBCC_PROG_LOAD_XATTRS_WITH_OPTS)
++endif(LIBBCC_PROG_LOAD_XATTRS_WITH_OPTS)
++
+ if (HAVE_BCC_KFUNC)
+   set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" HAVE_BCC_KFUNC)
+ endif(HAVE_BCC_KFUNC)
+diff --git a/cmake/FindLibBcc.cmake b/cmake/FindLibBcc.cmake
+index 7b4f12835786..20d2e68cd75f 100644
+--- a/cmake/FindLibBcc.cmake
++++ b/cmake/FindLibBcc.cmake
+@@ -85,6 +85,16 @@ int main(void) {
+   return 0;
+ }
+ " LIBBCC_ATTACH_UPROBE_SEVEN_ARGS_SIGNATURE)
++CHECK_CXX_SOURCE_COMPILES("
++#include <bcc/libbpf.h>
++
++int main(void) {
++  struct bpf_prog_load_opts *opts = (struct bpf_prog_load_opts*) 1;
++
++  bcc_prog_load_xattr(BPF_PROG_TYPE_UNSPEC, 0, 0, 0, opts, 0, 0, 0, true);
++  return 0;
++}
++" LIBBCC_PROG_LOAD_XATTRS_WITH_OPTS)
+ SET(CMAKE_REQUIRED_INCLUDES)
+ 
+ SET(CMAKE_REQUIRED_LIBRARIES ${LIBBCC_BPF_LIBRARIES})
+diff --git a/src/attached_probe.cpp b/src/attached_probe.cpp
+index 60778e53ce44..dd46f15fd8d2 100644
+--- a/src/attached_probe.cpp
++++ b/src/attached_probe.cpp
+@@ -731,7 +731,24 @@ void AttachedProbe::load_prog()
+         continue;
+       }
+ 
+-#ifdef HAVE_BCC_PROG_LOAD_XATTR
++#ifdef LIBBCC_PROG_LOAD_XATTRS_WITH_OPTS
++    struct bpf_prog_load_opts opts = { };
++
++    opts.sz = sizeof(opts);
++    opts.log_level = log_level;
++
++    progfd_ = bcc_prog_load_xattr(
++        progtype(probe_.type),
++        name.c_str(),
++        license,
++        reinterpret_cast<struct bpf_insn *>(insns),
++        &opts,
++        prog_len,
++        log_buf.get(),
++        log_buf_size,
++        true);
++
++#elif HAVE_BCC_PROG_LOAD_XATTR
+       struct bpf_load_program_attr attr = {};
+ 
+       attr.prog_type = progtype(probe_.type);

Added: binutils-239.patch
===================================================================
--- binutils-239.patch	                        (rev 0)
+++ binutils-239.patch	2022-08-29 17:08:45 UTC (rev 1285432)
@@ -0,0 +1,82 @@
+From 3be6e708d514d3378a4fe985ab907643ecbc77ee Mon Sep 17 00:00:00 2001
+From: Viktor Malik <viktor.malik at gmail.com>
+Date: Mon, 15 Aug 2022 15:13:14 +0200
+Subject: [PATCH] Fix builds against libbfd(binutils) >=2.39
+
+Binutils 2.39 changed signature of the init_disassemble_info function by
+adding an extra parameter for styled printf function. Let CMake detect
+which of the versions is present and call it appropriately.
+---
+ CHANGELOG.md           |  2 ++
+ CMakeLists.txt         |  3 +++
+ cmake/FindLibBfd.cmake | 10 ++++++++++
+ src/bfd-disasm.cpp     | 14 ++++++++++++++
+ 4 files changed, 29 insertions(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 8f7995afd2..2e54eb84f8 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -249,6 +249,9 @@ if(HAVE_BFD_DISASM)
+   if(LIBBFD_DISASM_FOUR_ARGS_SIGNATURE)
+     set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" LIBBFD_DISASM_FOUR_ARGS_SIGNATURE)
+   endif(LIBBFD_DISASM_FOUR_ARGS_SIGNATURE)
++  if(LIBBFD_INIT_DISASM_INFO_FOUR_ARGS_SIGNATURE)
++    set(BPFTRACE_FLAGS "${BPFTRACE_FLAGS}" LIBBFD_INIT_DISASM_INFO_FOUR_ARGS_SIGNATURE)
++  endif(LIBBFD_INIT_DISASM_INFO_FOUR_ARGS_SIGNATURE)
+ endif(HAVE_BFD_DISASM)
+ 
+ if (LIBBPF_BTF_DUMP_FOUND)
+diff --git a/cmake/FindLibBfd.cmake b/cmake/FindLibBfd.cmake
+index 4f4b8c4e20..5d917b188c 100644
+--- a/cmake/FindLibBfd.cmake
++++ b/cmake/FindLibBfd.cmake
+@@ -75,5 +75,15 @@ int main(void) {
+                abfd);
+   return 0;
+ }" LIBBFD_DISASM_FOUR_ARGS_SIGNATURE)
++CHECK_CXX_SOURCE_COMPILES("
++// See comment in bfd-disasm.cpp for why this needs to exist
++#define PACKAGE \"bpftrace-test\"
++#include <dis-asm.h>
++
++int main(void) {
++  init_disassemble_info(NULL, NULL, NULL, NULL);
++  return 0;
++}
++" LIBBFD_INIT_DISASM_INFO_FOUR_ARGS_SIGNATURE)
+ SET(CMAKE_REQUIRED_LIBRARIES)
+ endif()
+diff --git a/src/bfd-disasm.cpp b/src/bfd-disasm.cpp
+index f846468cd8..d4165dfac5 100644
+--- a/src/bfd-disasm.cpp
++++ b/src/bfd-disasm.cpp
+@@ -38,6 +38,16 @@ static int fprintf_nop(void *out __attribute__((unused)), const char *fmt __attr
+   return 0;
+ }
+ 
++#ifdef LIBBFD_INIT_DISASM_INFO_FOUR_ARGS_SIGNATURE
++static int fprintf_styled_nop(void *out __attribute__((unused)),
++                              enum disassembler_style s __attribute__((unused)),
++                              const char *fmt __attribute__((unused)),
++                              ...)
++{
++  return 0;
++}
++#endif
++
+ static AlignState is_aligned_buf(void *buf, uint64_t size, uint64_t offset)
+ {
+   disassembler_ftype disassemble;
+@@ -55,7 +65,11 @@ static AlignState is_aligned_buf(void *buf, uint64_t size, uint64_t offset)
+     return AlignState::Fail;
+   }
+ 
++#ifdef LIBBFD_INIT_DISASM_INFO_FOUR_ARGS_SIGNATURE
++  init_disassemble_info(&info, stdout, fprintf_nop, fprintf_styled_nop);
++#else
+   init_disassemble_info(&info, stdout, fprintf_nop);
++#endif
+ 
+   info.arch = bfd_get_arch(bfdf);
+   info.mach = bfd_get_mach(bfdf);



More information about the arch-commits mailing list