at 22.05-pre 83 lines 2.4 kB view raw
1{ lib, stdenv, kernel, elfutils, python2, python3, perl, newt, slang, asciidoc, xmlto, makeWrapper 2, docbook_xsl, docbook_xml_dtd_45, libxslt, flex, bison, pkg-config, libunwind, binutils-unwrapped 3, libiberty, audit, libbfd, libopcodes, openssl, systemtap, numactl 4, zlib 5, withGtk ? false, gtk2 6, withZstd ? true, zstd 7, withLibcap ? true, libcap 8}: 9 10with lib; 11 12assert versionAtLeast kernel.version "3.12"; 13 14stdenv.mkDerivation { 15 name = "perf-linux-${kernel.version}"; 16 17 inherit (kernel) src; 18 19 preConfigure = '' 20 cd tools/perf 21 22 substituteInPlace Makefile \ 23 --replace /usr/include/elfutils $elfutils/include/elfutils 24 25 for x in util/build-id.c util/dso.c; do 26 substituteInPlace $x --replace /usr/lib/debug /run/current-system/sw/lib/debug 27 done 28 29 if [ -f bash_completion ]; then 30 sed -i 's,^have perf,_have perf,' bash_completion 31 fi 32 ''; 33 34 makeFlags = ["prefix=$(out)" "WERROR=0"] ++ kernel.makeFlags; 35 36 hardeningDisable = [ "format" ]; 37 38 # perf refers both to newt and slang 39 nativeBuildInputs = [ 40 asciidoc xmlto docbook_xsl docbook_xml_dtd_45 libxslt 41 flex bison libiberty audit makeWrapper pkg-config python3 42 ]; 43 buildInputs = [ 44 elfutils newt slang libunwind libbfd zlib openssl systemtap.stapBuild numactl 45 libopcodes python3 perl 46 ] ++ lib.optional withGtk gtk2 47 ++ (if (versionAtLeast kernel.version "4.19") then [ python3 ] else [ python2 ]) 48 ++ lib.optional withZstd zstd 49 ++ lib.optional withLibcap libcap; 50 51 # Note: we don't add elfutils to buildInputs, since it provides a 52 # bad `ld' and other stuff. 53 NIX_CFLAGS_COMPILE = toString [ 54 "-Wno-error=cpp" 55 "-Wno-error=bool-compare" 56 "-Wno-error=deprecated-declarations" 57 "-Wno-error=stringop-truncation" 58 ]; 59 60 postPatch = '' 61 patchShebangs scripts 62 ''; 63 64 doCheck = false; # requires "sparse" 65 doInstallCheck = false; # same 66 67 separateDebugInfo = true; 68 installFlags = [ "install" "install-man" "ASCIIDOC8=1" "prefix=$(out)" ]; 69 70 preFixup = '' 71 # pull in 'objdump' into PATH to make annotations work 72 wrapProgram $out/bin/perf \ 73 --prefix PATH : "${binutils-unwrapped}/bin" 74 ''; 75 76 meta = { 77 homepage = "https://perf.wiki.kernel.org/"; 78 description = "Linux tools to profile with performance counters"; 79 maintainers = with lib.maintainers; [viric]; 80 platforms = with lib.platforms; linux; 81 broken = kernel.kernelOlder "5"; 82 }; 83}