all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#54728: Valgrind not working out of the box due to stripped ld.so
@ 2022-04-05 15:01 Denis 'GNUtoo' Carikli
  2022-04-07 16:40 ` Ludovic Courtès
  0 siblings, 1 reply; 15+ messages in thread
From: Denis 'GNUtoo' Carikli @ 2022-04-05 15:01 UTC (permalink / raw)
  To: 54728

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

Hi,

The fact that Valgrind doesn't work out of the box seems to already be
known[1] but I didn't find any bugreports on it.

The workaround[1] mentioned is extremely useful but it's far from ideal.

For instance if you have a software that uses Valgrind in its tests
(for instance in 'make check') you end up having to add something like
that in the native-inputs to refer to the right glibc debug symbols
directory:
> ("libc:debug", (@@ (gnu packages commencement) glibc-final) "debug")

In my case I'm using guix and a guix.scm for testing the build of a
library I maintain and I also wanted to automatically check for memory
safety.

I was helped a lot on #guix to solve the issue I had, and during that
mjw suggested to fix the root issue by keeping "the .symtab in ld.so"
without the full debug info (to save space) and if I understood right
mjw is a valgrind contributor.

According to mjw that could be done with strip -g or strip -d or -strip
-S.

Reference:
----------
[1]https://lists.gnu.org/archive/html/help-guix/2022-03/msg00036.html

Denis.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#54728: Valgrind not working out of the box due to stripped ld.so
  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
  0 siblings, 1 reply; 15+ messages in thread
From: Ludovic Courtès @ 2022-04-07 16:40 UTC (permalink / raw)
  To: Denis 'GNUtoo' Carikli; +Cc: 54728

Hi,

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

> The fact that Valgrind doesn't work out of the box seems to already be
> known[1] but I didn't find any bugreports on it.

Indeed.  Fixed in 6b6fb78724869c03394d0e6dc2f50f0777f6d467 on
‘core-updates’ as discussed with Mark (mjw) a couple of days ago on IRC.

Unfortunately, until that branch is merge (most likely a few months from
now), we’ll have to use the workaround you mentioned.

Alternatively, maybe we could temporarily patch the ‘valgrind’ package
such that it has ‘--extra-debuginfo-path=…’ by default.  Would you like
to give it a try?

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#54728: Valgrind not working out of the box due to stripped ld.so
  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
  0 siblings, 1 reply; 15+ messages in thread
From: Denis 'GNUtoo' Carikli @ 2022-04-14 23:26 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 54728


[-- Attachment #1.1: Type: text/plain, Size: 1899 bytes --]

On Thu, 07 Apr 2022 18:40:08 +0200
Ludovic Courtès <ludo@gnu.org> wrote:

> Hi,
Hi,

> Unfortunately, until that branch is merge (most likely a few months
> from now), we’ll have to use the workaround you mentioned.
> 
> Alternatively, maybe we could temporarily patch the ‘valgrind’ package
> such that it has ‘--extra-debuginfo-path=…’ by default.  Would you
> like to give it a try?
That is a good idea. As I need it anyway[1], I've actually worked on
doing that through patching Valgrind source code to use better defaults
than /usr/lib/debug but there is a couple of things I'm unsure with my
patch:
- First it works fine in 'guix shell -C' but it still fails
  in packages. Maybe I didn't patch the right Valgrind?

- Then for some reasons guix style messes up the whitespaces with the
  following command:
  $ ./pre-inst-env guix style -e \
    '(@@ (gnu packages valgrind) valgrind/interactive)';
  So I did the style by hand instead, so it might contain mistakes.

- And finally I'm not comfortable enough with Valgrind or how it's been
  used in Guix. As I understand from the comment in the first Valgrind
  being defined in valgrind.scm, it seems to be depended on by a lot of
  packages. In addition I've not looked why there is a
  valgrind/interactive or how it works yet, so someone would need to
  double check my patch carefuly.

I've attached a libsamsung-ipc.scm file as I used that for testing my
patch (in addition of just running Valgrind in a Guix shell container
and while building this package it fails.

I'll send the patch as a response to this mail.

References:
-----------
[1] At the end of the day I need it to work in both standalone mode and
    also in package builds as I use a guix.scm to run various
    compilation and runtime for libsamsung-ipc before pushing patches
    to the main branch.

Denis.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: libsamsung-ipc.scm --]
[-- Type: text/x-scheme, Size: 4364 bytes --]

;;; Copyright © 2022 Denis Carikli <GNUtoo@cyberdimension.org>
;;;
;;; This file is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; This file is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License.
;;; If not, see <http://www.gnu.org/licenses/>.
;;;
;;; This file is meant to test valgrind support in Guix.
;;;
;;; The libsamsung-ipc library is not ready to be packaged in general
;;; purpose distributions as right now as it requires either a vendor
;;; kernel or the compbinaison of a recent upstream kernel with on top
;;; work in progress out of tree modem drivers, out of tree
;;; libsamsung-ipc code to support theses drivers and kernel patches
;;; to support the nonfree bootloader of the Galaxy SIII
;;; (GT-I9300). Beside the library, the tools are of very limited use
;;; beside testing or reverse engineering.

(use-modules
 (ice-9 popen)
 (ice-9 rdelim)
 (sxml ssax input-parse)
 ((guix licenses) #:prefix license:)
 (guix build-system android-ndk)
 (guix build-system gnu)
 (guix gexp)
 (guix git-download)
 (guix packages)
 (gnu packages android)
 (gnu packages autotools)
 (gnu packages commencement)
 (gnu packages curl)
 (gnu packages disk)
 (gnu packages linux)
 (gnu packages llvm)
 (gnu packages pkg-config)
 (gnu packages python)
 (gnu packages python-xyz)
 (gnu packages tls)
 (gnu packages valgrind))

(define-public libsamsung-ipc
  (package
    (name "libsamsung-ipc")
    ;; we use a work in progress version that has support for --with-valgrind-tests
    (version (git-version "0.0" "HEAD" "4d3062db15783c188d6952f7b9b794b65cd93f66"))
    (source
     (origin
       (method git-fetch)
       (uri
        (git-reference
         (url "https://git.replicant.us/replicant-next/hardware_replicant_libsamsung-ipc")
         (commit "4d3062db15783c188d6952f7b9b794b65cd93f66")))
       (sha256
        (base32 "1jzv9z5rkgcx394akf2svja586z54vhd46pvdmzm3ilmspnvjcdx"))
       (file-name (git-file-name name version))))
    (build-system gnu-build-system)
    (native-inputs
     `(("autoreconf" ,autoconf)
       ("aclocal" ,automake)
       ("libcurl" ,curl)
       ("ddrescue", ddrescue)
       ;; ("libc:debug", (@@ (gnu packages commencement) glibc-final) "debug")
       ("libtool" ,libtool)
       ("pkgconfig" ,pkg-config)
       ("python" ,python)
       ("python-sh" ,python-sh)
       ("valgrind" ,valgrind)))
    (inputs
     `(("openssl" ,openssl)))
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'build 'patch-python
           (lambda _
             (substitute* (find-files "." ".*\\.py$")
               (("/usr/bin/env python") (which "python3")))
           #t))
         (add-after 'patch-python 'fix-valgrind
           (lambda _
             (substitute* (find-files "." ".*\\.py$")
                          (("'--leak-check=full',")
                            "'-v', '--leak-check=full',"))
             #t))
         ;; (add-after 'patch-python 'fix-valgrind
         ;;   (lambda _
         ;;     (substitute* (find-files "." ".*\\.py$")
         ;;                  (("'--leak-check=full',")
         ;;                   (string-append
         ;;                    "'--leak-check=full', '--extra-debuginfo-path="
         ;;                    (assoc-ref %build-inputs "libc:debug")
         ;;                    "/lib/debug',")))
         ;;     #t))
	 )
       #:configure-flags
       (list "--enable-debug"
             "--enable-valgrind-tests")))
    (synopsis "libsamsung-ipc is a free software implementation of the Samsung IPC modem protocol")
    (description
     "libsamsung-ipc is a free software implementation of the Samsung IPC modem protocol,
found in many Samsung smartphones and tablets.")
    (home-page "https://www.replicant.us")
    (license license:gpl2+)))

(list libsamsung-ipc)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#54728: [PATCH 1/2] gnu: valgrind: impots: sort imports alphabetically
  2022-04-14 23:26   ` Denis 'GNUtoo' Carikli
@ 2022-04-14 23:30     ` Denis 'GNUtoo' Carikli
  2022-04-14 23:30       ` bug#54728: [PATCH 2/2] gnu: valgrind: fix ld.so symbols not found Denis 'GNUtoo' Carikli
  0 siblings, 1 reply; 15+ messages in thread
From: Denis 'GNUtoo' Carikli @ 2022-04-14 23:30 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Denis 'GNUtoo' Carikli, 54728

* gnu/packages/valgrind.scm: sort imports alphabetically

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
---
 gnu/packages/valgrind.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/valgrind.scm b/gnu/packages/valgrind.scm
index 1cdc0f3b71..6648f17dfa 100644
--- a/gnu/packages/valgrind.scm
+++ b/gnu/packages/valgrind.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2016, 2020, 2022 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2020 Marius Bakke <marius@gnu.org>
+;;; Copyright © 2022 Denis Carikli <GNUtoo@cyberdimension.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -22,13 +23,13 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages valgrind)
-  #:use-module (guix packages)
-  #:use-module (guix download)
   #:use-module (guix build-system gnu)
+  #:use-module (guix download)
   #:use-module (guix licenses)
+  #:use-module (guix packages)
+  #:use-module (gnu packages)
   #:use-module (gnu packages gdb)
-  #:use-module (gnu packages perl)
-  #:use-module (gnu packages))
+  #:use-module (gnu packages perl))
 
 (define-public valgrind
   (package
-- 
2.35.1





^ permalink raw reply related	[flat|nested] 15+ messages in thread

* bug#54728: [PATCH 2/2] gnu: valgrind: fix ld.so symbols not found
  2022-04-14 23:30     ` bug#54728: [PATCH 1/2] gnu: valgrind: impots: sort imports alphabetically Denis 'GNUtoo' Carikli
@ 2022-04-14 23:30       ` Denis 'GNUtoo' Carikli
  2022-04-15 16:21         ` Ludovic Courtès
  0 siblings, 1 reply; 15+ messages in thread
From: Denis 'GNUtoo' Carikli @ 2022-04-14 23:30 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Denis 'GNUtoo' Carikli, 54728

* gnu/packages/valgrind.scm (valgrind/interactive)[native-inputs]:
  Add libc:debug
  [arguments]: Add patch-default-debuginfo-path phase
* gnu/packages/commencement.scm (glibc-final): Export variable.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
---
 gnu/packages/commencement.scm |  2 +-
 gnu/packages/valgrind.scm     | 66 +++++++++++++++++++++++++++++++----
 2 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index e8b47fbeab..c2de02411c 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -3381,7 +3381,7 @@ (define gettext-boot0
                         (("^PROGRAMS =.*$")
                          "PROGRAMS =\n")))))))))
 
-(define glibc-final
+(define-public glibc-final
   ;; The final glibc, which embeds the statically-linked Bash built above.
   ;; Use 'package/inherit' so we get the 'replacement' of 'glibc', if any.
   (package/inherit
diff --git a/gnu/packages/valgrind.scm b/gnu/packages/valgrind.scm
index 6648f17dfa..a09721071d 100644
--- a/gnu/packages/valgrind.scm
+++ b/gnu/packages/valgrind.scm
@@ -25,8 +25,10 @@
 (define-module (gnu packages valgrind)
   #:use-module (guix build-system gnu)
   #:use-module (guix download)
+  #:use-module (guix gexp)
   #:use-module (guix licenses)
   #:use-module (guix packages)
+  #:use-module (guix utils)
   #:use-module (gnu packages)
   #:use-module (gnu packages gdb)
   #:use-module (gnu packages perl))
@@ -91,12 +93,64 @@ (define-public valgrind
     (properties '((hidden? . #t)))))
 
 (define-public valgrind/interactive
-  (package/inherit
-   valgrind
-   (inputs
-    ;; GDB is needed to provide a sane default for `--db-command'.
-    `(("gdb" ,gdb)))
-   (properties '())))
+  (package/inherit valgrind
+    (inputs
+     ;; GDB is needed to provide a sane default for `--db-command'.
+     `(("gdb" ,gdb)
+       ("libc:debug" ,(@@ (gnu packages commencement) glibc-final) "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 'build '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")
+                    (("/usr/lib/debug")
+                     (string-append
+                       (assoc-ref %build-inputs "libc:debug")
+                       "/lib/debug")))
+                  ;; We also need to account for the bigger path in
+                  ;; the malloc-ed variables
+                  (substitute* '
+                    ("coregrind/m_debuginfo/readelf.c")
+                    (("VG_\\(strlen\\)\\(buildid\\) \\+ 33")
+                      (string-append
+                        "VG_(strlen)(buildid) + "
+                        (number->string
+                         (+ (string-length
+                            (string-append
+                              (assoc-ref %build-inputs "libc:debug")
+                              "/lib/debug"))
+                            (string-length "/.build-id//.debug")
+                            1)))))
+                  (substitute* '
+                    ("coregrind/m_debuginfo/readelf.c")
+                    ((string-append
+                      "VG_\\(strlen\\)\\(objdir\\) \\+ "
+                      "VG_\\(strlen\\)\\(debugname\\) \\+ 64")
+                     (string-append
+                      "VG_(strlen)(objdir) + VG_(strlen)(debugname) + "
+                      (number->string
+                        (+ (string-length
+                            (string-append
+                             (assoc-ref
+                              %build-inputs
+                              "libc:debug")
+                             "/lib/debug"))
+                           (string-length
+                            "/usr/lib/debug")
+                           1)))))
+                  #t)))))))
+    (properties '())))
 
 (define-public valgrind-3.18
   (package
-- 
2.35.1





^ permalink raw reply related	[flat|nested] 15+ messages in thread

* bug#54728: [PATCH 2/2] gnu: valgrind: fix ld.so symbols not found
  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
  0 siblings, 1 reply; 15+ messages in thread
From: Ludovic Courtès @ 2022-04-15 16:21 UTC (permalink / raw)
  To: Denis 'GNUtoo' Carikli; +Cc: 54728

Hello!

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

>  (define-public valgrind/interactive
> -  (package/inherit
> -   valgrind
> -   (inputs
> -    ;; GDB is needed to provide a sane default for `--db-command'.
> -    `(("gdb" ,gdb)))
> -   (properties '())))
> +  (package/inherit valgrind
> +    (inputs
> +     ;; GDB is needed to provide a sane default for `--db-command'.
> +     `(("gdb" ,gdb)
> +       ("libc:debug" ,(@@ (gnu packages commencement) glibc-final) "debug")))

Rather: ("libc: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 'build '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")
> +                    (("/usr/lib/debug")
> +                     (string-append
> +                       (assoc-ref %build-inputs "libc:debug")
> +                       "/lib/debug")))
> +                  ;; We also need to account for the bigger path in
> +                  ;; the malloc-ed variables
> +                  (substitute* '
> +                    ("coregrind/m_debuginfo/readelf.c")
> +                    (("VG_\\(strlen\\)\\(buildid\\) \\+ 33")
> +                      (string-append
> +                        "VG_(strlen)(buildid) + "
> +                        (number->string
> +                         (+ (string-length
> +                            (string-append
> +                              (assoc-ref %build-inputs "libc:debug")
> +                              "/lib/debug"))
> +                            (string-length "/.build-id//.debug")
> +                            1)))))
> +                  (substitute* '
> +                    ("coregrind/m_debuginfo/readelf.c")
> +                    ((string-append
> +                      "VG_\\(strlen\\)\\(objdir\\) \\+ "
> +                      "VG_\\(strlen\\)\\(debugname\\) \\+ 64")
> +                     (string-append
> +                      "VG_(strlen)(objdir) + VG_(strlen)(debugname) + "
> +                      (number->string
> +                        (+ (string-length
> +                            (string-append
> +                             (assoc-ref
> +                              %build-inputs
> +                              "libc:debug")
> +                             "/lib/debug"))
> +                           (string-length
> +                            "/usr/lib/debug")
> +                           1)))))

I find this patch-as-code snippet rather difficult to follow; it might
also break easily if minor things change in those C files.

How about making it an actual patch?  In the patch, you’d have
placeholders for the store file names, like @LIBC_DEBUG_DIRECTORY@; the
phase would replace those placeholders with ‘substitute*’.

How does that sound?

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#54728: [PATCH 2/2] gnu: valgrind: fix ld.so symbols not found
  2022-04-15 16:21         ` Ludovic Courtès
@ 2022-04-25 16:39           ` Denis 'GNUtoo' Carikli
  2022-04-25 17:41             ` Maxime Devos
  0 siblings, 1 reply; 15+ messages in thread
From: Denis 'GNUtoo' Carikli @ 2022-04-25 16:39 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 54728

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

On Fri, 15 Apr 2022 18:21:33 +0200
Ludovic Courtès <ludo@gnu.org> wrote:
> Hello!
Hi,

[...]
> I find this patch-as-code snippet rather difficult to follow; it might
> also break easily if minor things change in those C files.
> 
> How about making it an actual patch?  In the patch, you’d have
> placeholders for the store file names, like @LIBC_DEBUG_DIRECTORY@;
> the phase would replace those placeholders with ‘substitute*’.
Thanks, I've done that and now the code is much easier to read.

> Rather: ("libc:debug" ,(canonical-package glibc) "debug").
The issue with that is that importing "gnu packages commencement" fails
with the following error:
> $ ./pre-inst-env guix build hello
> error: tcc: unbound variable
> hint: Did you forget a `use-modules' form?
> 
> error: googletest: unbound variable
> hint: Did you forget a `use-modules' form?
> 
> error: bzip2: unbound variable
> hint: Did you forget a `use-modules' form?
> 
> error: binutils: unbound variable
> hint: Did you forget a `use-modules' form?
> 
> error: gcc-4.9: unbound variable
> hint: Did you forget a `use-modules' form?
> 
> error: xz: unbound variable
> hint: Did you forget a `use-modules' form?
> 
> error: gnu-make: unbound variable
> hint: Did you forget a `use-modules' form?
> 
> error: binutils: unbound variable
> hint: Did you forget a `use-modules' form?
> 
> error: perl: unbound variable
> hint: Did you forget a `use-modules' form?
> 
> error: coreutils: unbound variable
> hint: Did you forget a `use-modules' form?
> 
> Throw to key `unbound-variable' with args `("resolve-interface" "no
> binding `~A' in module ~A" (python (gnu packages python)) #f)'.
> Backtrace: In guix/store.scm:
>    658:37 19 (thunk)
>    1320:8 18 (call-with-build-handler #<procedure 995c6f0 at guix/u?>
> ?) In guix/scripts/build.scm:
>     499:2 17 (_)
> In srfi/srfi-1.scm:
>    673:15 16 (append-map _ _ . _)
>    586:17 15 (map1 ((argument . "hello") (build-mode . 0) (# . #t) ?))
> In guix/scripts/build.scm:
>    519:31 14 (_ _)
> In gnu/packages.scm:
>     480:2 13 (%find-package "hello" "hello" #f)
>     365:6 12 (find-best-packages-by-name _ _)
>    295:56 11 (_ "hello" _)
> In unknown file:
>           10 (force #<promise #<procedure 9a81870 at
> gnu/packages.sc?>) In gnu/packages.scm:
>    242:33  9 (fold-packages #<procedure b45e1e78 at gnu/packages.sc?>
> ?) In guix/discovery.scm:
>    159:11  8 (all-modules _ #:warn _)
> In srfi/srfi-1.scm:
>    460:18  7 (fold #<procedure 9814390 at guix/discovery.scm:143:8 ?>
> ?) In guix/discovery.scm:
>    149:19  6 (_ _ ())
>     116:5  5 (scheme-modules _ _ #:warn _)
> In srfi/srfi-1.scm:
>    691:23  4 (filter-map #<procedure 98142e0 at guix/discovery.sc?> .
> #) In guix/discovery.scm:
>    124:24  3 (_ . _)
> In guix/ui.scm:
>     319:2  2 (report-unbound-variable-error _ #:frame _)
> In ice-9/boot-9.scm:
>   1685:16  1 (raise-exception _ #:continuable? _)
>   1685:16  0 (raise-exception _ #:continuable? _)
> 
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> Throw to key `match-error' with args `("match" "no matching pattern"
> (unbound-variable "resolve-interface" "no binding `~A' in module ~A"
> (python (gnu packages python)) #f))'.
So I need to not import gnu packages commencement globally.

I can also do something like that instead: 
> ("glibc:debug"
>     ,((@@ (gnu packages commencement) canonical-package)
>        (@@ (gnu packages commencement) glibc)) "debug")

Which form is the best?

Beside the glibc:debug input, the new patch is ready to be sent. I also
successfully managed to run tests that use valgrind transparently (by
using valgrind/interactive in the native inputs).

Denis.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#54728: [PATCH 2/2] gnu: valgrind: fix ld.so symbols not found
  2022-04-25 16:39           ` Denis 'GNUtoo' Carikli
@ 2022-04-25 17:41             ` Maxime Devos
  2022-04-26  1:39               ` Denis 'GNUtoo' Carikli
  0 siblings, 1 reply; 15+ messages in thread
From: Maxime Devos @ 2022-04-25 17:41 UTC (permalink / raw)
  To: Denis 'GNUtoo' Carikli, Ludovic Courtès; +Cc: 54728

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

Denis 'GNUtoo' Carikli schreef op ma 25-04-2022 om 18:39 [+0200]:
> The issue with that is that importing "gnu packages commencement"
> fails
> with the following error:

This does not work (due to import cycles I think)?
From (gnu packages commencement)

;;; To avoid circular dependencies, this module should not be imported
;;; directly from anywhere.

Instead, try using the 'canonical-package' defined in (gnu packages
base).

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#54728: [PATCH 2/2] gnu: valgrind: fix ld.so symbols not found
  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
  0 siblings, 2 replies; 15+ messages in thread
From: Denis 'GNUtoo' Carikli @ 2022-04-26  1:39 UTC (permalink / raw)
  To: 54728, ludo, maximedevos


Hi,

I've now managed to make a proper patch. I've used 'v2' for more
clarity.

I'll send the files used to test them in a subsequent mails.

As for the tests, I've done them in Guix system, once installed
valgrind works fine:
> $ make check
> valgrind -v --leak-check=full ./main
> ==20324== Memcheck, a memory error detector
> ==20324== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
> ==20324== Using Valgrind-3.18.1-42b08ed5bd-20211015 and LibVEX; rerun with -h for copyright info
> ==20324== Command: ./main
> ==20324== 
> --20324-- Valgrind options:
> --20324--    -v
> --20324--    --leak-check=full
> --20324-- Contents of /proc/version:
> --20324--   Linux version 5.16.20-gnu (guix@guix) (gcc (GCC) 10.3.0, GNU ld (GNU Binutils) 2.37) #1 SMP PREEMPT 1
> --20324-- 
> --20324-- Arch and hwcaps: X86, LittleEndian, x86-mmxext-sse1-sse2-sse3
> --20324-- Page sizes: currently 4096, max supported 4096
> --20324-- Valgrind library directory: /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind
> --20324-- Reading syms from /gnu/store/0iapawfss4xnxls622g23qpk4mwb9ihp-glibc-2.33/lib/ld-2.33.so
> --20324--   Considering /gnu/store/wznq4d1i3znqjhcribfr2m9ljyyrsdyd-glibc-2.33-debug/lib/debug/gnu/store/0iapawfss4xnxls622g23qpk4mwb9ihp-glibc-2.33/lib/ld-2.33.so.debug ..
> --20324--   .. CRC is valid
> --20324-- Reading syms from /home/gnutoo/work/projects/guix/valgrind-test/main
> --20324-- Reading syms from /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind/memcheck-x86-linux
> --20324--    object doesn't have a symbol table
> --20324--    object doesn't have a dynamic symbol table
> --20324-- Scheduler: using generic scheduler lock implementation.
> --20324-- Reading suppressions file: /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind/default.supp
> ==20324== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-20324-by-gnutoo-on-???
> ==20324== embedded gdbserver: writing to   /tmp/vgdb-pipe-to-vgdb-from-20324-by-gnutoo-on-???
> ==20324== embedded gdbserver: shared mem   /tmp/vgdb-pipe-shared-mem-vgdb-20324-by-gnutoo-on-???
> ==20324== 
> ==20324== TO CONTROL THIS PROCESS USING vgdb (which you probably
> ==20324== don't want to do, unless you know exactly what you're doing,
> ==20324== or are doing some strange experiment):
> ==20324==   /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind/../../bin/vgdb --pid=20324 ...command...
> ==20324== 
> ==20324== TO DEBUG THIS PROCESS USING GDB: start GDB like this
> ==20324==   /path/to/gdb ./main
> ==20324== and then give GDB the following command
> ==20324==   target remote | /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind/../../bin/vgdb --pid=20324
> ==20324== --pid is optional if only one valgrind process is running
> ==20324== 
> --20324-- REDIR: 0x4021570 (ld-linux.so.2:strlen) redirected to 0x580a1f4a (???)
> --20324-- REDIR: 0x40212d0 (ld-linux.so.2:index) redirected to 0x580a1f25 (???)
> --20324-- Reading syms from /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind/vgpreload_core-x86-linux.so
> --20324--    object doesn't have a symbol table
> --20324-- Reading syms from /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind/vgpreload_memcheck-x86-linux.so
> --20324--    object doesn't have a symbol table
> ==20324== WARNING: new redirection conflicts with existing -- ignoring it
> --20324--     old: 0x04021570 (strlen              ) R-> (0000.0) 0x580a1f4a ???
> --20324--     new: 0x04021570 (strlen              ) R-> (2007.0) 0x04043ca0 strlen
> --20324-- Reading syms from /gnu/store/r7n4snily34ld9nm4crzc0z65jr2y26c-gcc-10.3.0-lib/lib/libgcc_s.so.1
> --20324--    object doesn't have a symbol table
> --20324-- Reading syms from /gnu/store/0iapawfss4xnxls622g23qpk4mwb9ihp-glibc-2.33/lib/libc-2.33.so
> --20324--   Considering /gnu/store/wznq4d1i3znqjhcribfr2m9ljyyrsdyd-glibc-2.33-debug/lib/debug/gnu/store/0iapawfss4xnxls622g23qpk4mwb9ihp-glibc-2.33/lib/libc-2.33.so.debug ..
> --20324--   .. CRC is valid
> ==20324== WARNING: new redirection conflicts with existing -- ignoring it
> --20324--     old: 0x040f08c0 (memalign            ) R-> (1011.0) 0x04043084 memalign
> --20324--     new: 0x040f08c0 (memalign            ) R-> (1017.0) 0x0404303d aligned_alloc
> ==20324== WARNING: new redirection conflicts with existing -- ignoring it
> --20324--     old: 0x040f08c0 (memalign            ) R-> (1011.0) 0x04043084 memalign
> --20324--     new: 0x040f08c0 (memalign            ) R-> (1017.0) 0x04042ff6 aligned_alloc
> ==20324== WARNING: new redirection conflicts with existing -- ignoring it
> --20324--     old: 0x040f08c0 (memalign            ) R-> (1011.0) 0x04043084 memalign
> --20324--     new: 0x040f08c0 (memalign            ) R-> (1017.0) 0x0404303d aligned_alloc
> ==20324== WARNING: new redirection conflicts with existing -- ignoring it
> --20324--     old: 0x040f08c0 (memalign            ) R-> (1011.0) 0x04043084 memalign
> --20324--     new: 0x040f08c0 (memalign            ) R-> (1017.0) 0x04042ff6 aligned_alloc
> --20324-- REDIR: 0x40f49e0 (libc.so.6:strncasecmp) redirected to 0x40351e6 (_vgnU_ifunc_wrapper)
> --20324-- REDIR: 0x40fa870 (libc.so.6:memrchr) redirected to 0x40351e6 (_vgnU_ifunc_wrapper)
> --20324-- REDIR: 0x410df30 (libc.so.6:wcslen) redirected to 0x40351e6 (_vgnU_ifunc_wrapper)
> --20324-- REDIR: 0x410d5c0 (libc.so.6:__GI_strrchr) redirected to 0x4043730 (__GI_strrchr)
> --20324-- REDIR: 0x410da60 (libc.so.6:__GI_strlen) redirected to 0x4043c20 (__GI_strlen)
> --20324-- REDIR: 0x40efb60 (libc.so.6:malloc) redirected to 0x403e5ae (malloc)
> Hello world
> --20324-- REDIR: 0x40f0190 (libc.so.6:free) redirected to 0x40409fc (free)
> ==20324== 
> ==20324== HEAP SUMMARY:
> ==20324==     in use at exit: 0 bytes in 0 blocks
> ==20324==   total heap usage: 1 allocs, 1 frees, 1,024 bytes allocated
> ==20324== 
> ==20324== All heap blocks were freed -- no leaks are possible
> ==20324== 
> ==20324== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 5 from 5)
> --20324-- 
> --20324-- used_suppression:      5 dl-hack3-cond-1 /gnu/store/gkrqxqxs20mzxwxqpasy1q3w7a1v42w6-valgrind-3.18.1/libexec/valgrind/default.supp:1232
> ==20324== 
> ==20324== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 5 from 5)

In addition it also works fine with either valgrind/interactive or
valgrind-3.18 as dependency, when it is used in the tests of a
package.

I've used the 'make && ./pre-inst-env guix build -f
libsamsung-ipc.scm' command for that (with a libsamsung-ipc.scm that
is slightly modified since last time).

Denis.




^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#54728: [PATCH v2 1/2] gnu: valgrind: impots: sort imports alphabetically
  2022-04-26  1:39               ` Denis 'GNUtoo' Carikli
@ 2022-04-26  1:39                 ` 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
  1 sibling, 0 replies; 15+ messages in thread
From: Denis 'GNUtoo' Carikli @ 2022-04-26  1:39 UTC (permalink / raw)
  To: 54728, ludo, maximedevos; +Cc: Denis 'GNUtoo' Carikli

* gnu/packages/valgrind.scm: sort imports alphabetically

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
---
 gnu/packages/valgrind.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/valgrind.scm b/gnu/packages/valgrind.scm
index 1cdc0f3b71..6648f17dfa 100644
--- a/gnu/packages/valgrind.scm
+++ b/gnu/packages/valgrind.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2016, 2020, 2022 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2020 Marius Bakke <marius@gnu.org>
+;;; Copyright © 2022 Denis Carikli <GNUtoo@cyberdimension.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -22,13 +23,13 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages valgrind)
-  #:use-module (guix packages)
-  #:use-module (guix download)
   #:use-module (guix build-system gnu)
+  #:use-module (guix download)
   #:use-module (guix licenses)
+  #:use-module (guix packages)
+  #:use-module (gnu packages)
   #:use-module (gnu packages gdb)
-  #:use-module (gnu packages perl)
-  #:use-module (gnu packages))
+  #:use-module (gnu packages perl))
 
 (define-public valgrind
   (package
-- 
2.35.1





^ permalink raw reply related	[flat|nested] 15+ messages in thread

* bug#54728: [PATCH v2 2/2] gnu: valgrind: fix ld.so symbols not found
  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                 ` Denis 'GNUtoo' Carikli
  2022-04-26 22:37                   ` Denis 'GNUtoo' Carikli
  2022-05-09  9:24                   ` bug#54728: Valgrind not working out of the box due to stripped ld.so Ludovic Courtès
  1 sibling, 2 replies; 15+ messages in thread
From: Denis 'GNUtoo' Carikli @ 2022-04-26  1:39 UTC (permalink / raw)
  To: 54728, ludo, maximedevos; +Cc: Denis 'GNUtoo' Carikli

* 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>
---
 gnu/local.mk                                  |   3 +-
 gnu/packages/commencement.scm                 |   2 +-
 .../valgrind-fix-default-debuginfo-path.patch | 100 ++++++++++++++++++
 gnu/packages/valgrind.scm                     |  67 +++++++++++-
 4 files changed, 168 insertions(+), 4 deletions(-)
 create mode 100644 gnu/packages/patches/valgrind-fix-default-debuginfo-path.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 9bad87710c..c28efcab32 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1919,7 +1919,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/util-linux-tests.patch			\
   %D%/packages/patches/util-linux-CVE-2021-3995.patch		\
   %D%/packages/patches/util-linux-CVE-2021-3996.patch		\
-  %D%/packages/patches/valgrind-enable-arm.patch		\
+  %D%/packages/patches/valgrind-enable-arm.patch			\
+  %D%/packages/patches/valgrind-fix-default-debuginfo-path.patch	\
   %D%/packages/patches/vboot-utils-fix-format-load-address.patch	\
   %D%/packages/patches/vboot-utils-fix-tests-show-contents.patch	\
   %D%/packages/patches/vboot-utils-skip-test-workbuf.patch	\
diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index 1fed8bcd6e..769139e779 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -3381,7 +3381,7 @@ (define gettext-boot0
                         (("^PROGRAMS =.*$")
                          "PROGRAMS =\n")))))))))
 
-(define glibc-final
+(define-public glibc-final
   ;; The final glibc, which embeds the statically-linked Bash built above.
   ;; Use 'package/inherit' so we get the 'replacement' of 'glibc', if any.
   (package/inherit
diff --git a/gnu/packages/patches/valgrind-fix-default-debuginfo-path.patch b/gnu/packages/patches/valgrind-fix-default-debuginfo-path.patch
new file mode 100644
index 0000000000..f78dec02dc
--- /dev/null
+++ b/gnu/packages/patches/valgrind-fix-default-debuginfo-path.patch
@@ -0,0 +1,100 @@
+From a7f17b57a94e9cde6d7fa96ac86be5c4fc4f9211 Mon Sep 17 00:00:00 2001
+From: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+Date: Sun, 24 Apr 2022 22:20:50 +0200
+Subject: [PATCH] valgrind: fix default debuginfo path
+
+Description: Workaround for missing symbol in Guix's ld.so. The
+ correct fix (not stripping all the ld.so symbols) will be done in the
+ next Guix release as it requires to recompile a lot of packages.
+
+Forwarded: not-needed
+Bug-Guix: https://issues.guix.gnu.org/54728
+Author: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+---
+ coregrind/m_debuginfo/readelf.c | 11 ++++++-----
+ docs/xml/manual-core-adv.xml    |  4 ++--
+ docs/xml/manual-core.xml        |  2 +-
+ 3 files changed, 9 insertions(+), 8 deletions(-)
+
+diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c
+index c586e3f33..947fcc500 100644
+--- a/coregrind/m_debuginfo/readelf.c
++++ b/coregrind/m_debuginfo/readelf.c
+@@ -1509,9 +1509,9 @@ DiImage* find_debug_file( struct _DebugInfo* di,
+ 
+    if (buildid != NULL) {
+       debugpath = ML_(dinfo_zalloc)("di.fdf.1",
+-                                    VG_(strlen)(buildid) + 33);
++                                    VG_(strlen)(buildid) + DEBUGPATH_EXTRA_BYTES_1);
+ 
+-      VG_(sprintf)(debugpath, "/usr/lib/debug/.build-id/%c%c/%s.debug",
++      VG_(sprintf)(debugpath, "DEFAULT_DEBUGINFO_PATH/.build-id/%c%c/%s.debug",
+                    buildid[0], buildid[1], buildid + 2);
+ 
+       dimg = open_debug_file(debugpath, buildid, 0, rel_ok, NULL);
+@@ -1536,7 +1536,8 @@ DiImage* find_debug_file( struct _DebugInfo* di,
+ 
+       debugpath = ML_(dinfo_zalloc)(
+                      "di.fdf.3",
+-                     VG_(strlen)(objdir) + VG_(strlen)(debugname) + 64
++                     VG_(strlen)(objdir) + VG_(strlen)(debugname)
++                     + VG_(strlen)("DEFAULT_DEBUGINFO_PATH/") + 1
+                      + (extrapath ? VG_(strlen)(extrapath) : 0)
+                      + (serverpath ? VG_(strlen)(serverpath) : 0));
+ 
+@@ -1561,7 +1562,7 @@ DiImage* find_debug_file( struct _DebugInfo* di,
+ 
+       TRY_OBJDIR_USRMERGE_OBJDIR("%s/%s");
+       TRY_OBJDIR_USRMERGE_OBJDIR("%s/.debug/%s");
+-      TRY_OBJDIR_USRMERGE_OBJDIR("/usr/lib/debug%s/%s");
++      TRY_OBJDIR_USRMERGE_OBJDIR("DEFAULT_DEBUGINFO_PATH%s/%s");
+ 
+       if (extrapath) {
+          TRY_OBJDIR("%s%s/%s", extrapath, objdir, debugname);
+@@ -1631,7 +1632,7 @@ DiImage* find_debug_file_ad_hoc( const DebugInfo* di,
+ 
+    debugpath = ML_(dinfo_zalloc)(
+                   "di.fdfah.3",
+-                  VG_(strlen)(objdir) + 64
++                  VG_(strlen)(objdir) + DEBUGPATH_EXTRA_BYTES_2
+                   + (extrapath ? VG_(strlen)(extrapath) : 0)
+                   + (serverpath ? VG_(strlen)(serverpath) : 0));
+ 
+diff --git a/docs/xml/manual-core-adv.xml b/docs/xml/manual-core-adv.xml
+index 1fa801edc..a7c01d5e6 100644
+--- a/docs/xml/manual-core-adv.xml
++++ b/docs/xml/manual-core-adv.xml
+@@ -447,7 +447,7 @@ Valgrind embedded gdbserver:</para>
+ Remote debugging using | vgdb
+ relaying data between gdb and process 2418
+ Reading symbols from /lib/ld-linux.so.2...done.
+-Reading symbols from /usr/lib/debug/lib/ld-2.11.2.so.debug...done.
++Reading symbols from DEFAULT_DEBUGINFO_PATH/lib/ld-2.11.2.so.debug...done.
+ Loaded symbols for /lib/ld-linux.so.2
+ [Switching to Thread 2418]
+ 0x001f2850 in _start () from /lib/ld-linux.so.2
+@@ -475,7 +475,7 @@ Remote communication error: Resource temporarily unavailable.
+ Remote debugging using | vgdb --pid=2479
+ relaying data between gdb and process 2479
+ Reading symbols from /lib/ld-linux.so.2...done.
+-Reading symbols from /usr/lib/debug/lib/ld-2.11.2.so.debug...done.
++Reading symbols from DEFAULT_DEBUGINFO_PATH/lib/ld-2.11.2.so.debug...done.
+ Loaded symbols for /lib/ld-linux.so.2
+ [Switching to Thread 2479]
+ 0x001f2850 in _start () from /lib/ld-linux.so.2
+diff --git a/docs/xml/manual-core.xml b/docs/xml/manual-core.xml
+index dc33e1269..f6eb60086 100644
+--- a/docs/xml/manual-core.xml
++++ b/docs/xml/manual-core.xml
+@@ -1409,7 +1409,7 @@ that can report errors, e.g. Memcheck, but not Cachegrind.</para>
+     <listitem>
+       <para>By default Valgrind searches in several well-known paths
+       for debug objects, such
+-      as <computeroutput>/usr/lib/debug/</computeroutput>.</para>
++      as <computeroutput>DEFAULT_DEBUGINFO_PATH/</computeroutput>.</para>
+ 
+       <para>However, there may be scenarios where you may wish to put
+       debug objects at an arbitrary location, such as external storage
+-- 
+2.35.1
+
diff --git a/gnu/packages/valgrind.scm b/gnu/packages/valgrind.scm
index 6648f17dfa..1269e07593 100644
--- a/gnu/packages/valgrind.scm
+++ b/gnu/packages/valgrind.scm
@@ -25,9 +25,12 @@
 (define-module (gnu packages valgrind)
   #:use-module (guix build-system gnu)
   #:use-module (guix download)
+  #:use-module (guix gexp)
   #:use-module (guix licenses)
   #:use-module (guix packages)
+  #:use-module (guix utils)
   #:use-module (gnu packages)
+  #:use-module (gnu packages base)
   #:use-module (gnu packages gdb)
   #:use-module (gnu packages perl))
 
@@ -93,9 +96,68 @@ (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)))
+    `(("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 '())))
 
 (define-public valgrind-3.18
@@ -111,4 +173,5 @@ (define-public valgrind-3.18
               (sha256
                (base32
                 "1xgph509i6adv9w2glviw3xrmlz0dssg8992hbvxsbkp7ahrm180"))
-              (patches (search-patches "valgrind-enable-arm.patch"))))))
+              (patches (search-patches "valgrind-enable-arm.patch"
+                                       "valgrind-fix-default-debuginfo-path.patch"))))))
-- 
2.35.1





^ permalink raw reply related	[flat|nested] 15+ messages in thread

* bug#54728: [PATCH v2 2/2] gnu: valgrind: fix ld.so symbols not found
  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-09  9:24                   ` bug#54728: Valgrind not working out of the box due to stripped ld.so Ludovic Courtès
  1 sibling, 1 reply; 15+ messages in thread
From: Denis 'GNUtoo' Carikli @ 2022-04-26 22:37 UTC (permalink / raw)
  To: 54728, ludo, maximedevos


[-- Attachment #1.1: Type: text/plain, Size: 401 bytes --]

For some reasons I didn't receive a copy of the cover letter patch I
sent with git-send-email yet, so I can't reply to the cover letter, so
I'm replying to the patch instead.

In any case the patches and the cover letter are in the bug[1] report
and so as promised here's the libsamsung-ipc.scm I used for the tests.

References:
-----------
[1]https://issues.guix.gnu.org/54728#8

Denis.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: libsamsung-ipc.scm --]
[-- Type: text/x-scheme, Size: 3433 bytes --]

;;; Copyright © 2022 Denis Carikli <GNUtoo@cyberdimension.org>
;;;
;;; This file is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; This file is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License.
;;; If not, see <http://www.gnu.org/licenses/>.
;;;
;;; This file is meant to test valgrind support in Guix.
;;;
;;; The libsamsung-ipc library is not ready to be packaged in general
;;; purpose distributions as right now as it requires either a vendor
;;; kernel or the compbinaison of a recent upstream kernel with on top
;;; work in progress out of tree modem drivers, out of tree
;;; libsamsung-ipc code to support theses drivers and kernel patches
;;; to support the nonfree bootloader of the Galaxy SIII
;;; (GT-I9300). Beside the library, the tools are of very limited use
;;; beside testing or reverse engineering.

(use-modules
 (ice-9 popen)
 (ice-9 rdelim)
 (sxml ssax input-parse)
 ((guix licenses) #:prefix license:)
 (guix build-system android-ndk)
 (guix build-system gnu)
 (guix gexp)
 (guix git-download)
 (guix packages)
 (gnu packages android)
 (gnu packages autotools)
 (gnu packages curl)
 (gnu packages disk)
 (gnu packages linux)
 (gnu packages llvm)
 (gnu packages pkg-config)
 (gnu packages python)
 (gnu packages python-xyz)
 (gnu packages tls)
 (gnu packages valgrind))

(define-public libsamsung-ipc
  (package
    (name "libsamsung-ipc")
    ;; we use a work in progress version that has support for --with-valgrind-tests
    (version (git-version "0.0" "HEAD" "92de58c3ecd3f6a40323161dd28f2c9ad075ca62"))
    (source
     (origin
       (method git-fetch)
       (uri
        (git-reference
         (url "https://git.replicant.us/replicant-next/hardware_replicant_libsamsung-ipc")
         (commit "92de58c3ecd3f6a40323161dd28f2c9ad075ca62")))
       (sha256
        (base32 "0glm8hvb46iq1dhhbhymckxi6lcxn5k30lywcppbs7s8r4bnkwvy"))
       (file-name (git-file-name name version))))
    (build-system gnu-build-system)
    (native-inputs
     (list
      autoconf
      automake
      curl
      ddrescue
      libtool
      pkg-config
      python
      python-sh
      valgrind/interactive))
    (inputs
     (list openssl))
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-before 'build 'patch-python
           (lambda _
             (substitute* (find-files "." ".*\\.py$")
               (("/usr/bin/env python") (which "python3")))
           #t)))
       #:tests? #t
       #:configure-flags
       (list "--enable-debug"
             "--enable-valgrind-tests")))
    (synopsis "libsamsung-ipc is a free software implementation of the Samsung IPC modem protocol")
    (description
     "libsamsung-ipc is a free software implementation of the Samsung IPC modem protocol,
found in many Samsung smartphones and tablets.")
    (home-page "https://www.replicant.us")
    (license license:gpl2+)))

(list libsamsung-ipc)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#54728: [PATCH v2 2/2] gnu: valgrind: fix ld.so symbols not found
  2022-04-26 22:37                   ` Denis 'GNUtoo' Carikli
@ 2022-05-06 20:16                     ` Denis 'GNUtoo' Carikli
  2022-05-06 20:20                       ` Maxime Devos
  0 siblings, 1 reply; 15+ messages in thread
From: Denis 'GNUtoo' Carikli @ 2022-05-06 20:16 UTC (permalink / raw)
  To: 54728, ludo, maximedevos

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

Hi,

Did you manage to receive the patches, or were they lost somehow[1]?

At least I see them on https://issues.guix.gnu.org/54728 .

References:
-----------
[1]Personally for some reason I didn't receive a copy of the patches I
   sent through git-send-email in my mail.

Denis.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#54728: [PATCH v2 2/2] gnu: valgrind: fix ld.so symbols not found
  2022-05-06 20:16                     ` Denis 'GNUtoo' Carikli
@ 2022-05-06 20:20                       ` Maxime Devos
  0 siblings, 0 replies; 15+ messages in thread
From: Maxime Devos @ 2022-05-06 20:20 UTC (permalink / raw)
  To: Denis 'GNUtoo' Carikli, 54728, ludo

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

Denis 'GNUtoo' Carikli schreef op vr 06-05-2022 om 22:16 [+0200]:
> Hi,
> 
> Did you manage to receive the patches, or were they lost somehow[1]?
> 
> At least I see them on https://issues.guix.gnu.org/54728 .
> 

I've received ‘https://issues.guix.gnu.org/54728#11’ (at least,
received it now, via issues.guix.gnu.org) but this is way outside my
expertise and I'm currently to busy for reviewing something like that.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#54728: Valgrind not working out of the box due to stripped ld.so
  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-09  9:24                   ` Ludovic Courtès
  1 sibling, 0 replies; 15+ messages in thread
From: Ludovic Courtès @ 2022-05-09  9:24 UTC (permalink / raw)
  To: Denis 'GNUtoo' Carikli; +Cc: 54728-done, maximedevos

[-- 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"))))))

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-05-09  9:25 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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                   ` bug#54728: Valgrind not working out of the box due to stripped ld.so Ludovic Courtès

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.