summary refs log tree commit diff
path: root/pkgs/development/tools/analysis/valgrind/default.nix
blob: 4592c1bb53f185af77ed4265fbe2bc469478e45a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{ stdenv, fetchurl, perl, gdb }:

stdenv.mkDerivation (rec {
  name = "valgrind-3.8.1";

  src = fetchurl {
    url = "http://valgrind.org/downloads/${name}.tar.bz2";
    sha256 = "1nsqk70ry3221sd62s4f0njcrncppszs4xxjcak13lxyfq2y0fs7";
  };

  patches = [ ./glibc-2.17.patch ];

  # Perl is needed for `cg_annotate'.
  # GDB is needed to provide a sane default for `--db-command'.
  nativeBuildInputs = [ perl ];
  buildInputs = stdenv.lib.optional (!stdenv.isDarwin) gdb;

  configureFlags =
    if (stdenv.system == "x86_64-linux" || stdenv.system == "x86_64-darwin")
    then [ "--enable-only64bit" ]
    else [];

  postInstall = ''
    for i in $out/lib/valgrind/*.supp; do
      substituteInPlace $i \
        --replace 'obj:/lib' 'obj:*/lib' \
        --replace 'obj:/usr/X11R6/lib' 'obj:*/lib' \
        --replace 'obj:/usr/lib' 'obj:*/lib'
    done
  '';

  meta = {
    homepage = http://www.valgrind.org/;
    description = "Valgrind, a debugging and profiling tool suite";

    longDescription = ''
      Valgrind is an award-winning instrumentation framework for
      building dynamic analysis tools.  There are Valgrind tools that
      can automatically detect many memory management and threading
      bugs, and profile your programs in detail.  You can also use
      Valgrind to build new tools.
    '';

    license = "GPLv2+";

    maintainers = with stdenv.lib.maintainers; [ eelco ];
    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
  };
}

//

(if stdenv.isDarwin
 then {
   patchPhase =
     # Apple's GCC doesn't recognize `-arch' (as of version 4.2.1, build 5666).
     '' echo "getting rid of the \`-arch' GCC option..."
        find -name Makefile\* -exec \
          sed -i {} -e's/DARWIN\(.*\)-arch [^ ]\+/DARWIN\1/g' \;

        sed -i coregrind/link_tool_exe_darwin.in \
            -e 's/^my \$archstr = .*/my $archstr = "x86_64";/g'
     '';
 }
 else {}))