1{
2 lib,
3 stdenv,
4 buildPackages,
5 fetchurl,
6 pkg-config,
7 libbfd,
8 popt,
9 zlib,
10 linuxHeaders,
11 libiberty_static,
12}:
13
14stdenv.mkDerivation (finalAttrs: {
15 pname = "oprofile";
16 version = "1.4.0";
17
18 src = fetchurl {
19 url = "mirror://sourceforge/oprofile/${finalAttrs.pname}-${finalAttrs.version}.tar.gz";
20 sha256 = "04m46ni0ryk4sqmzd6mahwzp7iwhwqzfbmfi42fki261sycnz83v";
21 };
22
23 patches = [
24 # fix configurePhase with gcc14:
25 # https://sourceforge.net/p/oprofile/oprofile/ci/b0acf9f0c0aac93bf6f3e196d7a52c9632ff4475/
26 ./fix-autoconf-detection-of-perf_events.patch
27 ];
28
29 postPatch = ''
30 substituteInPlace opjitconv/opjitconv.c \
31 --replace-fail "/bin/rm" "${buildPackages.coreutils}/bin/rm" \
32 --replace-fail "/bin/cp" "${buildPackages.coreutils}/bin/cp"
33 '';
34
35 nativeBuildInputs = [ pkg-config ];
36 buildInputs = [
37 libbfd
38 zlib
39 popt
40 linuxHeaders
41 libiberty_static
42 ];
43
44 configureFlags = [
45 "--with-kernel=${linuxHeaders}"
46 "--disable-shared" # needed because only the static libbfd is available
47 ];
48
49 meta = {
50 description = "System-wide profiler for Linux";
51 longDescription = ''
52 OProfile is a system-wide profiler for Linux systems, capable of
53 profiling all running code at low overhead. It consists of a
54 kernel driver and a daemon for collecting sample data, and
55 several post-profiling tools for turning data into information.
56
57 OProfile leverages the hardware performance counters of the CPU
58 to enable profiling of a wide variety of interesting statistics,
59 which can also be used for basic time-spent profiling. All code
60 is profiled: hardware and software interrupt handlers, kernel
61 modules, the kernel, shared libraries, and applications.
62 '';
63 license = lib.licenses.gpl2;
64 homepage = "http://oprofile.sourceforge.net/";
65
66 platforms = lib.platforms.linux;
67 maintainers = [ ];
68 };
69})