GNU bug report logs - #68423
[PATCH] guix: go-build-system: use trimpath go flag

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Ekaitz Zarraga <ekaitz@HIDDEN>; Keywords: patch; dated Sat, 13 Jan 2024 11:48:01 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 68423 <at> debbugs.gnu.org:


Received: (at 68423) by debbugs.gnu.org; 13 Jan 2024 13:31:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 08:31:49 2024
Received: from localhost ([127.0.0.1]:38741 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOe73-0007Ps-3o
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 08:31:49 -0500
Received: from dane.soverin.net ([185.233.34.158]:36603)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ekaitz@HIDDEN>) id 1rOe71-0007Kg-DJ
 for 68423 <at> debbugs.gnu.org; Sat, 13 Jan 2024 08:31:48 -0500
Received: from smtp.soverin.net (unknown [10.10.4.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits))
 (No client certificate requested)
 by dane.soverin.net (Postfix) with ESMTPS id 4TBzp62kYRzyWT;
 Sat, 13 Jan 2024 13:31:42 +0000 (UTC)
Received: from smtp.soverin.net (smtp.soverin.net [10.10.4.99]) by soverin.net
 (Postfix) with ESMTPSA id 4TBzp55JNjz44; 
 Sat, 13 Jan 2024 13:31:41 +0000 (UTC)
Authentication-Results: smtp.soverin.net; dkim=pass (2048-bit key;
 unprotected) header.d=elenq.tech header.i=@elenq.tech header.a=rsa-sha256
 header.s=soverin1 header.b=EVdOv4nN; dkim-atps=neutral
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=elenq.tech; s=soverin1;
 t=1705152702;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references:autocrypt:autocrypt;
 bh=Cu+5C7sI5zd2+ELUNfj7rRXt2Ra/B04EzJr7Cm49E2I=;
 b=EVdOv4nNccv5JLP4JTw7xI4yq4RYXr6fafsK7+IIFlS7FaPs3VkWaqefCFzvgKn0CrHgG/
 N0tM/qS3A0pvTtIjteVjcfYyC37H7obnQF80Jya2Ql71+uBcalxG1wu74cmbLE0Vn4roVL
 PGKipMfVs4tkROnlLlT63pKSC4zjApKL4zC77CnMdKMlk9l2asqM+qjsE46zXYSbyXgsD4
 P1mbVGkrE8Ng6ere649bXdLgTZkKfjz7vfsDWKteam8QXwn53jMLtM+2D5JxJSyHgqZfkq
 4E/pQJP5NzzFrDY3zGIJRkmVEMmSD4DzAyXszce8nOLiK8meRWpZjegryBtNZw==
Message-ID: <5171475c-288e-24c2-a91c-94ee9b7627af@HIDDEN>
Date: Sat, 13 Jan 2024 14:31:39 +0100
MIME-Version: 1.0
Subject: Re: [bug#68423] [PATCH] guix: go-build-system: use trimpath go flag
To: Sharlatan Hellseher <sharlatanus@HIDDEN>
References: <bad254afb05576bb8f95038da01df6f34bb46009.1705146375.git.ekaitz@HIDDEN>
 <CAO+9K5om43zrhjjwK0cVs5wsNY9g0rXe3HsJGhE-aGL0xto0ug@HIDDEN>
Content-Language: en-US, es-ES, eu
From: Ekaitz Zarraga <ekaitz@HIDDEN>
Autocrypt: addr=ekaitz@HIDDEN; keydata=
 xsFNBGViSyIBEADY3g71uW/0CVaVm5/ObqTicQXXJRuh1uafIFiUUZoAp1V3V89b3LZ/m0cL
 8YNHxTxsx8sKIMYTGlOvARAMiSpDvkmpf5pLn5T7+VvK90FOv/Pkp1tNNT+tvd0m/7C58+39
 s7tN+XppbjVRtFuSXY0aFe8rpivZsKxv+tPUHUnQQszXvwgx0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Uz4mXILJrIaD/9CXGckwRCojuRzP0r6+8/RvNDc03CSe2W17WrSaoYgiRb+h5asI/AL
 yqw+QRgwXZpt0i9hNiDCe/baD62mufIyjKFjHoAWSYJuZ5VK3vWnro6GaxWULYt1+c4c4Lz2
 d1nSK6j8F3CxYo7BFk6afOusjYfh+0HywThcYY+x+K5Z+4SdJejDLiL5AzJn2W5Gt/ViK5nI
 wl7uRQpayMc9zmI8ytUT2NJxovq1/fT9nB8VPwlbJTE9zvIqfqHh9o9Apx5o8yTaSCyGUyu9
 8h/klqxFy4HAPJJu/3JkiMaCI45ZdCqRR1LIwhtmW2lb73r0rP/0S1cKi+ehA4oQvwiUw7zh
 XXw7mqzSAJ0SWT92Vy2G8Z8qqgwxwfQcdFZAyJAL1rgEPQljNT91Vgbc6DCUka2XW5BqyhEB
 eS0n1gK0hYXbM9FKegRsZxlmRAXa4KGXCwr4BNK6k+zkKPitezjbtcLgcKSHa8/HyHNkW7xH
 R+MN16x2elQPmQ2d0Ien1HgsK98+3prlUGwZIVCqa1ddSoW0llU3JzGsKrMAiYbWg/rOXFil
 RJbuhjflaLBVmfI8VlRQRocP+WEH0lsUWrtjVaGcBj1/YnIoT+zT6fPSXwPsrBvAWEjfl8HH
 e1F4cYb+ugPDwUTd1s2Uj2tF0/fhCHPy9sXyx/EIL3gqyBw9M2Rz9A==
In-Reply-To: <CAO+9K5om43zrhjjwK0cVs5wsNY9g0rXe3HsJGhE-aGL0xto0ug@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 68423
Cc: 68423 <at> debbugs.gnu.org, Picnoir <picnoir@HIDDEN>,
 Katherine Cox-Buday <cox.katherine.e+guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Hi,

On 2024-01-13 13:58, Sharlatan Hellseher wrote:
> Hi Ekaitz,
> 
> Thanks for the patch.
> 
> I think this is more suitable for core updates brunch as triggers 
> rebuild the world for all golang packages as far as I see.

Yeah, probably.

We also thought after the patch that would be interesting to provide a 
way to disable this behavior. Or maybe it's ok?

With the previous alternative the packager would just remove the phase, 
but hardcoding the option as we did doesn't provide any way to do 
that...  Some kind of flag should be enough.

Are you ok with the patch, thought?

If this is ok we'll make those small changes and send a v2.

Thanks




Information forwarded to guix-patches@HIDDEN:
bug#68423; Package guix-patches. Full text available.

Message received at 68423 <at> debbugs.gnu.org:


Received: (at 68423) by debbugs.gnu.org; 13 Jan 2024 12:58:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 07:58:55 2024
Received: from localhost ([127.0.0.1]:38701 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOdbC-0006wx-9v
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 07:58:55 -0500
Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]:50561)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sharlatanus@HIDDEN>) id 1rOdb9-0006wh-Ko
 for 68423 <at> debbugs.gnu.org; Sat, 13 Jan 2024 07:58:53 -0500
Received: by mail-lf1-x12c.google.com with SMTP id
 2adb3069b0e04-50e7ddd999bso8109889e87.1
 for <68423 <at> debbugs.gnu.org>; Sat, 13 Jan 2024 04:58:52 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1705150727; x=1705755527; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=wN7tMhPg1MZbzuUTKaKkgpAe3Vv82+sFWbdqoxHhp9M=;
 b=JSkL0kXzGxd8EcrSE2tdYR2IjvXOhI7mDiL3bWGcr4ecG0RfX4HLFyusBshlVZjPFI
 ajCb7sJUa16KHjCckoKOB7xQptD5CMvexUxyP7WslJ+YsibIhsgxZsuqwZ4WR5xdYAkQ
 wqzzkliaLhC04Roft8x1cHBN3NiL33CmhPb+KGBsFf3K4OQvCxagpzL8QKlhGy2TodY2
 ULn//4OdDIWniFe0rwsdsaJ0ctxaP/0mVPtcEhM5dYzZfe5WcMoQH97wDeFb1WGK/NgI
 j4o5dUwzRiRL3WPinLjQBGdnhZ+BxrEsfoNWwXaqnhKMjKE4ZrsGE+pG/GsCihiR+8l3
 KldQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1705150727; x=1705755527;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=wN7tMhPg1MZbzuUTKaKkgpAe3Vv82+sFWbdqoxHhp9M=;
 b=u1gTQy068K3+6uaMQxWxSXSg+MKefnn/TQmbMk8VoXYSJmv+25gqlTWdJgKdmyYWyk
 iadugsrFtIizyiob+qFDTL+9daRBCimqawFmza11pKbFkpEOhmfjtRxhQkn5kO4vQFXq
 HBLF/GCmUTlqjtUmxfmcgtDC7sncBeBzr5Ln65NS3e95SElWzkmEIZrHLy+hWYWScXV3
 qA15xiCvvqeHAxtvujMEjkPYL+Hq7H4XGd2UDR3hL9PvEGRo38VrupxOhksrs1MSsC4S
 SJrtC0ytzbjQrdv8sYtNTOtJsERx78TEN5lXqrEf6x7CMxO12hAgEMwuqkE1jWT89IAW
 HLww==
X-Gm-Message-State: AOJu0Yz/gecnrsMS581PbxzJ3TNbdYzaxoxYcdJSjtTaIDFBmS++phO8
 KG/ZEptm7nqhO6goIgMHz1z9gD2Gl1mrFcoWDBw=
X-Google-Smtp-Source: AGHT+IFFV1/NsctKc5sSG5jk0uuWkc21Vlzk4pvCWmInSF/fBDiOryg5M4sAj4AbIf9iFkw4wD30Xkpm91x0lJ5dcfI=
X-Received: by 2002:ac2:548e:0:b0:50e:59cf:e548 with SMTP id
 t14-20020ac2548e000000b0050e59cfe548mr1129685lfk.94.1705150726603; Sat, 13
 Jan 2024 04:58:46 -0800 (PST)
MIME-Version: 1.0
References: <bad254afb05576bb8f95038da01df6f34bb46009.1705146375.git.ekaitz@HIDDEN>
In-Reply-To: <bad254afb05576bb8f95038da01df6f34bb46009.1705146375.git.ekaitz@HIDDEN>
From: Sharlatan Hellseher <sharlatanus@HIDDEN>
Date: Sat, 13 Jan 2024 12:58:34 +0000
Message-ID: <CAO+9K5om43zrhjjwK0cVs5wsNY9g0rXe3HsJGhE-aGL0xto0ug@HIDDEN>
Subject: Re: [bug#68423] [PATCH] guix: go-build-system: use trimpath go flag
To: Ekaitz Zarraga <ekaitz@HIDDEN>
Content-Type: multipart/alternative; boundary="0000000000005907cc060ed357b1"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 68423
Cc: 68423 <at> debbugs.gnu.org, Picnoir <picnoir@HIDDEN>,
 Katherine Cox-Buday <cox.katherine.e+guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--0000000000005907cc060ed357b1
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Ekaitz,

Thanks for the patch.

I think this is more suitable for core updates brunch as triggers rebuild
the world for all golang packages as far as I see.

Regards,
Oleg

On Sat, 13 Jan 2024, 11:48 Ekaitz Zarraga, <ekaitz@HIDDEN> wrote:

> Go 1.13 introduced[1] a new "trimpath" flag in charge of removing the
> references to the go toolchain in the produced ELFs. We used to remove
> these references using the "remove-go-reference" function. This function
> was executed after go install. By using this new trimpath flag, we don't
> have to remove any store path from the ELFs produced by go install.
>
> We're not using any go older than 1.13 anymore, it's safe to remove
> these functions.
>
> [1] https://go.dev/doc/go1.13
>
>     -trimpath
>         remove all file system paths from the resulting executable.
>         Instead of absolute file system paths, the recorded file names
>         will begin either a module path@version (when using modules),
>         or a plain import path (when using the standard library, or
>         GOPATH).
>
> * guix/build/go-build-system.scm (build): Add -trimpath
> (%standard-phases): Remove remove-go-references.
> (remove-go-references): Remove.
>
> Change-Id: Idcae366d226da5ce095693f81fd33133fd1d70d6
> Co-authored-by: Picnoir <picnoir@HIDDEN>
> ---
>  guix/build/go-build-system.scm | 59 +++-------------------------------
>  1 file changed, 4 insertions(+), 55 deletions(-)
>
> diff --git a/guix/build/go-build-system.scm
> b/guix/build/go-build-system.scm
> index 7f25e05d0d..70ddcd07cd 100644
> --- a/guix/build/go-build-system.scm
> +++ b/guix/build/go-build-system.scm
> @@ -6,6 +6,8 @@
>  ;;; Copyright =C2=A9 2020 Jakub K=C4=85dzio=C5=82ka <kuba@HIDDEN>
>  ;;; Copyright =C2=A9 2020, 2021 Efraim Flashner <efraim@HIDDEN>
>  ;;; Copyright =C2=A9 2021 Sarah Morgensen <iskarian@HIDDEN>
> +;;; Copyright =C2=A9 2024 Ekaitz Zarraga <ekaitz@HIDDEN>
> +;;; Copyright =C2=A9 2024 Picnoir <picnoir@HIDDEN>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -90,7 +92,6 @@ (define-module (guix build go-build-system)
>  ;; * Use Go modules [4]
>  ;; * Re-use compiled packages [5]
>  ;; * Avoid the go-inputs hack
> -;; * Stop needing remove-go-references (-trimpath ? )
>  ;; * Remove module packages, only offering the full Git repos? This is
>  ;; more idiomatic, I think, because Go downloads Git repos, not modules.
>  ;; What are the trade-offs?
> @@ -265,6 +266,7 @@ (define* (build #:key import-path build-flags
> #:allow-other-keys)
>                ;; Respectively, strip the symbol table and debug
>                ;; information, and the DWARF symbol table.
>                "-ldflags=3D-s -w"
> +              "-trimpath"
>                `(,@build-flags ,import-path)))
>      (lambda (key . args)
>        (display (string-append "Building '" import-path "' failed.\n"
> @@ -304,58 +306,6 @@ (define* (install-license-files #:key unpack-path
>                                                      unpack-path))
>      (apply (assoc-ref gnu:%standard-phases 'install-license-files) args)=
))
>
> -(define* (remove-store-reference file file-name
> -                                  #:optional (store (%store-directory)))
> -  "Remove from FILE occurrences of FILE-NAME in STORE; return #t when
> FILE-NAME
> -is encountered in FILE, #f otherwise. This implementation reads FILE one
> byte at
> -a time, which is slow. Instead, we should use the Boyer-Moore string
> search
> -algorithm; there is an example in (guix build grafts)."
> -  (define pattern
> -    (string-take file-name
> -                 (+ 34 (string-length (%store-directory)))))
> -
> -  (with-fluids ((%default-port-encoding #f))
> -    (with-atomic-file-replacement file
> -      (lambda (in out)
> -        ;; We cannot use `regexp-exec' here because it cannot deal with
> -        ;; strings containing NUL characters.
> -        (format #t "removing references to `~a' from `~a'...~%" file-nam=
e
> file)
> -        (setvbuf in 'block 65536)
> -        (setvbuf out 'block 65536)
> -        (fold-port-matches (lambda (match result)
> -                             (put-bytevector out (string->utf8 store))
> -                             (put-u8 out (char->integer #\/))
> -                             (put-bytevector out
> -                                             (string->utf8
> -
> "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-"))
> -                             #t)
> -                           #f
> -                           pattern
> -                           in
> -                           (lambda (char result)
> -                             (put-u8 out (char->integer char))
> -                             result))))))
> -
> -(define* (remove-go-references #:key allow-go-reference?
> -                               inputs outputs #:allow-other-keys)
> -  "Remove any references to the Go compiler from the compiled Go
> executable
> -files in OUTPUTS."
> -;; We remove this spurious reference to save bandwidth when installing G=
o
> -;; executables. It would be better to not embed the reference in the fir=
st
> -;; place, but I'm not sure how to do that. The subject was discussed at:
> -;; <https://lists.gnu.org/archive/html/guix-devel/2017-10/msg00207.html>
> -  (if allow-go-reference?
> -    #t
> -    (let ((go (assoc-ref inputs "go"))
> -          (bin "/bin"))
> -      (for-each (lambda (output)
> -                  (when (file-exists? (string-append (cdr output)
> -                                                     bin))
> -                    (for-each (lambda (file)
> -                                (remove-store-reference file go))
> -                              (find-files (string-append (cdr output)
> bin)))))
> -                outputs)
> -      #t)))
>
>  (define %standard-phases
>    (modify-phases gnu:%standard-phases
> @@ -367,8 +317,7 @@ (define %standard-phases
>      (replace 'build build)
>      (replace 'check check)
>      (replace 'install install)
> -    (replace 'install-license-files install-license-files)
> -    (add-after 'install 'remove-go-references remove-go-references)))
> +    (replace 'install-license-files install-license-files)))
>
>  (define* (go-build #:key inputs (phases %standard-phases)
>                        #:allow-other-keys #:rest args)
>
> base-commit: c0b303aaa3d6154acbe054120d11467eb98e6d33
> --
> 2.41.0
>
>
>
>

--0000000000005907cc060ed357b1
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">Hi Ekaitz,<div dir=3D"auto"><br></div><div dir=3D"auto">T=
hanks for the patch.</div><div dir=3D"auto"><br></div><div dir=3D"auto">I t=
hink this is more suitable for core updates brunch as triggers rebuild the =
world for all golang packages as far as I see.</div><div dir=3D"auto"><br><=
/div><div dir=3D"auto">Regards,</div><div dir=3D"auto">Oleg</div></div><br>=
<div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sat, 13=
 Jan 2024, 11:48 Ekaitz Zarraga, &lt;ekaitz@HIDDEN&gt; wrote:<br></div>=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Go 1.13 introduced[1] a new &quot;trimpath&q=
uot; flag in charge of removing the<br>
references to the go toolchain in the produced ELFs. We used to remove<br>
these references using the &quot;remove-go-reference&quot; function. This f=
unction<br>
was executed after go install. By using this new trimpath flag, we don&#39;=
t<br>
have to remove any store path from the ELFs produced by go install.<br>
<br>
We&#39;re not using any go older than 1.13 anymore, it&#39;s safe to remove=
<br>
these functions.<br>
<br>
[1] <a href=3D"https://go.dev/doc/go1.13" rel=3D"noreferrer noreferrer" tar=
get=3D"_blank">https://go.dev/doc/go1.13</a><br>
<br>
=C2=A0 =C2=A0 -trimpath<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 remove all file system paths from the resulting=
 executable.<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Instead of absolute file system paths, the reco=
rded file names<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 will begin either a module path@version (when u=
sing modules),<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 or a plain import path (when using the standard=
 library, or<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 GOPATH).<br>
<br>
* guix/build/go-build-system.scm (build): Add -trimpath<br>
(%standard-phases): Remove remove-go-references.<br>
(remove-go-references): Remove.<br>
<br>
Change-Id: Idcae366d226da5ce095693f81fd33133fd1d70d6<br>
Co-authored-by: Picnoir &lt;<a href=3D"mailto:picnoir@HIDDEN" ta=
rget=3D"_blank" rel=3D"noreferrer">picnoir@HIDDEN</a>&gt;<br>
---<br>
=C2=A0guix/build/go-build-system.scm | 59 +++------------------------------=
-<br>
=C2=A01 file changed, 4 insertions(+), 55 deletions(-)<br>
<br>
diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.sc=
m<br>
index 7f25e05d0d..70ddcd07cd 100644<br>
--- a/guix/build/go-build-system.scm<br>
+++ b/guix/build/go-build-system.scm<br>
@@ -6,6 +6,8 @@<br>
=C2=A0;;; Copyright =C2=A9 2020 Jakub K=C4=85dzio=C5=82ka &lt;<a href=3D"ma=
ilto:kuba@HIDDEN" target=3D"_blank" rel=3D"noreferrer">kuba@kadziolk=
a.net</a>&gt;<br>
=C2=A0;;; Copyright =C2=A9 2020, 2021 Efraim Flashner &lt;<a href=3D"mailto=
:efraim@HIDDEN" target=3D"_blank" rel=3D"noreferrer">efraim@flashne=
r.co.il</a>&gt;<br>
=C2=A0;;; Copyright =C2=A9 2021 Sarah Morgensen &lt;<a href=3D"mailto:iskar=
ian@HIDDEN" target=3D"_blank" rel=3D"noreferrer">iskarian@HIDDEN</a>&gt=
;<br>
+;;; Copyright =C2=A9 2024 Ekaitz Zarraga &lt;ekaitz@HIDDEN&gt;<br>
+;;; Copyright =C2=A9 2024 Picnoir &lt;<a href=3D"mailto:picnoir@alternativ=
ebit.fr" target=3D"_blank" rel=3D"noreferrer">picnoir@HIDDEN</a>=
&gt;<br>
=C2=A0;;;<br>
=C2=A0;;; This file is part of GNU Guix.<br>
=C2=A0;;;<br>
@@ -90,7 +92,6 @@ (define-module (guix build go-build-system)<br>
=C2=A0;; * Use Go modules [4]<br>
=C2=A0;; * Re-use compiled packages [5]<br>
=C2=A0;; * Avoid the go-inputs hack<br>
-;; * Stop needing remove-go-references (-trimpath ? )<br>
=C2=A0;; * Remove module packages, only offering the full Git repos? This i=
s<br>
=C2=A0;; more idiomatic, I think, because Go downloads Git repos, not modul=
es.<br>
=C2=A0;; What are the trade-offs?<br>
@@ -265,6 +266,7 @@ (define* (build #:key import-path build-flags #:allow-o=
ther-keys)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Respectively, str=
ip the symbol table and debug<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; information, and =
the DWARF symbol table.<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;-ldflags=3D-s =
-w&quot;<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &quot;-trimpath&quot;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0`(,@build-flags ,imp=
ort-path)))<br>
=C2=A0 =C2=A0 =C2=A0(lambda (key . args)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0(display (string-append &quot;Building &#39;&quo=
t; import-path &quot;&#39; failed.\n&quot;<br>
@@ -304,58 +306,6 @@ (define* (install-license-files #:key unpack-path<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0unpack-path))<br>
=C2=A0 =C2=A0 =C2=A0(apply (assoc-ref gnu:%standard-phases &#39;install-lic=
ense-files) args)))<br>
<br>
-(define* (remove-store-reference file file-name<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #:optional (store (%store-dir=
ectory)))<br>
-=C2=A0 &quot;Remove from FILE occurrences of FILE-NAME in STORE; return #t=
 when FILE-NAME<br>
-is encountered in FILE, #f otherwise. This implementation reads FILE one b=
yte at<br>
-a time, which is slow. Instead, we should use the Boyer-Moore string searc=
h<br>
-algorithm; there is an example in (guix build grafts).&quot;<br>
-=C2=A0 (define pattern<br>
-=C2=A0 =C2=A0 (string-take file-name<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(+ 34 (strin=
g-length (%store-directory)))))<br>
-<br>
-=C2=A0 (with-fluids ((%default-port-encoding #f))<br>
-=C2=A0 =C2=A0 (with-atomic-file-replacement file<br>
-=C2=A0 =C2=A0 =C2=A0 (lambda (in out)<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; We cannot use `regexp-exec&#39; here becaus=
e it cannot deal with<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; strings containing NUL characters.<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 (format #t &quot;removing references to `~a&#3=
9; from `~a&#39;...~%&quot; file-name file)<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 (setvbuf in &#39;block 65536)<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 (setvbuf out &#39;block 65536)<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 (fold-port-matches (lambda (match result)<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(put-bytevector out (string-&gt;utf8 store))=
<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(put-u8 out (char-&gt;integ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=
=A0 =C2=A0 =C2=A0 =C2=A0(lambda (char result)<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(put-u8 out (char-&gt;integer char))<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0result))))))<br>
-<br>
-(define* (remove-go-references #:key allow-go-reference?<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0inputs outputs #:allow-other-keys)<br=
>
-=C2=A0 &quot;Remove any references to the Go compiler from the compiled Go=
 executable<br>
-files in OUTPUTS.&quot;<br>
-;; We remove this spurious reference to save bandwidth when installing Go<=
br>
-;; executables. It would be better to not embed the reference in the first=
<br>
-;; place, but I&#39;m not sure how to do that. The subject was discussed a=
t:<br>
-;; &lt;<a href=3D"https://lists.gnu.org/archive/html/guix-devel/2017-10/ms=
g00207.html" rel=3D"noreferrer noreferrer" target=3D"_blank">https://lists.=
gnu.org/archive/html/guix-devel/2017-10/msg00207.html</a>&gt;<br>
-=C2=A0 (if allow-go-reference?<br>
-=C2=A0 =C2=A0 #t<br>
-=C2=A0 =C2=A0 (let ((go (assoc-ref inputs &quot;go&quot;))<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (bin &quot;/bin&quot;))<br>
-=C2=A0 =C2=A0 =C2=A0 (for-each (lambda (output)<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (when (file=
-exists? (string-append (cdr output)<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bin))<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (for=
-each (lambda (file)<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (remove-store-reference file go))<br=
>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (find-files (string-append (cdr output) bin=
)))))<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 outputs)<br>
-=C2=A0 =C2=A0 =C2=A0 #t)))<br>
<br>
=C2=A0(define %standard-phases<br>
=C2=A0 =C2=A0(modify-phases gnu:%standard-phases<br>
@@ -367,8 +317,7 @@ (define %standard-phases<br>
=C2=A0 =C2=A0 =C2=A0(replace &#39;build build)<br>
=C2=A0 =C2=A0 =C2=A0(replace &#39;check check)<br>
=C2=A0 =C2=A0 =C2=A0(replace &#39;install install)<br>
-=C2=A0 =C2=A0 (replace &#39;install-license-files install-license-files)<b=
r>
-=C2=A0 =C2=A0 (add-after &#39;install &#39;remove-go-references remove-go-=
references)))<br>
+=C2=A0 =C2=A0 (replace &#39;install-license-files install-license-files)))=
<br>
<br>
=C2=A0(define* (go-build #:key inputs (phases %standard-phases)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0#:allow-other-keys #:rest args)<br>
<br>
base-commit: c0b303aaa3d6154acbe054120d11467eb98e6d33<br>
-- <br>
2.41.0<br>
<br>
<br>
<br>
</blockquote></div>

--0000000000005907cc060ed357b1--




Information forwarded to guix-patches@HIDDEN:
bug#68423; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 Jan 2024 11:47:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 13 06:47:26 2024
Received: from localhost ([127.0.0.1]:38627 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOcU1-0002P0-QB
	for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 06:47:26 -0500
Received: from lists.gnu.org ([2001:470:142::17]:43402)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ekaitz@HIDDEN>) id 1rOcTy-0002Ok-6J
 for submit <at> debbugs.gnu.org; Sat, 13 Jan 2024 06:47:24 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ekaitz@HIDDEN>) id 1rOcTs-0000h1-Ir
 for guix-patches@HIDDEN; Sat, 13 Jan 2024 06:47:17 -0500
Received: from dane.soverin.net ([2a10:de80:1:4091:b9e9:2218:0:1])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <ekaitz@HIDDEN>) id 1rOcTo-0004Bn-JY
 for guix-patches@HIDDEN; Sat, 13 Jan 2024 06:47:16 -0500
Received: from smtp.soverin.net (unknown [10.10.4.74])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by dane.soverin.net (Postfix) with ESMTPS id 4TBxTQ2rykzyRc;
 Sat, 13 Jan 2024 11:47:06 +0000 (UTC)
Received: from smtp.soverin.net (smtp.soverin.net [10.10.4.100]) by
 soverin.net (Postfix) with ESMTPSA id 4TBxTP3R0WzF1; 
 Sat, 13 Jan 2024 11:47:05 +0000 (UTC)
Authentication-Results: smtp.soverin.net; dkim=pass (2048-bit key;
 unprotected) header.d=elenq.tech header.i=@elenq.tech header.a=rsa-sha256
 header.s=soverin1 header.b=n9wUX3Vw; dkim-atps=neutral
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=elenq.tech; s=soverin1;
 t=1705146425;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding;
 bh=tt7HZDrRxfiyAGQDqr74yxqzqHIxcVF3/3ermHAf8Wc=;
 b=n9wUX3Vwfwp7OGNYyibpdgHuuWACX65qBEgYZFXSgSVdQEwmCx+deUeDeYq2AjkAHbbW4a
 xA0YE7TtJNXmaQ4gDakTIDysJTdBWlejMdrEqjCnnQe6g+ROvmy4NEcjgX7Qmz/ZMWub7B
 hd+RiLmTssX+lrga+PJu5E9jQIAa9wIqicXwZXKyXCq2rUzB7MI2C+KpP8X5ZWeUcPibeW
 d7cJt/HuM/j5MtYesHiIk4oD6VuUqFHZh8rCAh/lTMBZ3okM+AD8pGmef0YvdlmYmrdsR9
 uP8jPDu901y7CPOe9e15GZkq30W2vsa0I27qpCAW6O81limayW2lpAzCAosSIw==
From: Ekaitz Zarraga <ekaitz@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH] guix: go-build-system: use trimpath go flag
Date: Sat, 13 Jan 2024 12:46:15 +0100
Message-ID: <bad254afb05576bb8f95038da01df6f34bb46009.1705146375.git.ekaitz@HIDDEN>
MIME-Version: 1.0
X-Debbugs-Cc: Katherine Cox-Buday <cox.katherine.e+guix@HIDDEN>,
 Sharlatan Hellseher <sharlatanus@HIDDEN>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=2a10:de80:1:4091:b9e9:2218:0:1;
 envelope-from=ekaitz@HIDDEN; helo=dane.soverin.net
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
Cc: Picnoir <picnoir@HIDDEN>, Ekaitz Zarraga <ekaitz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

Go 1.13 introduced[1] a new "trimpath" flag in charge of removing the
references to the go toolchain in the produced ELFs. We used to remove
these references using the "remove-go-reference" function. This function
was executed after go install. By using this new trimpath flag, we don't
have to remove any store path from the ELFs produced by go install.

We're not using any go older than 1.13 anymore, it's safe to remove
these functions.

[1] https://go.dev/doc/go1.13

    -trimpath
        remove all file system paths from the resulting executable.
        Instead of absolute file system paths, the recorded file names
        will begin either a module path@version (when using modules),
        or a plain import path (when using the standard library, or
        GOPATH).

* guix/build/go-build-system.scm (build): Add -trimpath
(%standard-phases): Remove remove-go-references.
(remove-go-references): Remove.

Change-Id: Idcae366d226da5ce095693f81fd33133fd1d70d6
Co-authored-by: Picnoir <picnoir@HIDDEN>
---
 guix/build/go-build-system.scm | 59 +++-------------------------------
 1 file changed, 4 insertions(+), 55 deletions(-)

diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm
index 7f25e05d0d..70ddcd07cd 100644
--- a/guix/build/go-build-system.scm
+++ b/guix/build/go-build-system.scm
@@ -6,6 +6,8 @@
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@HIDDEN>
 ;;; Copyright © 2020, 2021 Efraim Flashner <efraim@HIDDEN>
 ;;; Copyright © 2021 Sarah Morgensen <iskarian@HIDDEN>
+;;; Copyright © 2024 Ekaitz Zarraga <ekaitz@HIDDEN>
+;;; Copyright © 2024 Picnoir <picnoir@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -90,7 +92,6 @@ (define-module (guix build go-build-system)
 ;; * Use Go modules [4]
 ;; * Re-use compiled packages [5]
 ;; * Avoid the go-inputs hack
-;; * Stop needing remove-go-references (-trimpath ? )
 ;; * Remove module packages, only offering the full Git repos? This is
 ;; more idiomatic, I think, because Go downloads Git repos, not modules.
 ;; What are the trade-offs?
@@ -265,6 +266,7 @@ (define* (build #:key import-path build-flags #:allow-other-keys)
               ;; Respectively, strip the symbol table and debug
               ;; information, and the DWARF symbol table.
               "-ldflags=-s -w"
+              "-trimpath"
               `(,@build-flags ,import-path)))
     (lambda (key . args)
       (display (string-append "Building '" import-path "' failed.\n"
@@ -304,58 +306,6 @@ (define* (install-license-files #:key unpack-path
                                                     unpack-path))
     (apply (assoc-ref gnu:%standard-phases 'install-license-files) args)))
 
-(define* (remove-store-reference file file-name
-                                  #:optional (store (%store-directory)))
-  "Remove from FILE occurrences of FILE-NAME in STORE; return #t when FILE-NAME
-is encountered in FILE, #f otherwise. This implementation reads FILE one byte at
-a time, which is slow. Instead, we should use the Boyer-Moore string search
-algorithm; there is an example in (guix build grafts)."
-  (define pattern
-    (string-take file-name
-                 (+ 34 (string-length (%store-directory)))))
-
-  (with-fluids ((%default-port-encoding #f))
-    (with-atomic-file-replacement file
-      (lambda (in out)
-        ;; We cannot use `regexp-exec' here because it cannot deal with
-        ;; strings containing NUL characters.
-        (format #t "removing references to `~a' from `~a'...~%" file-name file)
-        (setvbuf in 'block 65536)
-        (setvbuf out 'block 65536)
-        (fold-port-matches (lambda (match result)
-                             (put-bytevector out (string->utf8 store))
-                             (put-u8 out (char->integer #\/))
-                             (put-bytevector out
-                                             (string->utf8
-                                              "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-"))
-                             #t)
-                           #f
-                           pattern
-                           in
-                           (lambda (char result)
-                             (put-u8 out (char->integer char))
-                             result))))))
-
-(define* (remove-go-references #:key allow-go-reference?
-                               inputs outputs #:allow-other-keys)
-  "Remove any references to the Go compiler from the compiled Go executable
-files in OUTPUTS."
-;; We remove this spurious reference to save bandwidth when installing Go
-;; executables. It would be better to not embed the reference in the first
-;; place, but I'm not sure how to do that. The subject was discussed at:
-;; <https://lists.gnu.org/archive/html/guix-devel/2017-10/msg00207.html>
-  (if allow-go-reference?
-    #t
-    (let ((go (assoc-ref inputs "go"))
-          (bin "/bin"))
-      (for-each (lambda (output)
-                  (when (file-exists? (string-append (cdr output)
-                                                     bin))
-                    (for-each (lambda (file)
-                                (remove-store-reference file go))
-                              (find-files (string-append (cdr output) bin)))))
-                outputs)
-      #t)))
 
 (define %standard-phases
   (modify-phases gnu:%standard-phases
@@ -367,8 +317,7 @@ (define %standard-phases
     (replace 'build build)
     (replace 'check check)
     (replace 'install install)
-    (replace 'install-license-files install-license-files)
-    (add-after 'install 'remove-go-references remove-go-references)))
+    (replace 'install-license-files install-license-files)))
 
 (define* (go-build #:key inputs (phases %standard-phases)
                       #:allow-other-keys #:rest args)

base-commit: c0b303aaa3d6154acbe054120d11467eb98e6d33
-- 
2.41.0





Acknowledgement sent to Ekaitz Zarraga <ekaitz@HIDDEN>:
New bug report received and forwarded. Copy sent to cox.katherine.e+guix@HIDDEN, sharlatanus@HIDDEN, guix-patches@HIDDEN. Full text available.
Report forwarded to cox.katherine.e+guix@HIDDEN, sharlatanus@HIDDEN, guix-patches@HIDDEN:
bug#68423; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 20 Jan 2024 12:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.