Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-19.03 76 lines 2.3 kB view raw
1{ lib, stdenv, kernel, elfutils, python, perl, newt, slang, asciidoc, xmlto, makeWrapper 2, docbook_xsl, docbook_xml_dtd_45, libxslt, flex, bison, pkgconfig, libunwind, binutils 3, libiberty, audit, libbfd, libopcodes, openssl, systemtap, numactl 4, zlib, withGtk ? false, gtk2 ? null 5}: 6 7with lib; 8 9assert withGtk -> gtk2 != null; 10assert versionAtLeast kernel.version "3.12"; 11 12stdenv.mkDerivation { 13 name = "perf-linux-${kernel.version}"; 14 15 inherit (kernel) src; 16 17 preConfigure = '' 18 cd tools/perf 19 20 substituteInPlace Makefile \ 21 --replace /usr/include/elfutils $elfutils/include/elfutils 22 23 for x in util/build-id.c util/dso.c; do 24 substituteInPlace $x --replace /usr/lib/debug /run/current-system/sw/lib/debug 25 done 26 27 if [ -f bash_completion ]; then 28 sed -i 's,^have perf,_have perf,' bash_completion 29 fi 30 ''; 31 32 makeFlags = ["prefix=$(out)" "WERROR=0"] ++ kernel.makeFlags; 33 34 hardeningDisable = [ "format" ]; 35 36 # perf refers both to newt and slang 37 nativeBuildInputs = [ 38 asciidoc xmlto docbook_xsl docbook_xml_dtd_45 libxslt 39 flex bison libiberty audit makeWrapper pkgconfig python perl 40 ]; 41 buildInputs = [ 42 elfutils newt slang libunwind libbfd zlib openssl systemtap.stapBuild numactl 43 libopcodes 44 ] ++ stdenv.lib.optional withGtk gtk2; 45 46 # Note: we don't add elfutils to buildInputs, since it provides a 47 # bad `ld' and other stuff. 48 NIX_CFLAGS_COMPILE = 49 [ "-Wno-error=cpp" 50 "-Wno-error=bool-compare" 51 "-Wno-error=deprecated-declarations" 52 "-DOBJDUMP_PATH=\"${binutils}/bin/objdump\"" 53 ] 54 # gcc before 6 doesn't know these options 55 ++ stdenv.lib.optionals (hasPrefix "gcc-6" stdenv.cc.cc.name) [ 56 "-Wno-error=unused-const-variable" "-Wno-error=misleading-indentation" 57 ]; 58 59 doCheck = false; # requires "sparse" 60 doInstallCheck = false; # same 61 62 separateDebugInfo = true; 63 installFlags = "install install-man ASCIIDOC8=1 prefix=$(out)"; 64 65 preFixup = '' 66 wrapProgram $out/bin/perf \ 67 --prefix PATH : "${binutils}/bin" 68 ''; 69 70 meta = { 71 homepage = https://perf.wiki.kernel.org/; 72 description = "Linux tools to profile with performance counters"; 73 maintainers = with stdenv.lib.maintainers; [viric]; 74 platforms = with stdenv.lib.platforms; linux; 75 }; 76}