2022-10-06 18:32:54 +00:00
|
|
|
{ lib, stdenv, fetchpatch, kernel, elfutils, python2, python3, python3Packages, perl, newt, slang, asciidoc, xmlto, makeWrapper
|
2021-10-14 00:43:12 +00:00
|
|
|
, docbook_xsl, docbook_xml_dtd_45, libxslt, flex, bison, pkg-config, libunwind, binutils-unwrapped
|
2022-09-09 14:08:57 +00:00
|
|
|
, libiberty, audit, libbfd, libbfd_2_38, libopcodes, libopcodes_2_38, openssl, systemtap, numactl
|
2021-07-04 02:40:35 +00:00
|
|
|
, zlib
|
|
|
|
, withGtk ? false, gtk2
|
|
|
|
, withZstd ? true, zstd
|
|
|
|
, withLibcap ? true, libcap
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2022-01-19 23:45:15 +00:00
|
|
|
pname = "perf-linux";
|
|
|
|
version = kernel.version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
inherit (kernel) src;
|
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
patches = lib.optionals (lib.versionAtLeast kernel.version "5.19" && lib.versionOlder kernel.version "5.20") [
|
|
|
|
# binutils-2.39 support around init_disassemble_info()
|
|
|
|
# API change.
|
|
|
|
# Will be included in 5.20.
|
|
|
|
./5.19-binutils-2.39-support.patch
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
preConfigure = ''
|
|
|
|
cd tools/perf
|
|
|
|
|
|
|
|
substituteInPlace Makefile \
|
|
|
|
--replace /usr/include/elfutils $elfutils/include/elfutils
|
|
|
|
|
|
|
|
for x in util/build-id.c util/dso.c; do
|
|
|
|
substituteInPlace $x --replace /usr/lib/debug /run/current-system/sw/lib/debug
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -f bash_completion ]; then
|
|
|
|
sed -i 's,^have perf,_have perf,' bash_completion
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
|
|
|
makeFlags = ["prefix=$(out)" "WERROR=0"] ++ kernel.makeFlags;
|
|
|
|
|
|
|
|
hardeningDisable = [ "format" ];
|
|
|
|
|
|
|
|
# perf refers both to newt and slang
|
|
|
|
nativeBuildInputs = [
|
|
|
|
asciidoc xmlto docbook_xsl docbook_xml_dtd_45 libxslt
|
2021-02-05 17:12:51 +00:00
|
|
|
flex bison libiberty audit makeWrapper pkg-config python3
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
buildInputs = [
|
2022-09-09 14:08:57 +00:00
|
|
|
elfutils newt slang libunwind zlib openssl systemtap.stapBuild numactl
|
|
|
|
python3 perl
|
|
|
|
] ++ (if (lib.versionAtLeast kernel.version "5.19")
|
|
|
|
then [ libbfd libopcodes ]
|
|
|
|
else [ libbfd_2_38 libopcodes_2_38 ])
|
|
|
|
++ lib.optional withGtk gtk2
|
2022-08-21 13:32:41 +00:00
|
|
|
++ (if (lib.versionAtLeast kernel.version "4.19") then [ python3 ] else [ python2 ])
|
2021-07-04 02:40:35 +00:00
|
|
|
++ lib.optional withZstd zstd
|
2022-10-06 18:32:54 +00:00
|
|
|
++ lib.optional withLibcap libcap
|
|
|
|
++ lib.optional (lib.versionAtLeast kernel.version "6.0") python3Packages.setuptools;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
NIX_CFLAGS_COMPILE = toString [
|
|
|
|
"-Wno-error=cpp"
|
|
|
|
"-Wno-error=bool-compare"
|
|
|
|
"-Wno-error=deprecated-declarations"
|
|
|
|
"-Wno-error=stringop-truncation"
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
2022-10-06 18:32:54 +00:00
|
|
|
patchShebangs scripts tools/perf/pmu-events/jevents.py
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = false; # requires "sparse"
|
|
|
|
doInstallCheck = false; # same
|
|
|
|
|
|
|
|
separateDebugInfo = true;
|
|
|
|
installFlags = [ "install" "install-man" "ASCIIDOC8=1" "prefix=$(out)" ];
|
|
|
|
|
|
|
|
preFixup = ''
|
2021-10-14 00:43:12 +00:00
|
|
|
# pull in 'objdump' into PATH to make annotations work
|
2020-04-24 23:36:52 +00:00
|
|
|
wrapProgram $out/bin/perf \
|
2021-10-14 00:43:12 +00:00
|
|
|
--prefix PATH : "${binutils-unwrapped}/bin"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://perf.wiki.kernel.org/";
|
|
|
|
description = "Linux tools to profile with performance counters";
|
2022-08-21 13:32:41 +00:00
|
|
|
maintainers = with maintainers; [ viric ];
|
|
|
|
platforms = platforms.linux;
|
2021-05-28 09:39:13 +00:00
|
|
|
broken = kernel.kernelOlder "5";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|