From patchwork Fri Aug 27 19:38:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marius Bakke X-Patchwork-Id: 32341 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A6E6827BBE4; Fri, 27 Aug 2021 20:39:14 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6041827BBE1 for ; Fri, 27 Aug 2021 20:39:12 +0100 (BST) Received: from localhost ([::1]:41652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJhh0-0008U9-Up for patchwork@mira.cbaines.net; Fri, 27 Aug 2021 15:39:10 -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 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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: ...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. This may be a cleaner solution. Thoughts? 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)