On Thu, 07 Apr 2022 18:40:08 +0200
Ludovic Courtès <l...@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.
;;; Copyright © 2022 Denis Carikli <gnu...@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: pgprSAOJmyN3O.pgp
Description: OpenPGP digital signature

Reply via email to