From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:5f26::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id WJJMMpF4omXw9gAAkFu2QA (envelope-from ) for ; Sat, 13 Jan 2024 12:48:33 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id 8IfAK5F4omU8GwAAqHPOHw (envelope-from ) for ; Sat, 13 Jan 2024 12:48:33 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=elenq.tech header.s=soverin1 header.b=n9wUX3Vw; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1705146513; h=from:from:sender:sender: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:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=tt7HZDrRxfiyAGQDqr74yxqzqHIxcVF3/3ermHAf8Wc=; b=n/g9bzzLXyNEvHlYjHtjdkZchaiyjtPJIXyQXc0UfoYeIP0tQGTTwMZJsMFbwyAAsJAkQF RcC1U4ymNcvZp604xbCznp+aQvwNr9FAZcksMu+eFuCcEYJSVqVx5HA4A/TADU9206HebP GevAo5sHcuISQZa3zgN6B4tpLGRP7brP5V6lgvaHfWrtHJEeYL9aDXLaGi+ExBNCB1otXC i6s8g3WZniyPUJlfNkfMcaxiowQOr5PnivbFPxAL2kdxNHHGoUHG3ozmzpaph+SY5KNoM2 ZSC4JiwrrjEw261F1b7u9GGbi/BVSBKSerKuixiFONK+fO6LXUgteYuDNAaOpQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=elenq.tech header.s=soverin1 header.b=n9wUX3Vw; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1705146513; a=rsa-sha256; cv=none; b=e81vJg+fwAUfg6rD0/FMCyb/uwaqcY/+M6enI3dxi/euYaoaOurLXbRVEl5MAZj8w3nbE2 E2LgGBP1tTlxgZJfFjCCwISZRkXiW5qgi+ZU3FHTpaGATGaRrthE2ycEQpWGv8AchD/ENg FjI9a6Jk+VBmV/4xc6Lvd+Xb7tLth2V2OiSzU6Fli4PHPEMIgw9wICgJ4aYNyqmPsrFl1v UVxHS5EMfGjkUmv6ZD0grwg+fOUWQc7aTF7lrrci3QEkdstufDqnN4whIYsio4oKVa4lEO GkhwtKcybrhU5is65+u7wjUroCNY7BmwCmBq0Uo1a1PPSHpsblbFWDP6H/xmkg== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1766621B5A for ; Sat, 13 Jan 2024 12:48:33 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOcUp-0000k1-21; Sat, 13 Jan 2024 06:48:15 -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 ) id 1rOcUe-0000jg-2E for guix-patches@gnu.org; Sat, 13 Jan 2024 06:48:04 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rOcUd-0004ZW-Ox for guix-patches@gnu.org; Sat, 13 Jan 2024 06:48:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rOcUc-0002SI-5I; Sat, 13 Jan 2024 06:48:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68423] [PATCH] guix: go-build-system: use trimpath go flag Resent-From: Ekaitz Zarraga Original-Sender: "Debbugs-submit" Resent-CC: cox.katherine.e+guix@gmail.com, sharlatanus@gmail.com, guix-patches@gnu.org Resent-Date: Sat, 13 Jan 2024 11:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68423 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68423@debbugs.gnu.org Cc: Picnoir , Ekaitz Zarraga , Katherine Cox-Buday , Sharlatan Hellseher X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Katherine Cox-Buday , Sharlatan Hellseher Received: via spool by submit@debbugs.gnu.org id=B.17051464469243 (code B ref -1); Sat, 13 Jan 2024 11:48:01 +0000 Received: (at submit) by debbugs.gnu.org; 13 Jan 2024 11:47:26 +0000 Received: from localhost ([127.0.0.1]:38627 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rOcU1-0002P0-QB for submit@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 ) id 1rOcTy-0002Ok-6J for submit@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 ) id 1rOcTs-0000h1-Ir for guix-patches@gnu.org; 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 ) id 1rOcTo-0004Bn-JY for guix-patches@gnu.org; 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) 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 Date: Sat, 13 Jan 2024 12:46:15 +0100 Message-ID: MIME-Version: 1.0 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@elenq.tech; 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -0.30 X-Spam-Score: -0.30 X-Migadu-Queue-Id: 1766621B5A X-Migadu-Scanner: mx12.migadu.com X-TUID: eXjR0TbQ6lHi 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 --- 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 ;;; Copyright © 2020, 2021 Efraim Flashner ;;; Copyright © 2021 Sarah Morgensen +;;; Copyright © 2024 Ekaitz Zarraga +;;; Copyright © 2024 Picnoir ;;; ;;; 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: -;; - (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