(address . guix-patches@gnu.org)
This configuration causes /sys/kernel/btf/vmlinux to exist, which is
necessary for some eBPF programs (e.g. those that rely on the "BPF
CO-RE" feature; see
The initial two patches introduce userland packages that enable building
the kernel with this configuration, and the third one changes the kernel
config.
From f02af354b559d53009a96d00c0f58a72957678d9 Mon Sep 17 00:00:00 2001
Message-ID: <f02af354b559d53009a96d00c0f58a72957678d9.1708822862.git.brennan@umanwizard.com>
From: Brennan Vincent <brennan@umanwizard.com>
Date: Sat, 24 Feb 2024 09:34:22 -0500
Subject: [PATCH 1/3] gnu: Add libbpf 1.1.0
* gnu/packages/linux.scm (libbpf-1.1.0): New variable.
Change-Id: I5492541a6279a73a1a3fe25381c187168e2dd253
---
gnu/packages/linux.scm | 14 ++++++++++++++
1 file changed, 14 insertions(+)
Toggle diff (29 lines)
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index ef225479ca..8c665d436d 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -9660,6 +9660,20 @@ (define-public libbpf
headers.")
(license `(,license:lgpl2.1 ,license:bsd-2))))
+(define-public libbpf-1.1.0
+ (package
+ (inherit libbpf)
+ (version "1.1.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/libbpf/libbpf")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name (package-name libbpf) version))
+ (sha256
+ (base32 "0rh8828cridphkmynb3nhdcd8l37i11885kmnp2hilk81lh7myzy"))))))
+
(define-public bcc
(package
(name "bcc")
base-commit: de24aaf13b17d6c019f3f240fd0eb0e1b8654970
--
2.41.0
From 8b7fa6a86b6e1a7956b6941ecfac337ec6ad0abe Mon Sep 17 00:00:00 2001
Message-ID: <8b7fa6a86b6e1a7956b6941ecfac337ec6ad0abe.1708822862.git.brennan@umanwizard.com>
In-Reply-To: <f02af354b559d53009a96d00c0f58a72957678d9.1708822862.git.brennan@umanwizard.com>
References: <f02af354b559d53009a96d00c0f58a72957678d9.1708822862.git.brennan@umanwizard.com>
From: Brennan Vincent <brennan@umanwizard.com>
Date: Sat, 24 Feb 2024 09:37:44 -0500
Subject: [PATCH 2/3] gnu: Add dwarves.
* gnu/packages/cpp.scm (dwarves): New variable.
Change-Id: I4d29732c1c04044f66d17b7f0ebc308e0e8134aa
---
gnu/packages/cpp.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
Toggle diff (47 lines)
diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
index e530d1d2a8..58c2da019e 100644
--- a/gnu/packages/cpp.scm
+++ b/gnu/packages/cpp.scm
@@ -84,6 +84,7 @@ (define-module (gnu packages cpp)
#:use-module (gnu packages curl)
#:use-module (gnu packages datastructures)
#:use-module (gnu packages disk)
+ #:use-module (gnu packages elf)
#:use-module (gnu packages documentation)
#:use-module (gnu packages fontutils)
#:use-module (gnu packages gcc)
@@ -1629,6 +1630,32 @@ (define-public libexpected
(home-page "https://tl.tartanllama.xyz/")
(license license:cc0)))
+(define-public dwarves
+ (package
+ (name "dwarves")
+ (version "1.24")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/acmel/dwarves")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "132ln21xj2xhpj3zzpisl18r189jdz0gn6j5rddz2ifp6zlq2vkx"))))
+ (build-system cmake-build-system)
+ (arguments
+ (list
+ #:tests? #f
+ #:configure-flags #~(list "-DLIBBPF_EMBEDDED=OFF" "-D__LIB=lib")))
+ (inputs (list pkg-config zlib libbpf-1.1.0 linux-libre-headers-6.6
+ elfutils))
+ (home-page "https://github.com/acmel/dwarves")
+ (synopsis "Pahole and the dwarves")
+ (description
+ "pahole - Shows, manipulates data structure layout and pretty prints raw data.")
+ (license license:gpl2)))
+
(define-public immer
(package
(name "immer")
--
2.41.0
From d8322b660c45b4f463106c14a4a4cf15820934cf Mon Sep 17 00:00:00 2001
Message-ID: <d8322b660c45b4f463106c14a4a4cf15820934cf.1708822862.git.brennan@umanwizard.com>
In-Reply-To: <f02af354b559d53009a96d00c0f58a72957678d9.1708822862.git.brennan@umanwizard.com>
References: <f02af354b559d53009a96d00c0f58a72957678d9.1708822862.git.brennan@umanwizard.com>
From: Brennan Vincent <brennan@umanwizard.com>
Date: Sat, 24 Feb 2024 10:07:51 -0500
Subject: [PATCH 3/3] gnu: Set CONFIG_DEBUG_INFO_BTF in bpf kernel.
* gnu/packages/linux.scm (linux-libre-with-bpf): Set CONFIG_DEBUG_INFO_BTF.
Change-Id: I9cc0da5394a63ede4a2549cbdcc13b75c8af3001
---
gnu/packages/linux.scm | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
Toggle diff (37 lines)
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 8c665d436d..f894c6cfe3 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -117,6 +117,7 @@ (define-module (gnu packages linux)
#:use-module (gnu packages crypto)
#:use-module (gnu packages cryptsetup)
#:use-module (gnu packages compression)
+ #:use-module (gnu packages cpp)
#:use-module (gnu packages databases)
#:use-module (gnu packages datastructures)
#:use-module (gnu packages dbm)
@@ -891,7 +892,11 @@ (define %bpf-extra-linux-options
;; optional, for kprobes
("CONFIG_BPF_EVENTS" . #t)
;; kheaders module
- ("CONFIG_IKHEADERS" . #t)))
+ ("CONFIG_IKHEADERS" . #t)
+ ;; BTF debug info, requires `pahole' from `dwarves' package
+ ("CONFIG_DEBUG_INFO=y" . #t)
+ ("CONFIG_DEBUG_INFO_DWARF4" . #t)
+ ("CONFIG_DEBUG_INFO_BTF" . #t)))
(define (config->string options)
(string-join (map (match-lambda
@@ -1342,7 +1347,8 @@ (define-public linux-libre-with-bpf
(package
(inherit base-linux-libre)
(inputs (modify-inputs (package-inputs base-linux-libre)
- (prepend cpio)))
+ (prepend cpio
+ (@ (gnu packages compression) zlib) python dwarves)))
(synopsis "Linux-libre with BPF support")
(description "This package provides GNU Linux-Libre with support
for @acronym{BPF, the Berkeley Packet Filter}."))))
--
2.41.0