lol

perf: add default d3-flame-graph templates for flamegraph script (#198028)

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>

authored by

Aaron Jheng
Sandro
and committed by
GitHub
a72fc0d5 8f34adb8

+92 -22
+92 -22
pkgs/os-specific/linux/kernel/perf/default.nix
··· 1 - { lib, stdenv, fetchpatch, kernel, elfutils, python2, python3, python3Packages, 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, libbfd_2_38, libopcodes, libopcodes_2_38, openssl, systemtap, numactl 1 + { lib 2 + , stdenv 3 + , fetchpatch 4 + , fetchurl 5 + , kernel 6 + , elfutils 7 + , python2 8 + , python3 9 + , python3Packages 10 + , perl 11 + , newt 12 + , slang 13 + , asciidoc 14 + , xmlto 15 + , makeWrapper 16 + , docbook_xsl 17 + , docbook_xml_dtd_45 18 + , libxslt 19 + , flex 20 + , bison 21 + , pkg-config 22 + , libunwind 23 + , binutils-unwrapped 24 + , libiberty 25 + , audit 26 + , libbfd 27 + , libbfd_2_38 28 + , libopcodes 29 + , libopcodes_2_38 30 + , openssl 31 + , systemtap 32 + , numactl 4 33 , zlib 5 - , withGtk ? false, gtk2 6 - , withZstd ? true, zstd 7 - , withLibcap ? true, libcap 34 + , withGtk ? false 35 + , gtk2 36 + , withZstd ? true 37 + , zstd 38 + , withLibcap ? true 39 + , libcap 8 40 }: 41 + let 42 + d3-flame-graph-templates = stdenv.mkDerivation rec { 43 + pname = "d3-flame-graph-templates"; 44 + version = "4.1.3"; 45 + 46 + src = fetchurl { 47 + url = "https://registry.npmjs.org/d3-flame-graph/-/d3-flame-graph-${version}.tgz"; 48 + sha256 = "sha256-W5/Vh5jarXUV224aIiTB2TnBFYT3naEIcG2945QjY8Q="; 49 + }; 50 + 51 + installPhase = '' 52 + install -D -m 0755 -t $out/share/d3-flame-graph/ ./dist/templates/* 53 + ''; 54 + }; 55 + in 9 56 10 57 stdenv.mkDerivation { 11 58 pname = "perf-linux"; ··· 20 67 ./5.19-binutils-2.39-support.patch 21 68 ]; 22 69 70 + postPatch = '' 71 + patchShebangs scripts tools/perf/pmu-events/jevents.py 72 + 73 + substituteInPlace tools/perf/scripts/python/flamegraph.py \ 74 + --replace "/usr/share/d3-flame-graph/d3-flamegraph-base.html" \ 75 + "${d3-flame-graph-templates}/share/d3-flame-graph/d3-flamegraph-base.html" 76 + ''; 77 + 23 78 preConfigure = '' 24 79 cd tools/perf 25 80 ··· 35 90 fi 36 91 ''; 37 92 38 - makeFlags = ["prefix=$(out)" "WERROR=0"] ++ kernel.makeFlags; 93 + makeFlags = [ "prefix=$(out)" "WERROR=0" ] ++ kernel.makeFlags; 39 94 40 95 hardeningDisable = [ "format" ]; 41 96 42 97 # perf refers both to newt and slang 43 98 nativeBuildInputs = [ 44 - asciidoc xmlto docbook_xsl docbook_xml_dtd_45 libxslt 45 - flex bison libiberty audit makeWrapper pkg-config python3 99 + asciidoc 100 + xmlto 101 + docbook_xsl 102 + docbook_xml_dtd_45 103 + libxslt 104 + flex 105 + bison 106 + libiberty 107 + audit 108 + makeWrapper 109 + pkg-config 110 + python3 46 111 ]; 112 + 47 113 buildInputs = [ 48 - elfutils newt slang libunwind zlib openssl systemtap.stapBuild numactl 49 - python3 perl 114 + elfutils 115 + newt 116 + slang 117 + libunwind 118 + zlib 119 + openssl 120 + systemtap.stapBuild 121 + numactl 122 + python3 123 + perl 50 124 ] ++ (if (lib.versionAtLeast kernel.version "5.19") 51 - then [ libbfd libopcodes ] 52 - else [ libbfd_2_38 libopcodes_2_38 ]) 53 - ++ lib.optional withGtk gtk2 54 - ++ (if (lib.versionAtLeast kernel.version "4.19") then [ python3 ] else [ python2 ]) 55 - ++ lib.optional withZstd zstd 56 - ++ lib.optional withLibcap libcap 57 - ++ lib.optional (lib.versionAtLeast kernel.version "6.0") python3Packages.setuptools; 125 + then [ libbfd libopcodes ] 126 + else [ libbfd_2_38 libopcodes_2_38 ]) 127 + ++ lib.optional withGtk gtk2 128 + ++ (if (lib.versionAtLeast kernel.version "4.19") then [ python3 ] else [ python2 ]) 129 + ++ lib.optional withZstd zstd 130 + ++ lib.optional withLibcap libcap 131 + ++ lib.optional (lib.versionAtLeast kernel.version "6.0") python3Packages.setuptools; 58 132 59 133 NIX_CFLAGS_COMPILE = toString [ 60 134 "-Wno-error=cpp" ··· 62 136 "-Wno-error=deprecated-declarations" 63 137 "-Wno-error=stringop-truncation" 64 138 ]; 65 - 66 - postPatch = '' 67 - patchShebangs scripts tools/perf/pmu-events/jevents.py 68 - ''; 69 139 70 140 doCheck = false; # requires "sparse" 71 141 doInstallCheck = false; # same