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 sha256 = "sha256-3V40SG8aSD/3vnMAzBa01rJGkJh4d8MnjXl1NNZzjwI=";
18 # https://bugs.kde.org/show_bug.cgi?id=453929
20 url = "https://bugsfiles.kde.org/attachment.cgi?id=148912";
21 sha256 = "Za+7K93pgnuEUQ+jDItEzWlN0izhbynX2crSOXBBY/I=";
23 # Fix build on armv7l.
24 # https://bugs.kde.org/show_bug.cgi?id=454346
26 url = "https://bugsfiles.kde.org/attachment.cgi?id=149172";
27 sha256 = "sha256-4MASLsEK8wcshboR4YOc6mIt7AvAgDPvqIZyHqlvTEs=";
30 url = "https://bugsfiles.kde.org/attachment.cgi?id=149173";
31 sha256 = "sha256-jX9hD4utWRebbXMJYZ5mu9jecvdrNP05E5J+PnKRTyQ=";
34 url = "https://bugsfiles.kde.org/attachment.cgi?id=149174";
35 sha256 = "sha256-f1YIFIhWhXYVw3/UNEWewDak2mvbAd3aGzK4B+wTlys=";
39 outputs = [ "out" "dev" "man" "doc" ];
41 hardeningDisable = [ "pie" "stackprotector" ];
43 # GDB is needed to provide a sane default for `--db-command'.
44 # Perl is needed for `callgrind_{annotate,control}'.
45 buildInputs = [ gdb perl ] ++ lib.optionals (stdenv.isDarwin) [ bootstrap_cmds xnu ];
47 # Perl is also a native build input.
48 nativeBuildInputs = [ autoreconfHook perl ];
50 enableParallelBuilding = true;
51 separateDebugInfo = stdenv.isLinux;
53 preConfigure = lib.optionalString stdenv.isDarwin (
55 $(awk -F '"' '/#define OSRELEASE/{ print $2 }' \
56 <${xnu}/Library/Frameworks/Kernel.framework/Headers/libkern/version.h)'';
58 echo "Don't derive our xnu version using uname -r."
59 substituteInPlace configure --replace "uname -r" "echo ${OSRELEASE}"
61 # Apple's GCC doesn't recognize `-arch' (as of version 4.2.1, build 5666).
62 echo "getting rid of the \`-arch' GCC option..."
63 find -name Makefile\* -exec \
64 sed -i {} -e's/DARWIN\(.*\)-arch [^ ]\+/DARWIN\1/g' \;
66 sed -i coregrind/link_tool_exe_darwin.in \
67 -e 's/^my \$archstr = .*/my $archstr = "x86_64";/g'
69 substituteInPlace coregrind/m_debuginfo/readmacho.c \
70 --replace /usr/bin/dsymutil ${stdenv.cc.bintools.bintools}/bin/dsymutil
72 echo "substitute hardcoded /usr/bin/ld with ${cctools}/bin/ld"
73 substituteInPlace coregrind/link_tool_exe_darwin.in \
74 --replace /usr/bin/ld ${cctools}/bin/ld
78 lib.optional (stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "x86_64-darwin") "--enable-only64bit"
79 ++ lib.optional stdenv.hostPlatform.isDarwin "--with-xcodedir=${xnu}/include";
84 for i in $out/libexec/valgrind/*.supp; do
85 substituteInPlace $i \
86 --replace 'obj:/lib' 'obj:*/lib' \
87 --replace 'obj:/usr/X11R6/lib' 'obj:*/lib' \
88 --replace 'obj:/usr/lib' 'obj:*/lib'
93 updateScript = writeScript "update-valgrind" ''
94 #!/usr/bin/env nix-shell
95 #!nix-shell -i bash -p curl pcre common-updater-scripts
99 # Expect the text in format of:
100 # 'Current release: <a href="/downloads/current.html#current">valgrind-3.19.0</a>'
101 new_version="$(curl -s https://valgrind.org/ |
102 pcregrep -o1 'Current release: .*>valgrind-([0-9.]+)</a>')"
103 update-source-version ${pname} "$new_version"
108 homepage = "http://www.valgrind.org/";
109 description = "Debugging and profiling tool suite";
112 Valgrind is an award-winning instrumentation framework for
113 building dynamic analysis tools. There are Valgrind tools that
114 can automatically detect many memory management and threading
115 bugs, and profile your programs in detail. You can also use
116 Valgrind to build new tools.
119 license = lib.licenses.gpl2Plus;
121 maintainers = [ lib.maintainers.eelco ];
122 platforms = lib.platforms.unix;
124 "armv5tel-linux" "armv6l-linux" "armv6m-linux"
125 "sparc-linux" "sparc64-linux"
126 "riscv32-linux" "riscv64-linux"
129 broken = stdenv.isDarwin || stdenv.hostPlatform.isStatic; # https://hydra.nixos.org/build/128521440/nixlog/2