nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 autoreconfHook,
7 perl,
8 gdb,
9 writeScript,
10}:
11
12stdenv.mkDerivation rec {
13 pname = "valgrind";
14 version = "3.25.1";
15
16 src = fetchurl {
17 url = "https://sourceware.org/pub/${pname}/${pname}-${version}.tar.bz2";
18 hash = "sha256-Yd640HJ7RcJo79wbO2yeZ5zZfL9e5LKNHerXyLeica8=";
19 };
20
21 patches = [
22 # Fix checks on Musl.
23 # https://bugs.kde.org/show_bug.cgi?id=453929
24 (fetchpatch {
25 url = "https://bugsfiles.kde.org/attachment.cgi?id=148912";
26 sha256 = "Za+7K93pgnuEUQ+jDItEzWlN0izhbynX2crSOXBBY/I=";
27 })
28 # Fix build on armv7l.
29 # see also https://bugs.kde.org/show_bug.cgi?id=454346
30 (fetchpatch {
31 url = "https://git.yoctoproject.org/poky/plain/meta/recipes-devtools/valgrind/valgrind/use-appropriate-march-mcpu-mfpu-for-ARM-test-apps.patch?id=b7a9250590a16f1bdc8c7b563da428df814d4292";
32 sha256 = "sha256-sBZzn98Sf/ETFv8ubivgA6Y6fBNcyR8beB3ICDAyAH0=";
33 })
34 ];
35
36 outputs = [
37 "out"
38 "dev"
39 "man"
40 "doc"
41 ];
42
43 hardeningDisable = [
44 "pie"
45 "stackprotector"
46 ];
47
48 # GDB is needed to provide a sane default for `--db-command'.
49 # Perl is needed for `callgrind_{annotate,control}'.
50 buildInputs = [
51 gdb
52 perl
53 ];
54
55 # Perl is also a native build input.
56 nativeBuildInputs = [
57 autoreconfHook
58 perl
59 ];
60
61 enableParallelBuilding = true;
62 separateDebugInfo = stdenv.hostPlatform.isLinux;
63
64 preConfigure = lib.optionalString stdenv.hostPlatform.isFreeBSD ''
65 substituteInPlace configure --replace-fail '`uname -r`' ${stdenv.cc.libc.version}-
66 '';
67
68 configureFlags = lib.optional stdenv.hostPlatform.isx86_64 "--enable-only64bit";
69
70 doCheck = true;
71
72 postInstall = ''
73 for i in $out/libexec/valgrind/*.supp; do
74 substituteInPlace $i \
75 --replace 'obj:/lib' 'obj:*/lib' \
76 --replace 'obj:/usr/X11R6/lib' 'obj:*/lib' \
77 --replace 'obj:/usr/lib' 'obj:*/lib'
78 done
79 '';
80
81 passthru = {
82 updateScript = writeScript "update-valgrind" ''
83 #!/usr/bin/env nix-shell
84 #!nix-shell -i bash -p curl pcre common-updater-scripts
85
86 set -eu -o pipefail
87
88 # Expect the text in format of:
89 # 'Current release: <a href="/downloads/current.html#current">valgrind-3.19.0</a>'
90 new_version="$(curl -s https://valgrind.org/ |
91 pcregrep -o1 'Current release: .*>valgrind-([0-9.]+)</a>')"
92 update-source-version ${pname} "$new_version"
93 '';
94 };
95
96 meta = {
97 homepage = "https://valgrind.org/";
98 description = "Debugging and profiling tool suite";
99
100 longDescription = ''
101 Valgrind is an award-winning instrumentation framework for
102 building dynamic analysis tools. There are Valgrind tools that
103 can automatically detect many memory management and threading
104 bugs, and profile your programs in detail. You can also use
105 Valgrind to build new tools.
106 '';
107
108 license = lib.licenses.gpl2Plus;
109
110 maintainers = [ lib.maintainers.eelco ];
111 platforms =
112 with lib.platforms;
113 lib.intersectLists (x86 ++ power ++ s390x ++ armv7 ++ aarch64 ++ mips ++ riscv64) (
114 darwin ++ freebsd ++ illumos ++ linux
115 );
116 badPlatforms = [ lib.systems.inspect.platformPatterns.isStatic ];
117 # See: <https://hydra.nixos.org/build/128521440/nixlog/2>
118 #
119 # Darwin‐specific derivation logic has been removed, check the
120 # history if you want to fix this.
121 broken = stdenv.hostPlatform.isDarwin;
122 };
123}