summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorroblabla <unfiltered@roblab.la>2021-06-22 17:55:14 +0200
committerroblabla <unfiltered@roblab.la>2021-08-18 10:40:35 +0200
commit34150f86c0a6b9d452bab09157896c3b85b103d1 (patch)
treef4a6f934644e4293df24c8fd3fe6ca72077d044d /pkgs
parentcf887eb36fb74d8d440ffdf4a8f35dd8e866826b (diff)
downloadnixpkgs-34150f86c0a6b9d452bab09157896c3b85b103d1.tar
nixpkgs-34150f86c0a6b9d452bab09157896c3b85b103d1.tar.gz
nixpkgs-34150f86c0a6b9d452bab09157896c3b85b103d1.tar.bz2
nixpkgs-34150f86c0a6b9d452bab09157896c3b85b103d1.tar.lz
nixpkgs-34150f86c0a6b9d452bab09157896c3b85b103d1.tar.xz
nixpkgs-34150f86c0a6b9d452bab09157896c3b85b103d1.tar.zst
nixpkgs-34150f86c0a6b9d452bab09157896c3b85b103d1.zip
linux-kernel: Enable BTF
BTF is a new, lightweight debug information format tailored specifically
for the needs of eBPF, allowing eBPF programs to be portable across
various kernel versions, configurations and distributions. This is used
by bpftrace and lots of new eBPF-based tooling to avoid a dependency
on LLVM on the host.

BTF debug information is enabled on all major distributions: Fedora 31+,
RHEL 8.2+, Ubuntu 20.10, Debian 11 and ArchLinux all have enabled it.

Enabling BTF debug information requires adding two new dependencies to
the kernel build: Python3 and pahole. Those will be used to generate the
BTF debugging information.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/os-specific/linux/kernel/common-config.nix7
-rw-r--r--pkgs/os-specific/linux/kernel/manual-config.nix6
2 files changed, 10 insertions, 3 deletions
diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix
index 1ce4a21e242..38bb2c4ebd0 100644
--- a/pkgs/os-specific/linux/kernel/common-config.nix
+++ b/pkgs/os-specific/linux/kernel/common-config.nix
@@ -35,7 +35,12 @@ let
   options = {
 
     debug = {
-      DEBUG_INFO                = if (features.debug or false) then yes else no;
+      # Necessary for BTF
+      DEBUG_INFO                = mkMerge [
+        (whenOlder "5.2" (if (features.debug or false) then yes else no))
+        (whenAtLeast "5.2" yes)
+      ];
+      DEBUG_INFO_BTF            = whenAtLeast "5.2" yes;
       DEBUG_KERNEL              = yes;
       DEBUG_DEVRES              = no;
       DYNAMIC_DEBUG             = yes;
diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix
index 77add0aef53..12eca63e216 100644
--- a/pkgs/os-specific/linux/kernel/manual-config.nix
+++ b/pkgs/os-specific/linux/kernel/manual-config.nix
@@ -1,5 +1,5 @@
 { lib, buildPackages, runCommand, nettools, bc, bison, flex, perl, rsync, gmp, libmpc, mpfr, openssl
-, libelf, cpio, elfutils, zstd, gawk, python3Minimal
+, libelf, cpio, elfutils, zstd, gawk, python3Minimal, zlib, pahole
 , writeTextFile
 }:
 
@@ -316,10 +316,12 @@ stdenv.mkDerivation ((drvAttrs config stdenv.hostPlatform.linux-kernel kernelPat
       ++ optional  (lib.versionAtLeast version "4.14" && lib.versionOlder version "5.8") libelf
       # Removed util-linuxMinimal since it should not be a dependency.
       ++ optionals (lib.versionAtLeast version "4.16") [ bison flex ]
-      ++ optional  (lib.versionAtLeast version "5.2")  cpio
+      ++ optionals (lib.versionAtLeast version "5.2")  [ cpio pahole ]
       ++ optional  (lib.versionAtLeast version "5.8")  elfutils
       ;
 
+  buildInputs = optional (lib.versionAtLeast version "5.2") zlib;
+
   hardeningDisable = [ "bindnow" "format" "fortify" "stackprotector" "pic" "pie" ];
 
   # Absolute paths for compilers avoid any PATH-clobbering issues.