From unknown Sat Jun 21 03:31:06 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#70492 <70492@debbugs.gnu.org> To: bug#70492 <70492@debbugs.gnu.org> Subject: Status: [PATCH] build-system: copy: Fix cross-compilation. Reply-To: bug#70492 <70492@debbugs.gnu.org> Date: Sat, 21 Jun 2025 10:31:06 +0000 retitle 70492 [PATCH] build-system: copy: Fix cross-compilation. reassign 70492 guix-patches submitter 70492 dan severity 70492 normal tag 70492 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 21 03:13:18 2024 Received: (at submit) by debbugs.gnu.org; 21 Apr 2024 07:13:18 +0000 Received: from localhost ([127.0.0.1]:41112 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ryRNz-0002XW-Lo for submit@debbugs.gnu.org; Sun, 21 Apr 2024 03:13:17 -0400 Received: from lists.gnu.org ([2001:470:142::17]:54480) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ryRNw-0002WA-KJ for submit@debbugs.gnu.org; Sun, 21 Apr 2024 03:13:14 -0400 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 1ryRNb-00072O-Nf for guix-patches@gnu.org; Sun, 21 Apr 2024 03:12:51 -0400 Received: from fhigh5-smtp.messagingengine.com ([103.168.172.156]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ryRNZ-0008BC-6d; Sun, 21 Apr 2024 03:12:51 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 71F5911400AB; Sun, 21 Apr 2024 03:12:45 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sun, 21 Apr 2024 03:12:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dan.games; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:message-id:mime-version:reply-to :subject:subject:to:to; s=fm1; t=1713683565; x=1713769965; bh=sm jwGDe4mtQX9yoB/9DEM5TgzP0D7EX26RYAQQS9mZk=; b=rkKtZOrncsVH3bw9lJ WGKLTPY1JAvGOXouxSVDW0eBIQIYPO+SED2mat3OUz2A7Uyls8dQXF6TxLl/QWYu sO+UAMuRwllgISD46nqSce19+wpXVpp1z+sb1FCKfyk5zvOaVQgLfzFo1rjyaIQZ SSXOsfHEGfJF5BxcIIPyVhhgDxC+PQUzrzCOCF16ft+sEi393nv7aWjVMsZqTW9v P8enfHiOW07iv0/hnPabMIIRghHOG/yimeHIVxTWDVlFQVAZ9C2ZUEm3dyNA6NxM 4rrfW7/7PwDjXSAW6WcAianBIHpVWXMOPgoYFuyEuNt4YHxbCPbbdov0S26TSoDR 0ysQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1713683565; x=1713769965; bh=smjwGDe4mtQX9 yoB/9DEM5TgzP0D7EX26RYAQQS9mZk=; b=iY1+VkMW0I7SuUiGyrxIsh2DSK3Wh zEB0IgwU66n6AT+G1x8KmfaC7N8YoaharL4ABaYRpCXuQC5+/MulrUPoU3zUDY2M Q6eQ+wULpAnjF8ye/+/G9Vr999ShN7diBAnRZsyHQ2gVxd44MGuQVADxjkC0SQIr 51C1TaGzUhL/w9vSmOegaHwQWNDhGReyh2Rd2H7CoYWBJtAVibKbpvq3YqX1WrP/ cMygVxg9MD9CqSt2lRZU7N8WhULqSl1RS6aP9usauNz8uVEGyljmtgZQh5t82JqC 0uqYRpunjFqw4b362aX0hDcgV3uevKhzJFr/N59dlpZrYPB5l+JDsnmoA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudekiedgudefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdludejmdenucfjughrpefhvf evufffkffogggtgfesthekredtredtjeenucfhrhhomhepuggrnhcuoehisegurghnrdhg rghmvghsqeenucggtffrrghtthgvrhhnpeefveejteeguedtjefhtdekfeehveevgfekhf ehheekteeutefhtdeiuddthfeghfenucffohhmrghinhepghhnuhdrohhrghenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehisegurghnrdhgrg hmvghs X-ME-Proxy: Feedback-ID: i3b5946ed:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 21 Apr 2024 03:12:37 -0400 (EDT) From: dan To: guix-patches@gnu.org Subject: [PATCH] build-system: copy: Fix cross-compilation. Date: Sun, 21 Apr 2024 15:12:30 +0800 Message-ID: <20a614ca2a6064bfa597cd11b7b87ceb926de866.1713682643.git.i@dan.games> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=103.168.172.156; envelope-from=i@dan.games; helo=fhigh5-smtp.messagingengine.com 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: submit Cc: david.elsing@posteo.net, othacehe@gnu.org, ludo@gnu.org, efraim@flashner.co.il, 66866@debbugs.gnu.org, janneke@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) * guix/build-system/copy.scm (lower): Change arguments passed to host-inputs and build-inputs. Change-Id: I2991854b48587ab00ccc03712304e2850727e6b7 --- This patch tries to fix a issue related to grafting when cross-compiling. See https://issues.guix.gnu.org/66866 for more discussion. guix/build-system/copy.scm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/guix/build-system/copy.scm b/guix/build-system/copy.scm index d58931b33c..64bd61a53f 100644 --- a/guix/build-system/copy.scm +++ b/guix/build-system/copy.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2020 Pierre Neidhardt ;;; Copyright © 2021, 2022 Ludovic Courtès ;;; Copyright © 2023 Jonathan Brielmaier +;;; Copyright © 2024 dan ;;; ;;; This file is part of GNU Guix. ;;; @@ -66,13 +67,13 @@ (define* (lower name (bag (name name) (system system) - (host-inputs `(,@(if source - `(("source" ,source)) - '()) - ,@inputs - ;; Keep the standard inputs of 'gnu-build-system'. - ,@(standard-packages))) - (build-inputs native-inputs) + (build-inputs `(,@(if source + `(("source" ,source)) + '()) + ,@inputs + ,@native-inputs + ;; Keep the standard inputs of 'gnu-build-system'. + ,@(standard-packages))) (outputs outputs) (build copy-build) (arguments (strip-keyword-arguments private-keywords arguments)))) base-commit: 38b88d710ea13ba024aed0543bc2862772cdb645 -- 2.41.0 From debbugs-submit-bounces@debbugs.gnu.org Wed May 01 17:40:08 2024 Received: (at 70492) by debbugs.gnu.org; 1 May 2024 21:40:08 +0000 Received: from localhost ([127.0.0.1]:39597 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2HgN-0001DZ-Hp for submit@debbugs.gnu.org; Wed, 01 May 2024 17:40:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53606) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2HgK-0001D2-UZ; Wed, 01 May 2024 17:40:06 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2Hfs-0001IY-Ky; Wed, 01 May 2024 17:39:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=PKTJuTUWxkH1yaMMlZ+oMbsulqQ7RHSARVY7zE5+BHQ=; b=dTixssOHGGxuezOc38/1 Dz8N/Jgb5ZzwZ9DpXtVZmQcAFnV9pAXMEelzxCV4ZrJjCtcKJAhD8zYG9uL7sKGJ+/DepQ9/FfrD1 ++8A9YwZkdIXMxHGf0f8mQ8e7iYDueSP8hpt3olrUOQeRNC52VDibw293AkktLsdhurwWVVPx7ENe 757FT6oLkq6jWMV+7SmboAg7LbXZ2gNeXs44GKHnE5vehOKJAaaPAitKcKI3DkvxOvjhveWNixyNU yzUyD2MXMUixhd4zErDy+wqCRm0dgWuibiFCuv0Gokp1LkvGcpmqmB/CF+LTmfnwClgJRKZ/CcV2t l+VEUa0kpPLBmw==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: dan Subject: Re: bug#66866: Grafting breaks cross-compilation In-Reply-To: <87frwn308k.fsf@dan.games> (dan's message of "Tue, 19 Mar 2024 01:30:31 +0800") References: <87ttnh5b4g.fsf@gnu.org> <86h6ien6bg.fsf@posteo.net> <87frwn308k.fsf@dan.games> Date: Wed, 01 May 2024 23:39:32 +0200 Message-ID: <8734r143fv.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70492 Cc: David Elsing , dev@jpoiret.xyz, Philip McGrath , Mathieu Othacehe , efraim@flashner.co.il, 66866@debbugs.gnu.org, 70492@debbugs.gnu.org, janneke@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, dan skribis: > I spent some time digging into the rabbit hole. After changing=20 > the lower function of the copy-build-system to look more like the=20 > lower function of the gnu-build-system, I'm able to cross compile=20 > alsa-lib without the --no-grafts flag. The changes I made are=20 > like: > > diff --git a/guix/build-system/copy.scm=20 > b/guix/build-system/copy.scm > index d58931b33c..74304b4bfb 100644 > --- a/guix/build-system/copy.scm > +++ b/guix/build-system/copy.scm > @@ -66,13 +66,13 @@ (define* (lower name > (bag > (name name) > (system system) > - (host-inputs `(,@(if source > + (build-inputs `(,@(if source > `(("source" ,source)) > '()) > - ,@inputs > + ,@native-inputs > ;; Keep the standard inputs of=20 > 'gnu-build-system'. > ,@(standard-packages))) > - (build-inputs native-inputs) > + (host-inputs inputs) > (outputs outputs) > (build copy-build) > (arguments (strip-keyword-arguments private-keywords=20 > arguments)))) > > Can we put everything inside build-inputs? From my understanding,=20 > copy-build-system shouldn't care about cross-compilation at all. Intuitively, if =E2=80=98copy-build-system=E2=80=99 is about copying architecture-independent files, then it should do the same thing whether or not we are cross-compiling. However, users can and do add phases whose result is architecture-dependent. Small sample: =E2=80=A2 =E2=80=98desec-certbot-hook=E2=80=99 captures a reference to cu= rl, so it would get the wrong one when cross-compiling if we assumed build-inputs =3D host-inputs. =E2=80=A2 =E2=80=98chez-scheme-for-racket-bootstrap-bootfiles=E2=80=99 bu= ilds stuff when cross-compiling. Philip, could you explain the intent and what you expect here? So it would seem we can=E2=80=99t just assume everything is a native input = like https://issues.guix.gnu.org/70492 does. Now, as David and you found out, the use of inputs in build-system/copy.scm:lower is bogus. It seems that it can be fixed by following the intended definition of build/host inputs, as David suggested: --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/guix/build-system/copy.scm b/guix/build-system/copy.scm index d58931b33c2..cf0214320bf 100644 --- a/guix/build-system/copy.scm +++ b/guix/build-system/copy.scm @@ -66,13 +66,13 @@ (define* (lower name (bag (name name) (system system) - (host-inputs `(,@(if source + (build-inputs `(,@(if source `(("source" ,source)) '()) - ,@inputs - ;; Keep the standard inputs of 'gnu-build-system'. - ,@(standard-packages))) - (build-inputs native-inputs) + ,@native-inputs + ;; Keep the standard inputs of 'gnu-build-system'. + ,@(standard-packages))) + (host-inputs inputs) (outputs outputs) (build copy-build) (arguments (strip-keyword-arguments private-keywords arguments)))) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable But wait! That=E2=80=99s all theoretical because the bag always has (target= #f) and =E2=80=98copy-build=E2=80=99 bundles build and host inputs together, as= if doing a native build. So it seems like https://issues.guix.gnu.org/70492 (putting everything in =E2=80=98build-inputs=E2=80=99) is OK, after all. But still, there seem to be some expectation that =E2=80=98copy-build-syste= m=E2=80=99 can support cross-compilation for real, so maybe we should add a =E2=80=98copy-cross-build=E2=80=99 procedure in addition to the patch above. Thoughts? Ludo=E2=80=99. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun May 12 11:39:44 2024 Received: (at 70492) by debbugs.gnu.org; 12 May 2024 15:39:44 +0000 Received: from localhost ([127.0.0.1]:55037 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s6BIe-0002BJ-DH for submit@debbugs.gnu.org; Sun, 12 May 2024 11:39:44 -0400 Received: from mout01.posteo.de ([185.67.36.65]:46713) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s6BIa-0002B7-Ru for 70492@debbugs.gnu.org; Sun, 12 May 2024 11:39:43 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 2704824002F for <70492@debbugs.gnu.org>; Sun, 12 May 2024 17:39:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1715528375; bh=lSguE+CZvNnwKOa0LLUMV0hT9dKRRNCXAfLjenBcf9w=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=PKihVCVmgW//GKvj0gdfu7fPHJkBTvEXlVnIWBkcdKj0j5W+lbFmCYUdnzgOChcUh nXmCNQyPY6zf67TYQer3jjcLOtegWu6f5rLoI26bhySI5fgOvkIl3wrdE2QZzUtxfP kPGHSgsCqpEiSZeh88Q3IAt5+1k6LNXP+lNOxgNVklR8TI9NtUtSNJXHk/okA26rXl 41ZZ9knB6naIXzsKyz8S91xcdrW3SAgW/Xb7cVz+sjNojkOBwkyVD93Xnc+oEZZSp4 XMzyntL9Duvv9HsWdPxvJTQ//8+EWaf9q/BNerkVh2dhPvNxr0glhDa507OWOnVwlR /OFPVOIEsgRDg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VcmyF21Zfz9rxL; Sun, 12 May 2024 17:39:32 +0200 (CEST) From: David Elsing To: Ludovic =?utf-8?Q?Court=C3=A8s?= , dan Subject: Re: bug#66866: Grafting breaks cross-compilation In-Reply-To: <8734r143fv.fsf_-_@gnu.org> References: <87ttnh5b4g.fsf@gnu.org> <86h6ien6bg.fsf@posteo.net> <87frwn308k.fsf@dan.games> <8734r143fv.fsf_-_@gnu.org> Date: Sun, 12 May 2024 15:39:32 +0000 Message-ID: <86o79byr7v.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70492 Cc: dev@jpoiret.xyz, Philip McGrath , Mathieu Othacehe , efraim@flashner.co.il, 70492@debbugs.gnu.org, 66866@debbugs.gnu.org, janneke@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hello, I think I finally understand why the problem only occurs with grafts if a dependency uses copy-build-system. It is actually somewhat complicated. When a package is lowered into a derivation by 'package->derivation' in guix/packages.scm, a list of potentially applicable grafts is created by the 'bag-grafts' procedure. This works by first traversing the bag for native packages (where bag-build-inputs and bag-target-inputs are followed recursively; and also bag-host-inputs if not cross building) and building the native derivations of the grafted versions of the packages which have a replacement (such as glibc at the time of writing). Building the grafted package (in the 'input-graft' procedure) is done again with 'package->derivation', which eventually calls 'graft-derivation' in guix/grafts.scm, which in turn calls 'non-self-references', where the ungrafted package is actually built (ignoring the store monad indirection), not just its derivation. In the case of cross builds, the bag is also traversed for the target dependencies, where the bag-host-inputs are followed recursively. Analogously, this causes the ungrafted packages and their ungrafted replacement to be cross built to compute the grafted derivations. As dan found out, the 'lower' procedure in guix/build-system/copy.scm incorrectly puts standard-packages into the host inputs. They contain the glibc-final package in gnu/packages/commencement.scm (which inherits the replacement of glibc). Because copy-build-system puts them into bag-host-inputs, the package replacement of the glibc-final package is then cross built without grafts when calculating its grafted derivation, which it does not support. Note that the glibc-final package and its package replacement are distinct from the glibc package and its replacement in gnu/packages/base.scm. I confirmed this by running --8<---------------cut here---------------start------------->8--- ,use (guix) (with-store store (run-with-store store (package->cross-derivation (package= -replacement (@@ (gnu packages commencement) glibc-final)) "i686-linux-gnu"= #:graft? #f))) --8<---------------cut here---------------end--------------->8--- in the REPL, which returns the same incorrect glibc derivation that is attempted to be built as a dependency when running `guix build alsa-lib --target=3Di686-linux-gnu`. It is actually possible to compute the graft derivations only when needed by a store reference (which does not change the derivation of the grafted package). Then, this problem does not occur even without the fix for the copy-build-system, as the invalid derivations are never actually built. With substitutes or after running GC, this may even prevent building a package with replacement when the requested package output which (transitively) depends on it has no (transitive) store reference to it. I made a patch for that here: https://issues.guix.gnu.org/70895 Regarding the changes to the copy-build-system: Ludovic Court=C3=A8s writes: > But still, there seem to be some expectation that =E2=80=98copy-build-sys= tem=E2=80=99 > can support cross-compilation for real, so maybe we should add a > =E2=80=98copy-cross-build=E2=80=99 procedure in addition to the patch abo= ve. In guix/build-system/copy.scm, it is described as an extension of gnu-build-system and the manual says "It adds much of the gnu-build-system packages to the set of inputs. Because of this, the copy-build-system does not require all the boilerplate code often needed for the trivial-build-system." Therefore, I think it makes sense to add the copy-cross-build procedure so that copy-build-system actually behaves like gnu-build-system. Cheers, David