1 { lib, stdenv, fetchurl, fetchpatch
3 , gdb, cctools, xnu, bootstrap_cmds
7 stdenv.mkDerivation rec {
12 url = "https://sourceware.org/pub/${pname}/${pname}-${version}.tar.bz2";
13 hash = "sha256-yBHbWt0sX3KZRMr0fE56Zdyqu5Rh5HK1eHZd179tLUw=";
17 # Fix build on ELFv2 powerpc64
18 # https://bugs.kde.org/show_bug.cgi?id=398883
20 url = "https://github.com/void-linux/void-packages/raw/3e16b4606235885463fc9ab45b4c120f1a51aa28/srcpkgs/valgrind/patches/elfv2-ppc64-be.patch";
21 sha256 = "NV/F+5aqFZz7+OF5oN5MUTpThv4H5PEY9sBgnnWohQY=";
24 # https://bugs.kde.org/show_bug.cgi?id=453929
26 url = "https://bugsfiles.kde.org/attachment.cgi?id=148912";
27 sha256 = "Za+7K93pgnuEUQ+jDItEzWlN0izhbynX2crSOXBBY/I=";
29 # Fix build on armv7l.
30 # https://bugs.kde.org/show_bug.cgi?id=454346
32 url = "https://bugsfiles.kde.org/attachment.cgi?id=149172";
33 sha256 = "sha256-4MASLsEK8wcshboR4YOc6mIt7AvAgDPvqIZyHqlvTEs=";
36 url = "https://bugsfiles.kde.org/attachment.cgi?id=149173";
37 sha256 = "sha256-jX9hD4utWRebbXMJYZ5mu9jecvdrNP05E5J+PnKRTyQ=";
40 url = "https://bugsfiles.kde.org/attachment.cgi?id=149174";
41 sha256 = "sha256-f1YIFIhWhXYVw3/UNEWewDak2mvbAd3aGzK4B+wTlys=";
45 outputs = [ "out" "dev" "man" "doc" ];
47 hardeningDisable = [ "pie" "stackprotector" ];
49 # GDB is needed to provide a sane default for `--db-command'.
50 # Perl is needed for `callgrind_{annotate,control}'.
51 buildInputs = [ gdb perl ] ++ lib.optionals (stdenv.isDarwin) [ bootstrap_cmds xnu ];
53 # Perl is also a native build input.
54 nativeBuildInputs = [ autoreconfHook perl ];
56 enableParallelBuilding = true;
57 separateDebugInfo = stdenv.isLinux;
59 preConfigure = lib.optionalString stdenv.isFreeBSD ''
60 substituteInPlace configure --replace '`uname -r`' \
61 ${toString stdenv.hostPlatform.parsed.kernel.version}.0-
62 '' + lib.optionalString stdenv.isDarwin (
64 $(awk -F '"' '/#define OSRELEASE/{ print $2 }' \
65 <${xnu}/Library/Frameworks/Kernel.framework/Headers/libkern/version.h)'';
67 echo "Don't derive our xnu version using uname -r."
68 substituteInPlace configure --replace "uname -r" "echo ${OSRELEASE}"
70 # Apple's GCC doesn't recognize `-arch' (as of version 4.2.1, build 5666).
71 echo "getting rid of the \`-arch' GCC option..."
72 find -name Makefile\* -exec \
73 sed -i {} -e's/DARWIN\(.*\)-arch [^ ]\+/DARWIN\1/g' \;
75 sed -i coregrind/link_tool_exe_darwin.in \
76 -e 's/^my \$archstr = .*/my $archstr = "x86_64";/g'
78 substituteInPlace coregrind/m_debuginfo/readmacho.c \
79 --replace /usr/bin/dsymutil ${stdenv.cc.bintools.bintools}/bin/dsymutil
81 echo "substitute hardcoded /usr/bin/ld with ${cctools}/bin/ld"
82 substituteInPlace coregrind/link_tool_exe_darwin.in \
83 --replace /usr/bin/ld ${cctools}/bin/ld
87 lib.optional stdenv.hostPlatform.isx86_64 "--enable-only64bit"
88 ++ lib.optional stdenv.hostPlatform.isDarwin "--with-xcodedir=${xnu}/include";
93 for i in $out/libexec/valgrind/*.supp; do
94 substituteInPlace $i \
95 --replace 'obj:/lib' 'obj:*/lib' \
96 --replace 'obj:/usr/X11R6/lib' 'obj:*/lib' \
97 --replace 'obj:/usr/lib' 'obj:*/lib'
102 updateScript = writeScript "update-valgrind" ''
103 #!/usr/bin/env nix-shell
104 #!nix-shell -i bash -p curl pcre common-updater-scripts
108 # Expect the text in format of:
109 # 'Current release: <a href="/downloads/current.html#current">valgrind-3.19.0</a>'
110 new_version="$(curl -s https://valgrind.org/ |
111 pcregrep -o1 'Current release: .*>valgrind-([0-9.]+)</a>')"
112 update-source-version ${pname} "$new_version"
117 homepage = "http://www.valgrind.org/";
118 description = "Debugging and profiling tool suite";
121 Valgrind is an award-winning instrumentation framework for
122 building dynamic analysis tools. There are Valgrind tools that
123 can automatically detect many memory management and threading
124 bugs, and profile your programs in detail. You can also use
125 Valgrind to build new tools.
128 license = lib.licenses.gpl2Plus;
130 maintainers = [ lib.maintainers.eelco ];
131 platforms = with lib.platforms; lib.intersectLists
132 (x86 ++ power ++ s390x ++ armv7 ++ aarch64 ++ mips)
133 (darwin ++ freebsd ++ illumos ++ linux);
134 badPlatforms = [ lib.systems.inspect.platformPatterns.isStatic ];
135 broken = stdenv.isDarwin; # https://hydra.nixos.org/build/128521440/nixlog/2