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>
10 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
37 (define-public 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.
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")))
51 "18l5jbk301j3462gipqn9bkfx44mdmwn0pwr73r40gl1irkfqfmd"))
52 (patches (search-patches "valgrind-enable-arm.patch"))))
53 (build-system gnu-build-system)
54 (outputs '("doc" ;16 MB
57 `(,@(if (string-prefix? "powerpc" (or (%current-target-system)
59 `(#:make-flags '("CFLAGS+=-maltivec"))
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"))
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"))))
78 (rename-file orig dest)
82 (home-page "https://www.valgrind.org/")
83 (synopsis "Debugging and profiling tool suite")
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))
93 ;; Hide this variant so end users get the "interactive" Valgrind below.
94 (properties '((hidden? . #t)))))
96 (define-public valgrind/interactive
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")))
108 "18l5jbk301j3462gipqn9bkfx44mdmwn0pwr73r40gl1irkfqfmd"))
109 (patches (search-patches
110 "valgrind-enable-arm.patch"
111 "valgrind-fix-default-debuginfo-path.patch"))))
113 ;; GDB is needed to provide a sane default for `--db-command'.
114 (list gdb `(,(canonical-package glibc) "debug")))
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
125 ;; TODO: Remove on the next rebuild cycle, when libc is not
126 ;; longer fully stripped.
128 (string-append (ungexp (this-package-input "glibc") "debug")
131 (substitute* '("coregrind/m_debuginfo/readelf.c"
132 "docs/xml/manual-core-adv.xml"
133 "docs/xml/manual-core.xml")
134 (("DEFAULT_DEBUGINFO_PATH")
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")
141 (+ (string-length libc-debug)
142 (string-length "/.build-id//.debug")
144 (substitute* '("coregrind/m_debuginfo/readelf.c")
145 (("DEBUGPATH_EXTRA_BYTES_2")
147 (+ (string-length libc-debug)
148 (string-length "/usr/lib/debug")
152 (define-public valgrind-3.18
154 (inherit valgrind/interactive)
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")))
164 "1xgph509i6adv9w2glviw3xrmlz0dssg8992hbvxsbkp7ahrm180"))))))