Merge pull request #148535 from martinetd/bpf

bpf update: bcc remove linux kernel dep + devendor libbpf again, bpftrace 0.13.0 -> 0.14.0 + remove kernel dep, pahole 1.20 -> 1.22 + remove submodule, libbpf revert 0.6.0 -> 0.5.0 (unusable)
main
Jörg Thalheim 3 years ago committed by GitHub
commit c7fa870f5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      maintainers/maintainer-list.nix
  2. 6
      nixos/modules/programs/bcc.nix
  3. 1
      nixos/tests/all-tests.nix
  4. 25
      nixos/tests/bpf.nix
  5. 15
      pkgs/development/tools/misc/pahole/default.nix
  6. 24
      pkgs/os-specific/linux/bcc/default.nix
  7. 39
      pkgs/os-specific/linux/bpftrace/btf-dump-new-0.6.0.patch
  8. 35
      pkgs/os-specific/linux/bpftrace/default.nix
  9. 22
      pkgs/os-specific/linux/bpftrace/fix-kernel-include-dir.patch
  10. 7
      pkgs/os-specific/linux/libbpf/default.nix
  11. 6
      pkgs/top-level/all-packages.nix
  12. 7
      pkgs/top-level/linux-kernels.nix

@ -7238,6 +7238,12 @@
githubId = 623509;
name = "Martijn Vermaat";
};
martinetd = {
email = "f.ktfhrvnznqxacf@noclue.notk.org";
github = "martinetd";
githubId = 1729331;
name = "Dominique Martinet";
};
martingms = {
email = "martin@mg.am";
github = "martingms";

@ -1,9 +1,9 @@
{ config, lib, ... }:
{ config, pkgs, lib, ... }:
{
options.programs.bcc.enable = lib.mkEnableOption "bcc";
config = lib.mkIf config.programs.bcc.enable {
environment.systemPackages = [ config.boot.kernelPackages.bcc ];
boot.extraModulePackages = [ config.boot.kernelPackages.bcc ];
environment.systemPackages = [ pkgs.bcc ];
boot.extraModulePackages = [ pkgs.bcc ];
};
}

@ -44,6 +44,7 @@ in
boot-stage1 = handleTest ./boot-stage1.nix {};
borgbackup = handleTest ./borgbackup.nix {};
botamusique = handleTest ./botamusique.nix {};
bpf = handleTestOn ["x86_64-linux" "aarch64-linux"] ./bpf.nix {};
btrbk = handleTest ./btrbk.nix {};
buildbot = handleTest ./buildbot.nix {};
buildkite-agents = handleTest ./buildkite-agents.nix {};

@ -0,0 +1,25 @@
import ./make-test-python.nix ({ pkgs, ... }: {
name = "bpf";
meta.maintainers = with pkgs.lib.maintainers; [ martinetd ];
machine = { pkgs, ... }: {
programs.bcc.enable = true;
environment.systemPackages = with pkgs; [ bpftrace ];
};
testScript = ''
## bcc
# syscount -d 1 stops 1s after probe started so is good for that
print(machine.succeed("syscount -d 1"))
## bpftrace
# list probes
machine.succeed("bpftrace -l")
# simple BEGIN probe (user probe on bpftrace itself)
print(machine.succeed("bpftrace -e 'BEGIN { print(\"ok\"); exit(); }'"))
# tracepoint
print(machine.succeed("bpftrace -e 'tracepoint:syscalls:sys_enter_* { print(probe); exit(); }'"))
# kprobe
print(machine.succeed("bpftrace -e 'kprobe:schedule { print(probe); exit() }'"))
'';
})

@ -1,20 +1,19 @@
{ lib, stdenv, fetchgit, cmake, elfutils, zlib }:
{ lib, stdenv, fetchgit, pkg-config, libbpf, cmake, elfutils, zlib }:
stdenv.mkDerivation rec {
pname = "pahole";
version = "1.20";
version = "1.22";
src = fetchgit {
url = "https://git.kernel.org/pub/scm/devel/pahole/pahole.git";
rev = "v${version}";
sha256 = "11q9dpfi4qj2v8z0nlf8c0079mlv10ljhh0d1yr0j4ds3saacd15";
fetchSubmodules = true;
sha256 = "sha256-U1/i9WNlLphPIcNysC476sqil/q9tMYmu+Y6psga8I0=";
};
nativeBuildInputs = [ cmake ];
buildInputs = [ elfutils zlib ];
nativeBuildInputs = [ cmake pkg-config ];
buildInputs = [ elfutils zlib libbpf ];
# Put libraries in "lib" subdirectory, not top level of $out
cmakeFlags = [ "-D__LIB=lib" ];
cmakeFlags = [ "-D__LIB=lib" "-DLIBBPF_EMBEDDED=OFF" ];
meta = with lib; {
homepage = "https://git.kernel.org/cgit/devel/pahole/pahole.git/";
@ -22,6 +21,6 @@ stdenv.mkDerivation rec {
license = licenses.gpl2Only;
platforms = platforms.linux;
maintainers = [ maintainers.bosu ];
maintainers = with maintainers; [ bosu martinetd ];
};
}

@ -1,7 +1,7 @@
{ lib, stdenv, fetchFromGitHub
, makeWrapper, cmake, llvmPackages, kernel
, makeWrapper, cmake, llvmPackages
, flex, bison, elfutils, python, luajit, netperf, iperf, libelf
, systemtap, bash
, bash, libbpf, nixosTests
}:
python.pkgs.buildPythonApplication rec {
@ -14,15 +14,14 @@ python.pkgs.buildPythonApplication rec {
owner = "iovisor";
repo = "bcc";
rev = "v${version}";
sha256 = "sha256-4zfjr3VLg26uZ4xNKA1wayti7f2tqGvYSbwoZnr+Ygk=";
fetchSubmodules = true;
sha256 = "sha256-iLVUwJTDQ8Bn38sgHOcIR8TYxIB+gIlfTgr9+gPU0gE=";
};
format = "other";
buildInputs = with llvmPackages; [
llvm llvm.dev libclang kernel
llvm llvm.dev libclang
elfutils luajit netperf iperf
systemtap.stapBuild flex bash
flex bash libbpf
];
patches = [
@ -32,15 +31,14 @@ python.pkgs.buildPythonApplication rec {
];
propagatedBuildInputs = [ python.pkgs.netaddr ];
nativeBuildInputs = [ makeWrapper cmake flex bison llvmPackages.llvm.dev ]
# libelf is incompatible with elfutils-libelf
++ lib.filter (x: x != libelf) kernel.moduleBuildDependencies;
nativeBuildInputs = [ makeWrapper cmake flex bison llvmPackages.llvm.dev ];
cmakeFlags = [
"-DBCC_KERNEL_MODULES_DIR=${kernel.dev}/lib/modules"
"-DBCC_KERNEL_MODULES_DIR=/run/booted-system/kernel-modules/lib/modules"
"-DREVISION=${version}"
"-DENABLE_USDT=ON"
"-DENABLE_CPP_API=ON"
"-DCMAKE_USE_LIBBPF_PACKAGE=ON"
];
postPatch = ''
@ -71,10 +69,14 @@ python.pkgs.buildPythonApplication rec {
wrapPythonProgramsIn "$out/share/bcc/tools" "$out $pythonPath"
'';
passthru.tests = {
bpf = nixosTests.bpf;
};
meta = with lib; {
description = "Dynamic Tracing Tools for Linux";
homepage = "https://iovisor.github.io/bcc/";
license = licenses.asl20;
maintainers = with maintainers; [ ragge mic92 thoughtpolice ];
maintainers = with maintainers; [ ragge mic92 thoughtpolice martinetd ];
};
}

@ -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)
{

@ -1,38 +1,35 @@
{ lib, stdenv, fetchFromGitHub
, cmake, pkg-config, flex, bison
, llvmPackages, kernel, elfutils
, llvmPackages, elfutils
, libelf, libbfd, libbpf, libopcodes, bcc
, cereal, asciidoctor
, nixosTests
}:
stdenv.mkDerivation rec {
pname = "bpftrace";
version = "0.13.0";
version = "0.14.0";
src = fetchFromGitHub {
owner = "iovisor";
repo = "bpftrace";
rev = "v${version}";
sha256 = "sha256-BKWBdFzj0j7rAfG30A0fwyYCpOG/5NFRPODW46EP1u0=";
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
kernel elfutils libelf bcc
elfutils libelf bcc
libbpf libbfd libopcodes
cereal asciidoctor
];
nativeBuildInputs = [ cmake pkg-config flex bison llvmPackages.llvm.dev ]
# libelf is incompatible with elfutils-libelf
++ lib.filter (x: x != libelf) kernel.moduleBuildDependencies;
# patch the source, *then* substitute on @NIX_KERNEL_SRC@ in the result. we could
# also in theory make this an environment variable around bpftrace, but this works
# nicely without wrappers.
patchPhase = ''
patch -p1 < ${./fix-kernel-include-dir.patch}
substituteInPlace ./src/utils.cpp \
--subst-var-by NIX_KERNEL_SRC '${kernel.dev}/lib/modules/${kernel.modDirVersion}'
'';
nativeBuildInputs = [ cmake pkg-config flex bison llvmPackages.llvm.dev ];
# tests aren't built, due to gtest shenanigans. see:
#
@ -52,10 +49,14 @@ stdenv.mkDerivation rec {
outputs = [ "out" "man" ];
passthru.tests = {
bpf = nixosTests.bpf;
};
meta = with lib; {
description = "High-level tracing language for Linux eBPF";
homepage = "https://github.com/iovisor/bpftrace";
license = licenses.asl20;
maintainers = with maintainers; [ rvl thoughtpolice ];
maintainers = with maintainers; [ rvl thoughtpolice martinetd ];
};
}

@ -1,22 +0,0 @@
commit b6172952c0150d84912fa6f09bab782dd0549f1e
Author: Austin Seipp <aseipp@pobox.com>
Date: Fri May 3 00:47:12 2019 -0500
src: special case nix build directories for clang
Signed-off-by: Austin Seipp <aseipp@pobox.com>
diff --git a/src/clang_parser.cpp b/src/clang_parser.cpp
index b1db8ff..0cfb01f 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -140,6 +140,9 @@ static bool is_dir(const std::string& path)
// Both ksrc and kobj are guaranteed to be != "", if at least some trace of kernel sources was found.
std::tuple<std::string, std::string> get_kernel_dirs(const struct utsname& utsname)
{
+ // NB (aseipp): special case the kernel directory for nix
+ return { "@NIX_KERNEL_SRC@/source", "@NIX_KERNEL_SRC@/build" };
+
#ifdef KERNEL_HEADERS_DIR
return {KERNEL_HEADERS_DIR, KERNEL_HEADERS_DIR};
#endif

@ -23,6 +23,11 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;
makeFlags = [ "PREFIX=$(out)" ];
postInstall = ''
# install linux's libbpf-compatible linux/btf.h
install -Dm444 ../include/uapi/linux/btf.h -t $out/include/linux
'';
# FIXME: Multi-output requires some fixes to the way the pkg-config file is
# constructed (it gets put in $out instead of $dev for some reason, with
# improper paths embedded). Don't enable it for now.
@ -33,7 +38,7 @@ stdenv.mkDerivation rec {
description = "Upstream mirror of libbpf";
homepage = "https://github.com/libbpf/libbpf";
license = with licenses; [ lgpl21 /* or */ bsd2 ];
maintainers = with maintainers; [ thoughtpolice vcunat saschagrunert ];
maintainers = with maintainers; [ thoughtpolice vcunat saschagrunert martinetd ];
platforms = platforms.linux;
};
}

@ -14167,6 +14167,12 @@ with pkgs;
bpftools = callPackage ../os-specific/linux/bpftools { };
bcc = callPackage ../os-specific/linux/bcc {
python = pkgs.python3;
};
bpftrace = callPackage ../os-specific/linux/bpftrace { };
bpm-tools = callPackage ../tools/audio/bpm-tools { };
byacc = callPackage ../development/tools/parsing/byacc { };

@ -250,6 +250,7 @@ in {
inherit (kernel) kernelOlder kernelAtLeast;
# Obsolete aliases (these packages do not depend on the kernel).
inherit (pkgs) odp-dpdk pktgen; # added 2018-05
inherit (pkgs) bcc bpftrace; # added 2021-12
acpi_call = callPackage ../os-specific/linux/acpi-call {};
@ -263,12 +264,6 @@ in {
batman_adv = callPackage ../os-specific/linux/batman-adv {};
bcc = callPackage ../os-specific/linux/bcc {
python = pkgs.python3;
};
bpftrace = callPackage ../os-specific/linux/bpftrace { };
bbswitch = callPackage ../os-specific/linux/bbswitch {};
chipsec = callPackage ../tools/security/chipsec {

Loading…
Cancel
Save