Unverified Commit 1bfa1a00 authored by TomaSajt's avatar TomaSajt
Browse files

bcc: modernize

parent e5474a0a
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
--- 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
+31 −39
Original line number Diff line number Diff line
@@ -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,20 +31,6 @@ python3Packages.buildPythonApplication rec {
    tag = "v${version}";
    hash = "sha256-eP/VEq7cPALi2oDKAZFQGQ3NExdmcBKyi6ddRZiYmbI=";
  };
  format = "other";

  buildInputs = with llvmPackages; [
    llvm
    llvm.dev
    libclang
    elfutils
    luajit
    netperf
    iperf
    flex
    bash
    libbpf
  ];

  patches = [
    # This is needed until we fix
@@ -54,38 +39,49 @@ python3Packages.buildPythonApplication rec {
    # 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";
    })
  ];

  propagatedBuildInputs = [ python3Packages.netaddr ];
  build-system = [ python3Packages.setuptools ];

  dependencies = [ python3Packages.netaddr ];

  nativeBuildInputs = [
    bison
    cmake
    flex
    llvmPackages.llvm.dev
    llvmPackages.llvm
    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"
  buildInputs = [
    llvmPackages.llvm
    llvmPackages.libclang
    elfutils
    luajit
    netperf
    iperf
    flex
    bash
    libbpf
  ];

  # to replace this executable path:
  # https://github.com/iovisor/bcc/blob/master/src/python/bcc/syscall.py#L384
  ausyscall = "${audit}/bin/ausyscall";
  cmakeFlags = [
    (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)
  ];

  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