From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id UACfH14/KWGmTAEAgWs5BA (envelope-from ) for ; Fri, 27 Aug 2021 21:39:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id CE4vG14/KWEWLwAAB5/wlQ (envelope-from ) for ; Fri, 27 Aug 2021 19:39:10 +0000 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 9FA7F1C54E for ; Fri, 27 Aug 2021 21:39:09 +0200 (CEST) Received: from localhost ([::1]:41652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJhgy-0008U9-EI for larch@yhetil.org; Fri, 27 Aug 2021 15:39:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJhgt-0008S8-0K for guix-patches@gnu.org; Fri, 27 Aug 2021 15:39:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:41496) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mJhgs-000847-PF for guix-patches@gnu.org; Fri, 27 Aug 2021 15:39:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mJhgs-0007n1-Es for guix-patches@gnu.org; Fri, 27 Aug 2021 15:39:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50227] [PATCH] build-system/go: Trim store references using the native compiler option. Resent-From: Marius Bakke Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 27 Aug 2021 19:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50227 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50227@debbugs.gnu.org Received: via spool by 50227-submit@debbugs.gnu.org id=B50227.163009313229926 (code B ref 50227); Fri, 27 Aug 2021 19:39:02 +0000 Received: (at 50227) by debbugs.gnu.org; 27 Aug 2021 19:38:52 +0000 Received: from localhost ([127.0.0.1]:53042 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJhgh-0007mc-QT for submit@debbugs.gnu.org; Fri, 27 Aug 2021 15:38:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58002) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJhgg-0007mQ-4X for 50227@debbugs.gnu.org; Fri, 27 Aug 2021 15:38:51 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:60480) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJhga-0007vc-RG for 50227@debbugs.gnu.org; Fri, 27 Aug 2021 15:38:44 -0400 Received: from host-37-191-231-185.lynet.no ([37.191.231.185]:38016 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJhga-00046j-B2 for 50227@debbugs.gnu.org; Fri, 27 Aug 2021 15:38:44 -0400 From: Marius Bakke In-Reply-To: <87wno6n5ju.fsf@gnu.org> References: <20210827151052.12611-1-marius@gnu.org> <20210827164423.17109-1-marius@gnu.org> <87wno6n5ju.fsf@gnu.org> Date: Fri, 27 Aug 2021 21:38:40 +0200 Message-ID: <87tujan0e7.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" 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" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1630093150; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post; bh=ngKsRvrHB1FUTPGXDmY1qW7eh/11GgQcr0p/kZaO7FU=; b=ewup5OPDeuMzu6oIzWht7SaW6bY1dJsiU82dPMkTTCe3b6cdCQZBcqMiGhgQ1Y7NAD8wmP c6aqLfWBXpAbhJXHUR93Pnr3PG9GdxNfbuf/xixLvJfBeBXSwCjAW96adR/Wmrt5qRUVDH h+zzfNOZxpgocfAzH6sft4X4uTKwKfDjGcEVPe1s8QToB3DNPKDLsAYpeDhmPeas6LMg0h E8Wfacl0X8DMczs7tIkQNh2CqYK1D+OnusCQlHNHJoaY0cIPITPknnz7aQ0BhORPlEqf5R /ho1QoLdsxTBRc1jipPCEVm5P6XcAhZtgaPOLd4D6LRHdOKfKZY9DXCtf4U6+A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630093150; a=rsa-sha256; cv=none; b=c+UPh886R1DX8vsE6mCYx/knM1reGj5nQiYUIBwN4ts8GwDRVkhgOpR1YDIX2wAL5IFq95 B/tC+bWXsN4Qlag8yX6xnQ15K6kOK5TTeaRdefqlb3cGaZISwteMUdCSju5bUTHIUi3Aw/ NUDnkD5iD2PRyxTXrVWXf1xsnjux68BickXzVxeFynsBFP+onx86GEWxoBAg3laXg1UCl/ YckZUIq2qOaeI+pmgiO9uVeSe5r7rcKQAEQKv2Xxwc6DXW9VozN/p31z7CVDzhF+kcKv/X ajPLnbP8s66TCwrb8RCUK+AbBMrhtS3ba9ZFZq0bosylaECUfdOAAKwMHdf82g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -5.03 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 9FA7F1C54E X-Spam-Score: -5.03 X-Migadu-Scanner: scn0.migadu.com X-TUID: 04+HD3GHiUBk --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Marius Bakke skriver: > Marius Bakke skriver: > >> * guix/build/go-build-system.scm (build): Add '-trimpath' to the 'go install' >> invocation. >> (remove-store-references, remove-go-references): Remove procedures. >> (%standard-phases): Don't include remove-go-references. >> * gnu/packages/docker.scm (docker)[arguments]: Add the '-trimpath' option to >> the build flags. Remove phase remove-go-references. >> * gnu/packages/uucp.scm (nncp)[arguments]: Likewise. [...] > Docker explodes from 764.4 MiB to 1215.5 MiB with this patch even though > it does use the '-trimpath' option. Perhaps -trimpath does not work as > well with dynamically linked executables as it does for static? The size difference comes from containerd, which has a custom build system that does not add -trimpath. After adding the following hunk: --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/gnu/packages/docker.scm b/gnu/packages/docker.scm index 88dccc2ae2..e1ddfc6c38 100644 --- a/gnu/packages/docker.scm +++ b/gnu/packages/docker.scm @@ -221,6 +221,13 @@ Python without keeping their credentials in a Docker configuration file.") (("exec\\.LookPath\\(\"unpigz\"\\)") (string-append "\"" (assoc-ref inputs "pigz") "/bin/unpigz\", error(nil)")))))) + (add-before 'build 'trim-store-references + (lambda* (#:key import-path #:allow-other-keys) + (substitute* (string-append "src/" import-path "/Makefile") + ;; Pass the '-trimpath' option down to 'go build' in order + ;; to avoid spurious store references. + (("^GO_BUILD_FLAGS=") + "GO_BUILD_FLAGS=-trimpath")))) (replace 'build (lambda* (#:key import-path #:allow-other-keys) (with-directory-excursion (string-append "src/" import-path) --=-=-= Content-Type: text/plain ...the size of Docker becomes 763.7 MiB, or 0.7 less than before. I realize we can set the flag globally in go-build-system, instead of just for the build phase. Then we don't need to patch Docker, containerd, or anything else that does not use the stock build phase. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm index fc5ee39c8d..a6b9397d35 100644 --- a/guix/build/go-build-system.scm +++ b/guix/build/go-build-system.scm @@ -137,6 +137,9 @@ dependencies, so it should be self-contained." ;; Using the current working directory as GOPATH makes it easier for packagers ;; who need to manipulate the unpacked source code. (setenv "GOPATH" (string-append (getcwd) ":" (getenv "GOPATH"))) + ;; Unconditionally set the -trimpath option to avoid spurious store references + ;; from having multiple GOPATH entries. See . + (setenv "GOFLAGS" "-trimpath") ;; Go 1.13 uses go modules by default. The go build system does not ;; currently support modules, so turn modules off to continue using the old ;; GOPATH behavior. @@ -188,8 +191,6 @@ unpacking." (apply invoke "go" "install" "-v" ; print the name of packages as they are compiled "-x" ; print each command as it is invoked - ;; Trim store references from the compiled binaries. - "-trimpath" ;; Respectively, strip the symbol table and debug ;; information, and the DWARF symbol table. "-ldflags=-s -w" @@ -202,6 +203,9 @@ unpacking." ;; Can this also install commands??? (define* (check #:key tests? import-path #:allow-other-keys) "Run the tests for the package named by IMPORT-PATH." + ;; Remove the global -trimpath option because it can break some test + ;; suites. + (unsetenv "GOFLAGS") (when tests? (invoke "go" "test" import-path)) #t) --=-=-= Content-Type: text/plain This may be a cleaner solution. Thoughts? --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iIUEARYKAC0WIQRNTknu3zbaMQ2ddzTocYulkRQQdwUCYSk/QA8cbWFyaXVzQGdu dS5vcmcACgkQ6HGLpZEUEHe7ggD/TEW7hZyJ2lvB7YjJo2j9VBEgrS1orktACioC KYPcSvoA/j1OmpU9+lCNzF+A5GSROTTacDXpoY8J7zsP2hlMd6AM =KQpw -----END PGP SIGNATURE----- --==-=-=--