bcc: modernize

This commit is contained in:
TomaSajt
2025-07-22 02:46:25 +02:00
parent e5474a0a3a
commit 1bfa1a0015
2 changed files with 39 additions and 58 deletions
-11
View File
@@ -1,11 +0,0 @@
--- source.org/src/python/bcc/libbcc.py 2018-05-13 08:35:06.850522883 +0100
+++ source/src/python/bcc/libbcc.py 2018-05-13 08:36:24.602733151 +0100
@@ -14,7 +14,7 @@
import ctypes as ct
-lib = ct.CDLL("libbcc.so.0", use_errno=True)
+lib = ct.CDLL("@out@/lib/libbcc.so.0", use_errno=True)
# keep in sync with bpf_common.h
lib.bpf_module_create_b.restype = ct.c_void_p
+39 -47
View File
@@ -16,15 +16,14 @@
nixosTests,
python3Packages,
readline,
stdenv,
replaceVars,
zip,
}:
python3Packages.buildPythonApplication rec {
pname = "bcc";
version = "0.35.0";
disabled = !stdenv.hostPlatform.isLinux;
pyproject = false;
src = fetchFromGitHub {
owner = "iovisor";
@@ -32,12 +31,36 @@ python3Packages.buildPythonApplication rec {
tag = "v${version}";
hash = "sha256-eP/VEq7cPALi2oDKAZFQGQ3NExdmcBKyi6ddRZiYmbI=";
};
format = "other";
buildInputs = with llvmPackages; [
llvm
llvm.dev
libclang
patches = [
# This is needed until we fix
# https://github.com/NixOS/nixpkgs/issues/40427
./fix-deadlock-detector-import.patch
# Quick & dirty fix for bashreadline
# https://github.com/NixOS/nixpkgs/issues/328743
./bashreadline.py-remove-dependency-on-elftools.patch
(replaceVars ./absolute-ausyscall.patch {
ausyscall = lib.getExe' audit "ausyscall";
})
];
build-system = [ python3Packages.setuptools ];
dependencies = [ python3Packages.netaddr ];
nativeBuildInputs = [
bison
cmake
flex
llvmPackages.llvm
makeWrapper
zip
];
buildInputs = [
llvmPackages.llvm
llvmPackages.libclang
elfutils
luajit
netperf
@@ -47,45 +70,18 @@ python3Packages.buildPythonApplication rec {
libbpf
];
patches = [
# This is needed until we fix
# https://github.com/NixOS/nixpkgs/issues/40427
./fix-deadlock-detector-import.patch
# Quick & dirty fix for bashreadline
# https://github.com/NixOS/nixpkgs/issues/328743
./bashreadline.py-remove-dependency-on-elftools.patch
];
propagatedBuildInputs = [ python3Packages.netaddr ];
nativeBuildInputs = [
bison
cmake
flex
llvmPackages.llvm.dev
makeWrapper
python3Packages.setuptools
zip
];
cmakeFlags = [
"-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"
"-DENABLE_LIBDEBUGINFOD=OFF"
(lib.cmakeFeature "BCC_KERNEL_MODULES_DIR" "/run/booted-system/kernel-modules/lib/modules")
(lib.cmakeFeature "REVISION" version)
(lib.cmakeBool "ENABLE_USDT" true)
(lib.cmakeBool "ENABLE_CPP_API" true)
(lib.cmakeBool "CMAKE_USE_LIBBPF_PACKAGE" true)
(lib.cmakeBool "ENABLE_LIBDEBUGINFOD" false)
];
# to replace this executable path:
# https://github.com/iovisor/bcc/blob/master/src/python/bcc/syscall.py#L384
ausyscall = "${audit}/bin/ausyscall";
postPatch = ''
substituteAll ${./libbcc-path.patch} ./libbcc-path.patch
patch -p1 < libbcc-path.patch
substituteAll ${./absolute-ausyscall.patch} ./absolute-ausyscall.patch
patch -p1 < absolute-ausyscall.patch
substituteInPlace src/python/bcc/libbcc.py \
--replace-fail "libbcc.so.0" "$out/lib/libbcc.so.0"
# https://github.com/iovisor/bcc/issues/3996
substituteInPlace src/cc/libbcc.pc.in \
@@ -95,10 +91,6 @@ python3Packages.buildPythonApplication rec {
--replace-fail '/bin/bash' '${readline}/lib/libreadline.so'
'';
preInstall = ''
# required for setuptool during install
export PYTHONPATH=$out/${python3Packages.python.sitePackages}:$PYTHONPATH
'';
postInstall = ''
mkdir -p $out/bin $out/share
rm -r $out/share/bcc/tools/old