From patchwork Mon Aug 23 20:51:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 32240 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 2FA4927BC78; Mon, 23 Aug 2021 21:53:18 +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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable 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 A51FA27BC6B for ; Mon, 23 Aug 2021 21:53:17 +0100 (BST) Received: from localhost ([::1]:33520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mIGwW-0008LY-Kj for patchwork@mira.cbaines.net; Mon, 23 Aug 2021 16:53:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIGwI-0008KS-LB for guix-patches@gnu.org; Mon, 23 Aug 2021 16:53:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59375) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mIGwI-0001EH-Ai for guix-patches@gnu.org; Mon, 23 Aug 2021 16:53:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mIGwI-0000SC-9Q for guix-patches@gnu.org; Mon, 23 Aug 2021 16:53:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50174] [PATCH core-updates-frozen 1/2] gnu: make-bootstrap: Fix build of static gawk. Resent-From: Thiago Jung Bauermann Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 23 Aug 2021 20:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50174 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50174@debbugs.gnu.org Cc: Thiago Jung Bauermann X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16297519301678 (code B ref -1); Mon, 23 Aug 2021 20:53:02 +0000 Received: (at submit) by debbugs.gnu.org; 23 Aug 2021 20:52:10 +0000 Received: from localhost ([127.0.0.1]:42688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mIGvR-0000Qz-CS for submit@debbugs.gnu.org; Mon, 23 Aug 2021 16:52:10 -0400 Received: from lists.gnu.org ([209.51.188.17]:35540) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mIGvM-0000Qm-0Y for submit@debbugs.gnu.org; Mon, 23 Aug 2021 16:52:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIGvK-0007Mm-4Q for guix-patches@gnu.org; Mon, 23 Aug 2021 16:52:03 -0400 Received: from mx.kolabnow.com ([95.128.36.42]:63078) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mIGvE-0000KC-3X for guix-patches@gnu.org; Mon, 23 Aug 2021 16:52:00 -0400 Received: from localhost (unknown [127.0.0.1]) by ext-mx-out001.mykolab.com (Postfix) with ESMTP id 3D9B0679 for ; Mon, 23 Aug 2021 22:51:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:content-type:content-type:mime-version :message-id:date:date:subject:subject:from:from:received :received:received; s=dkim20160331; t=1629751908; x=1631566309; bh=kPxGyJproYxkbVySbjQueetwDLNDFK0K3i9tyvh0vQ4=; b=T5k3j+f+Wxsv nebyya6kfkVlWWtVZxB0z+6CLE0Mb3au94xFWog7NnqRRXSQGXwyUOclqYzLSOKE CXZR0NWG8j9O30nxrhG6cCs6j+cZYRGzy1Xvw0XOh+dsyVi5ASAsu2S4sPQHwDtE /5K2KFS5fTlG6k0+5l/Hp3Quy8P+WcviJphauSLUE+FBfeh5W40zguajarnJdaiu pd/3M74qFFlP6Ohp5n0rm+yZNBrhgMdyiB6KOenEeqFoom66BtpBSgUab681iuMe pJsFwt2bETNF3cecswhhd038nfrz7fabqG6Kr+ycmM12d6Yu3qfICrM+X4oAYA4L eJbWnTFVbLFIy20SBfBZW+LMZyqGpB7GOrRqd5enpdeIch095n1ptuawMyeB0qwJ ueihtzGuSAlqI2mwXZoZ3PvzzU62kRMw/7sxanzGZV9cqyYF8SiHMK1aydMAxzID AQTT5W22jDUKq7TqjS3BtgSeeNetkYSHj97jxB48xYzgDhU0xDB+Kp3Vu+8h/5Mp 6ZL3/ERcjSxRiLQAtCFrhRrV9pdiGm5h3EbwjdGvCtyre0NE4J6lacjzn+npZs97 oXDTuj9dGMgbnsdWQ68XFXMS5cIYn9vbB8JNI5ndAOd4WZwxI2v0t+X1whamVcfg nivbuL21Meod8I+uvBrSIK5Tx3Rv7AQ= X-Virus-Scanned: amavisd-new at mykolab.com Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out001.mykolab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id srBTMHvZ0QTf for ; Mon, 23 Aug 2021 22:51:48 +0200 (CEST) Received: from int-mx001.mykolab.com (unknown [10.9.13.1]) by ext-mx-out001.mykolab.com (Postfix) with ESMTPS id 29B08279 for ; Mon, 23 Aug 2021 22:51:47 +0200 (CEST) Received: from ext-subm003.mykolab.com (unknown [10.9.6.3]) by int-mx001.mykolab.com (Postfix) with ESMTPS id 196518A8; Mon, 23 Aug 2021 22:51:46 +0200 (CEST) Date: Mon, 23 Aug 2021 17:51:27 -0300 Message-Id: <20210823205127.27102-1-bauermann@kolabnow.com> MIME-Version: 1.0 Received-SPF: pass client-ip=95.128.36.42; envelope-from=bauermann@kolabnow.com; helo=mx.kolabnow.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Thiago Jung Bauermann X-ACL-Warn: , Thiago Jung Bauermann via Guix-patches X-Patchwork-Original-From: Thiago Jung Bauermann via Guix-patches via From: Thiago Jung Bauermann X-getmail-retrieved-from-mailbox: Patches * gnu/packages/make-bootstrap.scm (%static-inputs)[finalize-with-ld-flags]: New function. [map]: Add new clause to match three elements. [map]: Add linker option. * guix/build-system/gnu.scm (static-package): Add ‘#:ld-flags’ keyword argument. --- Hello, gawk for ‘static-binaries-tarball’ is failing to build natively, at least for x86_64-linux¹ and powerpc64le-linux. On both of them, the problem is the same: --8<---------------cut here---------------start------------->8--- ld: ext.o: in function `load_ext': /tmp/guix-build-gawk-5.1.0.drv-0/gawk-5.1.0/ext.c:59: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking ld: /gnu/store/qmgsfxm3ad5n7bi947n7xw0wq86blqr9-glibc-2.33-static/lib/libc.a(getopt.o): in function `_getopt_internal_r': (.text+0x6e0): multiple definition of `_getopt_internal_r'; support/libsupport.a(getopt.o):/tmp/guix-build-gawk-5.1.0.drv-0/gawk-5.1.0/support/getopt.c:404: first defined here ld: /gnu/store/qmgsfxm3ad5n7bi947n7xw0wq86blqr9-glibc-2.33-static/lib/libc.a(getopt.o): in function `_getopt_internal': (.text+0xcc0): multiple definition of `_getopt_internal'; support/libsupport.a(getopt.o):/tmp/guix-build-gawk-5.1.0.drv-0/gawk-5.1.0/support/getopt.c:1187: first defined here ld: /gnu/store/qmgsfxm3ad5n7bi947n7xw0wq86blqr9-glibc-2.33-static/lib/libc.a(getopt.o):(.data+0x8): multiple definition of `optind'; support/libsupport.a(getopt.o):/gnu/store/zy7zwhxxbphqqmigp17j54dpbpz6wr38-glibc-2.33/include/bits/getopt_core.h:50: first defined here ld: /gnu/store/qmgsfxm3ad5n7bi947n7xw0wq86blqr9-glibc-2.33-static/lib/libc.a(getopt.o):(.data+0x4): multiple definition of `opterr'; support/libsupport.a(getopt.o):/gnu/store/zy7zwhxxbphqqmigp17j54dpbpz6wr38-glibc-2.33/include/bits/getopt_core.h:55: first defined here ld: /gnu/store/qmgsfxm3ad5n7bi947n7xw0wq86blqr9-glibc-2.33-static/lib/libc.a(getopt.o):(.data+0x0): multiple definition of `optopt'; support/libsupport.a(getopt.o):/gnu/store/zy7zwhxxbphqqmigp17j54dpbpz6wr38-glibc-2.33/include/bits/getopt_core.h:59: first defined here ld: /gnu/store/qmgsfxm3ad5n7bi947n7xw0wq86blqr9-glibc-2.33-static/lib/libc.a(getopt.o): in function `getopt': (.text+0xd20): multiple definition of `getopt'; support/libsupport.a(getopt.o):/tmp/guix-build-gawk-5.1.0.drv-0/gawk-5.1.0/support/getopt.c:1206: first defined here collect2: error: ld returned 1 exit status make[2]: *** [Makefile:663: gawk] Error 1 make[2]: Leaving directory '/tmp/guix-build-gawk-5.1.0.drv-0/gawk-5.1.0' --8<---------------cut here---------------end--------------->8--- This patch fixes it by passing “--allow-multiple-definition” to the linker. Judging by the CI results, cross-builds seems to be working. I haven’t looked into what’s different about them. NB: I wasn’t sure how to write a changelog for ‘%static-inputs’ so I got a bit creative. ¹ https://ci.guix.gnu.org/build/502639/details gnu/packages/make-bootstrap.scm | 14 +++++++++++--- guix/build-system/gnu.scm | 8 ++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm index 12e59e9f8383..79eb9d60026f 100644 --- a/gnu/packages/make-bootstrap.scm +++ b/gnu/packages/make-bootstrap.scm @@ -260,10 +260,15 @@ for `sh' in $PATH, and without nscd, and with static NSS modules." `(modify-phases ,phases (delete 'fix-egrep-and-fgrep))))))) (finalize (compose static-package - package-with-relocatable-glibc))) + package-with-relocatable-glibc)) + (finalize-with-ld-flags (lambda (pkg ld-flags) + (package-with-relocatable-glibc + (static-package pkg #:ld-flags ld-flags))))) `(,@(map (match-lambda ((name package) - (list name (finalize package)))) + (list name (finalize package))) + ((name package ld-flags) + (list name (finalize-with-ld-flags package ld-flags)))) `(("tar" ,tar) ("gzip" ,gzip) ("bzip2" ,bzip2) @@ -272,7 +277,10 @@ for `sh' in $PATH, and without nscd, and with static NSS modules." ("coreutils" ,coreutils) ("sed" ,sed) ("grep" ,grep) - ("gawk" ,gawk))) + ("gawk" ,gawk + ;; gawk's gnulib defines some getopt symbols which are also in + ;; libc.a so this linker option is needed for a static build. + "-Wl,--allow-multiple-definition"))) ("bash" ,static-bash)))) (define %static-binaries diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm index ea91be5bcd0c..acbd5b3a0de4 100644 --- a/guix/build-system/gnu.scm +++ b/guix/build-system/gnu.scm @@ -210,7 +210,7 @@ flags for VARIABLE, the associated value is augmented." "A version of P linked with `-static-gcc'." (package-with-extra-configure-variable p "LDFLAGS" "-static-libgcc")) -(define* (static-package p #:key (strip-all? #t)) +(define* (static-package p #:key (strip-all? #t) (ld-flags #f)) "Return a statically-linked version of package P. If STRIP-ALL? is true, use `--strip-all' as the arguments to `strip'." (package (inherit p) @@ -220,7 +220,11 @@ use `--strip-all' as the arguments to `strip'." #:strip-flags '("--strip-unneeded"))))) (substitute-keyword-arguments a ((#:configure-flags flags) - `(cons* "--disable-shared" "LDFLAGS=-static" ,flags)) + `(cons* "--disable-shared" (string-append "LDFLAGS=-static" + (if ,ld-flags + (string-append " " ,ld-flags) + "")) + ,flags)) ((#:strip-flags flags) (if strip-all? ''("--strip-all")