2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub
|
2021-02-05 17:12:51 +00:00
|
|
|
, cmake, pkg-config, flex, bison
|
2021-12-06 16:07:01 +00:00
|
|
|
, llvmPackages, elfutils
|
2020-09-25 04:45:31 +00:00
|
|
|
, libelf, libbfd, libbpf, libopcodes, bcc
|
2021-12-06 16:07:01 +00:00
|
|
|
, cereal, asciidoctor
|
|
|
|
, nixosTests
|
2022-06-16 17:23:12 +00:00
|
|
|
, util-linux
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "bpftrace";
|
2022-01-13 20:06:32 +00:00
|
|
|
version = "0.14.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
# Cherry-picked from merged PR, remove this hook on next update
|
|
|
|
# https://github.com/iovisor/bpftrace/pull/2242
|
|
|
|
# Cannot `fetchpatch` such pure renaming diff since
|
|
|
|
# https://github.com/iovisor/bpftrace/commit/2df807dbae4037aa8bf0afc03f52fb3f6321c62a.patch
|
|
|
|
# does not contain any diff in unified format but just this instead:
|
|
|
|
# ...
|
|
|
|
# man/man8/{bashreadline.8 => bashreadline.bt.8} | 0
|
|
|
|
# ...
|
|
|
|
# 35 files changed, 0 insertions(+), 0 deletions(-)
|
|
|
|
# rename man/man8/{bashreadline.8 => bashreadline.bt.8} (100%)
|
|
|
|
# ...
|
|
|
|
# on witch `fetchpatch` fails with
|
|
|
|
# error: Normalized patch '/build/patch' is empty (while the fetched file was not)!
|
|
|
|
# Did you maybe fetch a HTML representation of a patch instead of a raw patch?
|
|
|
|
postUnpack = ''
|
|
|
|
rename .8 .bt.8 "$sourceRoot"/man/man8/*.8
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "iovisor";
|
|
|
|
repo = "bpftrace";
|
2021-04-05 15:23:46 +00:00
|
|
|
rev = "v${version}";
|
2022-01-13 20:06:32 +00:00
|
|
|
sha256 = "sha256-QDqHAEVM/XHCFMS0jMLdKJfDUOpkUqONOf8+Fbd5dCY=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
# 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 ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
buildInputs = with llvmPackages;
|
2021-05-20 23:08:51 +00:00
|
|
|
[ llvm libclang
|
2021-12-06 16:07:01 +00:00
|
|
|
elfutils libelf bcc
|
2020-09-25 04:45:31 +00:00
|
|
|
libbpf libbfd libopcodes
|
2021-12-06 16:07:01 +00:00
|
|
|
cereal asciidoctor
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
nativeBuildInputs = [ cmake pkg-config flex bison llvmPackages.llvm.dev util-linux ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# tests aren't built, due to gtest shenanigans. see:
|
|
|
|
#
|
|
|
|
# https://github.com/iovisor/bpftrace/issues/161#issuecomment-453606728
|
|
|
|
# https://github.com/iovisor/bpftrace/pull/363
|
|
|
|
#
|
|
|
|
cmakeFlags =
|
|
|
|
[ "-DBUILD_TESTING=FALSE"
|
2020-09-25 04:45:31 +00:00
|
|
|
"-DLIBBCC_INCLUDE_DIRS=${bcc}/include"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# nuke the example/reference output .txt files, for the included tools,
|
|
|
|
# stuffed inside $out. we don't need them at all.
|
|
|
|
postInstall = ''
|
|
|
|
rm -rf $out/share/bpftrace/tools/doc
|
|
|
|
'';
|
|
|
|
|
|
|
|
outputs = [ "out" "man" ];
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
passthru.tests = {
|
|
|
|
bpf = nixosTests.bpf;
|
|
|
|
};
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "High-level tracing language for Linux eBPF";
|
|
|
|
homepage = "https://github.com/iovisor/bpftrace";
|
|
|
|
license = licenses.asl20;
|
2021-12-06 16:07:01 +00:00
|
|
|
maintainers = with maintainers; [ rvl thoughtpolice martinetd ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|