gnu: r-biocviews: Update to 1.64.1.
[jackhill/guix/guix.git] / gnu / packages / valgrind.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2022 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
5 ;;; Copyright © 2016, 2020, 2022 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2020 Marius Bakke <marius@gnu.org>
8 ;;; Copyright © 2022 Denis Carikli <GNUtoo@cyberdimension.org>
9 ;;;
10 ;;; This file is part of GNU Guix.
11 ;;;
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
16 ;;;
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
21 ;;;
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24
25 (define-module (gnu packages valgrind)
26 #:use-module (guix build-system gnu)
27 #:use-module (guix download)
28 #:use-module (guix gexp)
29 #:use-module (guix licenses)
30 #:use-module (guix packages)
31 #:use-module (guix utils)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages base)
34 #:use-module (gnu packages gdb)
35 #:use-module (gnu packages perl))
36
37 (define-public valgrind
38 (package
39 (name "valgrind")
40 ;; Note: check "guix refresh -l -e '(@ (gnu packages valgrind) valgrind)'"
41 ;; when updating this package to find which branch it should go to.
42 (version "3.17.0")
43 (source (origin
44 (method url-fetch)
45 (uri (list (string-append "https://sourceware.org/pub/valgrind"
46 "/valgrind-" version ".tar.bz2")
47 (string-append "ftp://sourceware.org/pub/valgrind"
48 "/valgrind-" version ".tar.bz2")))
49 (sha256
50 (base32
51 "18l5jbk301j3462gipqn9bkfx44mdmwn0pwr73r40gl1irkfqfmd"))
52 (patches (search-patches "valgrind-enable-arm.patch"))))
53 (build-system gnu-build-system)
54 (outputs '("doc" ;16 MB
55 "out"))
56 (arguments
57 `(,@(if (string-prefix? "powerpc" (or (%current-target-system)
58 (%current-system)))
59 `(#:make-flags '("CFLAGS+=-maltivec"))
60 '())
61 #:phases
62 (modify-phases %standard-phases
63 (add-after 'install 'patch-suppression-files
64 (lambda* (#:key outputs #:allow-other-keys)
65 ;; Don't assume the FHS.
66 (let* ((out (assoc-ref outputs "out"))
67 (dir (string-append out "/lib/valgrind")))
68 (substitute* (find-files dir "\\.supp$")
69 (("obj:/lib") "obj:*/lib")
70 (("obj:/usr/X11R6/lib") "obj:*/lib")
71 (("obj:/usr/lib") "obj:*/lib"))
72 #t)))
73 (add-after 'install 'install-doc
74 (lambda* (#:key outputs #:allow-other-keys)
75 (let ((orig (format #f "~a/share/doc" (assoc-ref outputs "out")))
76 (dest (format #f "~a/share" (assoc-ref outputs "doc"))))
77 (mkdir-p dest)
78 (rename-file orig dest)
79 #t))))))
80 (native-inputs
81 (list perl))
82 (home-page "https://www.valgrind.org/")
83 (synopsis "Debugging and profiling tool suite")
84 (description
85 "Valgrind is an instrumentation framework for building dynamic analysis
86 tools. There are Valgrind tools that can automatically detect many memory
87 management and threading bugs, and profile your programs in detail. You can
88 also use Valgrind to build new tools.")
89 ;; https://valgrind.org/info/platforms.html
90 (supported-systems (delete "riscv64-linux" %supported-systems))
91 (license gpl2+)
92
93 ;; Hide this variant so end users get the "interactive" Valgrind below.
94 (properties '((hidden? . #t)))))
95
96 (define-public valgrind/interactive
97 (package/inherit
98 valgrind
99 (version "3.17.0")
100 (source (origin
101 (method url-fetch)
102 (uri (list (string-append "https://sourceware.org/pub/valgrind"
103 "/valgrind-" version ".tar.bz2")
104 (string-append "ftp://sourceware.org/pub/valgrind"
105 "/valgrind-" version ".tar.bz2")))
106 (sha256
107 (base32
108 "18l5jbk301j3462gipqn9bkfx44mdmwn0pwr73r40gl1irkfqfmd"))
109 (patches (search-patches
110 "valgrind-enable-arm.patch"
111 "valgrind-fix-default-debuginfo-path.patch"))))
112 (inputs
113 ;; GDB is needed to provide a sane default for `--db-command'.
114 (list gdb `(,(canonical-package glibc) "debug")))
115 (arguments
116 (substitute-keyword-arguments (package-arguments valgrind)
117 ((#:phases phases #~%standard-phases)
118 #~(modify-phases #$phases
119 (add-before 'configure 'patch-default-debuginfo-path
120 (lambda* (#:key inputs #:allow-other-keys)
121 ;; This helps Valgrind find the debug symbols of ld.so.
122 ;; Without it, Valgrind does not work in a Guix shell
123 ;; container and cannot be used as-is during packages tests
124 ;; phases.
125 ;; TODO: Remove on the next rebuild cycle, when libc is not
126 ;; longer fully stripped.
127 (define libc-debug
128 (string-append (ungexp (this-package-input "glibc") "debug")
129 "/lib/debug"))
130
131 (substitute* '("coregrind/m_debuginfo/readelf.c"
132 "docs/xml/manual-core-adv.xml"
133 "docs/xml/manual-core.xml")
134 (("DEFAULT_DEBUGINFO_PATH")
135 libc-debug))
136 ;; We also need to account for the bigger path in
137 ;; the malloc-ed variables.
138 (substitute* '("coregrind/m_debuginfo/readelf.c")
139 (("DEBUGPATH_EXTRA_BYTES_1")
140 (number->string
141 (+ (string-length libc-debug)
142 (string-length "/.build-id//.debug")
143 1))))
144 (substitute* '("coregrind/m_debuginfo/readelf.c")
145 (("DEBUGPATH_EXTRA_BYTES_2")
146 (number->string
147 (+ (string-length libc-debug)
148 (string-length "/usr/lib/debug")
149 1))))))))))
150 (properties '())))
151
152 (define-public valgrind-3.18
153 (package
154 (inherit valgrind/interactive)
155 (version "3.18.1")
156 (source (origin
157 (inherit (package-source valgrind/interactive))
158 (uri (list (string-append "https://sourceware.org/pub/valgrind"
159 "/valgrind-" version ".tar.bz2")
160 (string-append "ftp://sourceware.org/pub/valgrind"
161 "/valgrind-" version ".tar.bz2")))
162 (sha256
163 (base32
164 "1xgph509i6adv9w2glviw3xrmlz0dssg8992hbvxsbkp7ahrm180"))))))