unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Cc: 54728-done@debbugs.gnu.org, maximedevos@telenet.be
Subject: bug#54728: Valgrind not working out of the box due to stripped ld.so
Date: Mon, 09 May 2022 11:24:44 +0200	[thread overview]
Message-ID: <87czgnrrc3.fsf_-_@gnu.org> (raw)
In-Reply-To: <20220426013913.20117-3-GNUtoo@cyberdimension.org> (Denis Carikli's message of "Tue, 26 Apr 2022 03:39:13 +0200")

[-- Attachment #1: Type: text/plain, Size: 916 bytes --]

Hi Denis,

Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> skribis:

> * gnu/packages/valgrind.scm (valgrind/interactive)[native-inputs]:
>   Add libc:debug
>   [arguments]: Add patch-default-debuginfo-path phase
>   [source]: Add patch.
>   (valgrind-3.18)[source]: Add patch.
>
> * gnu/packages/commencement.scm (glibc-final): Export variable.
>
> Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>

I had lost track of it, so thanks for pinging.

I’ve applied it and confirmed it works.  I made the following cosmetic
changes (patch below):

  • removing the ‘glibc-final’ export, which is unnecessary;

  • in phases, refer to the ‘inputs’ parameter rather than the
    ‘%build-inputs’ global variable (which is deprecated);

  • avoid repetition of (string-append (assoc-ref …) "/lib/debug");

  • tweak indentation.

Thanks!

Ludo’.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 6813 bytes --]

diff --git a/gnu/packages/valgrind.scm b/gnu/packages/valgrind.scm
index 1269e07593..0da011087c 100644
--- a/gnu/packages/valgrind.scm
+++ b/gnu/packages/valgrind.scm
@@ -95,83 +95,71 @@ (define-public valgrind
 
 (define-public valgrind/interactive
   (package/inherit
-   valgrind
-   (version "3.17.0")
-   (source (origin
-             (method url-fetch)
-             (uri (list (string-append "https://sourceware.org/pub/valgrind"
-                                       "/valgrind-" version ".tar.bz2")
-                        (string-append "ftp://sourceware.org/pub/valgrind"
-                                       "/valgrind-" version ".tar.bz2")))
-             (sha256
-              (base32
-               "18l5jbk301j3462gipqn9bkfx44mdmwn0pwr73r40gl1irkfqfmd"))
-             (patches (search-patches
-                       "valgrind-enable-arm.patch"
-                       "valgrind-fix-default-debuginfo-path.patch"))))
-   (inputs
-    ;; GDB is needed to provide a sane default for `--db-command'.
-    `(("gdb" ,gdb)
-      ("glibc:debug" ,(canonical-package glibc) "debug")))
-   (arguments
+      valgrind
+    (version "3.17.0")
+    (source (origin
+              (method url-fetch)
+              (uri (list (string-append "https://sourceware.org/pub/valgrind"
+                                        "/valgrind-" version ".tar.bz2")
+                         (string-append "ftp://sourceware.org/pub/valgrind"
+                                        "/valgrind-" version ".tar.bz2")))
+              (sha256
+               (base32
+                "18l5jbk301j3462gipqn9bkfx44mdmwn0pwr73r40gl1irkfqfmd"))
+              (patches (search-patches
+                        "valgrind-enable-arm.patch"
+                        "valgrind-fix-default-debuginfo-path.patch"))))
+    (inputs
+     ;; GDB is needed to provide a sane default for `--db-command'.
+     `(("gdb" ,gdb)
+       ("glibc:debug" ,(canonical-package glibc) "debug")))
+    (arguments
      (substitute-keyword-arguments (package-arguments valgrind)
-       ((#:phases those-phases #~%standard-phases)
-        #~(let* ((those-phases #$those-phases)
-                 (unpack (assoc-ref those-phases 'unpack)))
-            (modify-phases
-              those-phases
-                (add-before 'configure 'patch-default-debuginfo-path
-                  (lambda _
-                    ;; This helps Valgrind find the debug symbols of ld.so.
-                    ;; Without it, Valgrind does not work in a Guix shell
-                    ;; container and cannot be used as-is during packages tests
-                    ;; phases
-                    (substitute* '
-                      ("coregrind/m_debuginfo/readelf.c"
-                       "docs/xml/manual-core-adv.xml"
-                       "docs/xml/manual-core.xml")
-                      (("DEFAULT_DEBUGINFO_PATH")
-                       (string-append (assoc-ref %build-inputs "glibc:debug")
-                                      "/lib/debug")))
-                    ;; We also need to account for the bigger path in
-                    ;; the malloc-ed variables
-                    (substitute* '
-                     ("coregrind/m_debuginfo/readelf.c")
-                     (("DEBUGPATH_EXTRA_BYTES_1")
-                      (number->string
-                       (+ (string-length
-                           (string-append
-                            (assoc-ref %build-inputs "glibc:debug")
-                            "/lib/debug"))
-                          (string-length "/.build-id//.debug")
-                          1))))
-                    (substitute* '
-                     ("coregrind/m_debuginfo/readelf.c")
-                     (("DEBUGPATH_EXTRA_BYTES_2")
-                      (number->string
-                       (+ (string-length
-                           (string-append
-                            (assoc-ref
-                             %build-inputs
-                             "glibc:debug")
-                            "/lib/debug"))
-                          (string-length
-                           "/usr/lib/debug")
-                          1)))))))))))
-   (properties '())))
+       ((#:phases phases #~%standard-phases)
+        #~(modify-phases #$phases
+            (add-before 'configure 'patch-default-debuginfo-path
+              (lambda* (#:key inputs #:allow-other-keys)
+                ;; This helps Valgrind find the debug symbols of ld.so.
+                ;; Without it, Valgrind does not work in a Guix shell
+                ;; container and cannot be used as-is during packages tests
+                ;; phases.
+                ;; TODO: Remove on the next rebuild cycle, when libc is not
+                ;; longer fully stripped.
+                (define libc-debug
+                  (string-append (assoc-ref inputs "glibc:debug")
+                                 "/lib/debug"))
+
+                (substitute* '("coregrind/m_debuginfo/readelf.c"
+                               "docs/xml/manual-core-adv.xml"
+                               "docs/xml/manual-core.xml")
+                  (("DEFAULT_DEBUGINFO_PATH")
+                   libc-debug))
+                ;; We also need to account for the bigger path in
+                ;; the malloc-ed variables.
+                (substitute* '("coregrind/m_debuginfo/readelf.c")
+                  (("DEBUGPATH_EXTRA_BYTES_1")
+                   (number->string
+                    (+ (string-length libc-debug)
+                       (string-length "/.build-id//.debug")
+                       1))))
+                (substitute* '("coregrind/m_debuginfo/readelf.c")
+                  (("DEBUGPATH_EXTRA_BYTES_2")
+                   (number->string
+                    (+ (string-length libc-debug)
+                       (string-length "/usr/lib/debug")
+                       1))))))))))
+    (properties '())))
 
 (define-public valgrind-3.18
   (package
     (inherit valgrind/interactive)
     (version "3.18.1")
     (source (origin
-              (method url-fetch)
+              (inherit (package-source valgrind/interactive))
               (uri (list (string-append "https://sourceware.org/pub/valgrind"
                                         "/valgrind-" version ".tar.bz2")
                          (string-append "ftp://sourceware.org/pub/valgrind"
                                         "/valgrind-" version ".tar.bz2")))
               (sha256
                (base32
-                "1xgph509i6adv9w2glviw3xrmlz0dssg8992hbvxsbkp7ahrm180"))
-              (patches (search-patches "valgrind-enable-arm.patch"
-                                       "valgrind-fix-default-debuginfo-path.patch"))))))
+                "1xgph509i6adv9w2glviw3xrmlz0dssg8992hbvxsbkp7ahrm180"))))))

      parent reply	other threads:[~2022-05-09  9:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05 15:01 bug#54728: Valgrind not working out of the box due to stripped ld.so Denis 'GNUtoo' Carikli
2022-04-07 16:40 ` Ludovic Courtès
2022-04-14 23:26   ` Denis 'GNUtoo' Carikli
2022-04-14 23:30     ` bug#54728: [PATCH 1/2] gnu: valgrind: impots: sort imports alphabetically Denis 'GNUtoo' Carikli
2022-04-14 23:30       ` bug#54728: [PATCH 2/2] gnu: valgrind: fix ld.so symbols not found Denis 'GNUtoo' Carikli
2022-04-15 16:21         ` Ludovic Courtès
2022-04-25 16:39           ` Denis 'GNUtoo' Carikli
2022-04-25 17:41             ` Maxime Devos
2022-04-26  1:39               ` Denis 'GNUtoo' Carikli
2022-04-26  1:39                 ` bug#54728: [PATCH v2 1/2] gnu: valgrind: impots: sort imports alphabetically Denis 'GNUtoo' Carikli
2022-04-26  1:39                 ` bug#54728: [PATCH v2 2/2] gnu: valgrind: fix ld.so symbols not found Denis 'GNUtoo' Carikli
2022-04-26 22:37                   ` Denis 'GNUtoo' Carikli
2022-05-06 20:16                     ` Denis 'GNUtoo' Carikli
2022-05-06 20:20                       ` Maxime Devos
2022-05-09  9:24                   ` Ludovic Courtès [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87czgnrrc3.fsf_-_@gnu.org \
    --to=ludo@gnu.org \
    --cc=54728-done@debbugs.gnu.org \
    --cc=GNUtoo@cyberdimension.org \
    --cc=maximedevos@telenet.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).