Message ID | 0c15a853521c4a9cfa8f4c3558e3aee9fb0a9d91.1720195563.git.mail@cbaines.net |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B48E727BBEA; Fri, 5 Jul 2024 17:07:43 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4C35527BBE2 for <patchwork@mira.cbaines.net>; Fri, 5 Jul 2024 17:07:43 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces@gnu.org>) id 1sPlSg-0005eO-00; Fri, 05 Jul 2024 12:07:02 -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 <Debian-debbugs@debbugs.gnu.org>) id 1sPlSe-0005dy-Un for guix-patches@gnu.org; Fri, 05 Jul 2024 12:07:00 -0400 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 <Debian-debbugs@debbugs.gnu.org>) id 1sPlSe-00044P-MF for guix-patches@gnu.org; Fri, 05 Jul 2024 12:07:00 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1sPlSh-0003Of-HH; Fri, 05 Jul 2024 12:07:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70985] [PATCH v2 5/6] gnu: rust: Guard against cross-libc returning #f. Resent-From: Christopher Baines <mail@cbaines.net> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: efraim@flashner.co.il, guix-patches@gnu.org Resent-Date: Fri, 05 Jul 2024 16:07:03 +0000 Resent-Message-ID: <handler.70985.B70985.172019560312991@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70985 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70985@debbugs.gnu.org Cc: Efraim Flashner <efraim@flashner.co.il> X-Debbugs-Original-Xcc: Efraim Flashner <efraim@flashner.co.il> Received: via spool by 70985-submit@debbugs.gnu.org id=B70985.172019560312991 (code B ref 70985); Fri, 05 Jul 2024 16:07:03 +0000 Received: (at 70985) by debbugs.gnu.org; 5 Jul 2024 16:06:43 +0000 Received: from localhost ([127.0.0.1]:44851 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1sPlSM-0003NO-LT for submit@debbugs.gnu.org; Fri, 05 Jul 2024 12:06:42 -0400 Received: from mira.cbaines.net ([212.71.252.8]:43916) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mail@cbaines.net>) id 1sPlSK-0003Mw-RM for 70985@debbugs.gnu.org; Fri, 05 Jul 2024 12:06:41 -0400 Received: from localhost (nat-inria-guest-32-gw-01-bso.bordeaux.inria.fr [194.199.1.32]) by mira.cbaines.net (Postfix) with ESMTPSA id 2038A27BBEC for <70985@debbugs.gnu.org>; Fri, 5 Jul 2024 17:06:07 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id eae7c300 for <70985@debbugs.gnu.org>; Fri, 5 Jul 2024 16:06:05 +0000 (UTC) From: Christopher Baines <mail@cbaines.net> Date: Fri, 5 Jul 2024 18:06:02 +0200 Message-ID: <0c15a853521c4a9cfa8f4c3558e3aee9fb0a9d91.1720195563.git.mail@cbaines.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <9f11c96f25ba0f8f0c63ad3d6f5d6295035e7cc7.1720195563.git.mail@cbaines.net> References: <9f11c96f25ba0f8f0c63ad3d6f5d6295035e7cc7.1720195563.git.mail@cbaines.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches |
Series |
[bug#70985,v2,1/6] guix: packages: Add new &package-unsupported-target-error.
|
|
Commit Message
Christopher Baines
July 5, 2024, 4:06 p.m. UTC
* gnu/packages/rust.scm (make-rust-sysroot/implementation): Guard against cross-libc returning #f. Change-Id: Ia0d5c889c6f5cd3478ad985c79feb9ba1c472c29 --- gnu/packages/rust.scm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
Comments
On Fri, Jul 05, 2024 at 06:06:02PM +0200, Christopher Baines wrote: > * gnu/packages/rust.scm (make-rust-sysroot/implementation): Guard against > cross-libc returning #f. > > Change-Id: Ia0d5c889c6f5cd3478ad985c79feb9ba1c472c29 > --- > gnu/packages/rust.scm | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm > index a385344473..f1de34b277 100644 > --- a/gnu/packages/rust.scm > +++ b/gnu/packages/rust.scm > @@ -73,7 +73,9 @@ (define-module (gnu packages rust) > #:use-module (ice-9 match) > #:use-module (ice-9 optargs) > #:use-module (srfi srfi-1) > - #:use-module (srfi srfi-26)) > + #:use-module (srfi srfi-26) > + #:use-module (srfi srfi-34) > + #:use-module (srfi srfi-35)) > > ;; This is the hash for the empty file, and the reason it's relevant is not > ;; the most obvious. > @@ -1464,7 +1466,11 @@ (define make-rust-sysroot/implementation > (modify-inputs (package-native-inputs base-rust) > (prepend (cross-gcc target > #:libc (cross-libc target)) > - (cross-libc target) > + (or (cross-libc target) ; could be #f > + (raise (condition > + (&package-unsupported-target-error > + (package (libc-for-target target)) > + (target target))))) > (cross-binutils target))))) > (properties > `((hidden? . #t) > -- > 2.45.2 rust does support architectures without a libc, for example the mingw targets a few lines above this snippet. I think it would make more sense to only include (cross-libc target) and not if not. I just tried building zoxide for powerpc-linux-gnu without (cross-libc target) and it tried to link with the x86_64 libc, so it looks like it is necessary where it is available. How about we make this section even worse with: (if (false-if-exception (cross-libc target)) (modify-inputs ... (cross-libc target) ...) (modify-inputs ...)) ; no (cross-libc target) In the meantime, I'll try to figure something out for actually putting everything inside one modify-inputs so we don't have an ever expanding number of them.
On Fri, Jul 05, 2024 at 06:06:02PM +0200, Christopher Baines wrote: > * gnu/packages/rust.scm (make-rust-sysroot/implementation): Guard against > cross-libc returning #f. > > Change-Id: Ia0d5c889c6f5cd3478ad985c79feb9ba1c472c29 > --- > gnu/packages/rust.scm | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm > index a385344473..f1de34b277 100644 > --- a/gnu/packages/rust.scm > +++ b/gnu/packages/rust.scm > @@ -73,7 +73,9 @@ (define-module (gnu packages rust) > #:use-module (ice-9 match) > #:use-module (ice-9 optargs) > #:use-module (srfi srfi-1) > - #:use-module (srfi srfi-26)) > + #:use-module (srfi srfi-26) > + #:use-module (srfi srfi-34) > + #:use-module (srfi srfi-35)) > > ;; This is the hash for the empty file, and the reason it's relevant is not > ;; the most obvious. > @@ -1464,7 +1466,11 @@ (define make-rust-sysroot/implementation > (modify-inputs (package-native-inputs base-rust) > (prepend (cross-gcc target > #:libc (cross-libc target)) > - (cross-libc target) > + (or (cross-libc target) ; could be #f > + (raise (condition > + (&package-unsupported-target-error > + (package (libc-for-target target)) > + (target target))))) > (cross-binutils target))))) > (properties > `((hidden? . #t) > -- > 2.45.2 This will probably work: (native-inputs `((,(string-append "gcc-cross-" target) ,(cross-gcc target #:libc (cross-libc target))) ,(when (false-if-exception (cross-libc target)) `(,(string-append "glibc-cross-" target) ,(cross-libc target))) (,(string-append "binutils-cross-" target) ,(cross-binutils target)) ,(when (target-mingw? target) (if (string=? "i686-w64-mingw32" target) `("mingw-w64-i686-winpthreads" ,mingw-w64-i686-winpthreads) `("mingw-w64-x86_64-winpthreads" ,mingw-w64-x86_64-winpthreads))) ,@(package-native-inputs base-rust)))
Efraim Flashner <efraim@flashner.co.il> writes: > On Fri, Jul 05, 2024 at 06:06:02PM +0200, Christopher Baines wrote: >> * gnu/packages/rust.scm (make-rust-sysroot/implementation): Guard against >> cross-libc returning #f. >> >> Change-Id: Ia0d5c889c6f5cd3478ad985c79feb9ba1c472c29 >> --- >> gnu/packages/rust.scm | 10 ++++++++-- >> 1 file changed, 8 insertions(+), 2 deletions(-) >> >> diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm >> index a385344473..f1de34b277 100644 >> --- a/gnu/packages/rust.scm >> +++ b/gnu/packages/rust.scm >> @@ -73,7 +73,9 @@ (define-module (gnu packages rust) >> #:use-module (ice-9 match) >> #:use-module (ice-9 optargs) >> #:use-module (srfi srfi-1) >> - #:use-module (srfi srfi-26)) >> + #:use-module (srfi srfi-26) >> + #:use-module (srfi srfi-34) >> + #:use-module (srfi srfi-35)) >> >> ;; This is the hash for the empty file, and the reason it's relevant is not >> ;; the most obvious. >> @@ -1464,7 +1466,11 @@ (define make-rust-sysroot/implementation >> (modify-inputs (package-native-inputs base-rust) >> (prepend (cross-gcc target >> #:libc (cross-libc target)) >> - (cross-libc target) >> + (or (cross-libc target) ; could be #f >> + (raise (condition >> + (&package-unsupported-target-error >> + (package (libc-for-target target)) >> + (target target))))) >> (cross-binutils target))))) >> (properties >> `((hidden? . #t) >> -- >> 2.45.2 > > This will probably work: > > (native-inputs > `((,(string-append "gcc-cross-" target) ,(cross-gcc target > #:libc (cross-libc target))) > ,(when (false-if-exception (cross-libc target)) > `(,(string-append "glibc-cross-" target) ,(cross-libc target))) > (,(string-append "binutils-cross-" target) ,(cross-binutils target)) > ,(when (target-mingw? target) > (if (string=? "i686-w64-mingw32" target) > `("mingw-w64-i686-winpthreads" ,mingw-w64-i686-winpthreads) > `("mingw-w64-x86_64-winpthreads" ,mingw-w64-x86_64-winpthreads))) > ,@(package-native-inputs base-rust))) Thanks for taking a look. In the latest patches cross-libc isn't changing to raise an exception (as that ended up being too complicated), so I'm not sure the false-if-exception is going to work. I'd also maybe stick with modify-inputs, as at least that avoids the older inputs style. If I've followed your first email correctly, are you thinking of something like this? (native-inputs (if (target-mingw? target) (modify-inputs (package-native-inputs base-rust) (prepend (cross-gcc target #:libc (cross-libc target)) (cross-binutils target) (if (string=? "i686-w64-mingw32" target) mingw-w64-i686-winpthreads mingw-w64-x86_64-winpthreads))) (modify-inputs (or (and=> (cross-libc target) (lambda (x-libc) (modify-inputs (package-native-inputs base-rust) (prepend x-libc)))) (package-native-inputs base-rust)) (prepend (cross-gcc target #:libc (cross-libc target)) (cross-binutils target)))))
On Tue, Jul 09, 2024 at 11:25:04AM +0200, Christopher Baines wrote: > Efraim Flashner <efraim@flashner.co.il> writes: > > > On Fri, Jul 05, 2024 at 06:06:02PM +0200, Christopher Baines wrote: > >> * gnu/packages/rust.scm (make-rust-sysroot/implementation): Guard against > >> cross-libc returning #f. > >> > >> Change-Id: Ia0d5c889c6f5cd3478ad985c79feb9ba1c472c29 > >> --- > >> gnu/packages/rust.scm | 10 ++++++++-- > >> 1 file changed, 8 insertions(+), 2 deletions(-) > >> > >> diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm > >> index a385344473..f1de34b277 100644 > >> --- a/gnu/packages/rust.scm > >> +++ b/gnu/packages/rust.scm > >> @@ -73,7 +73,9 @@ (define-module (gnu packages rust) > >> #:use-module (ice-9 match) > >> #:use-module (ice-9 optargs) > >> #:use-module (srfi srfi-1) > >> - #:use-module (srfi srfi-26)) > >> + #:use-module (srfi srfi-26) > >> + #:use-module (srfi srfi-34) > >> + #:use-module (srfi srfi-35)) > >> > >> ;; This is the hash for the empty file, and the reason it's relevant is not > >> ;; the most obvious. > >> @@ -1464,7 +1466,11 @@ (define make-rust-sysroot/implementation > >> (modify-inputs (package-native-inputs base-rust) > >> (prepend (cross-gcc target > >> #:libc (cross-libc target)) > >> - (cross-libc target) > >> + (or (cross-libc target) ; could be #f > >> + (raise (condition > >> + (&package-unsupported-target-error > >> + (package (libc-for-target target)) > >> + (target target))))) > >> (cross-binutils target))))) > >> (properties > >> `((hidden? . #t) > >> -- > >> 2.45.2 > > > > This will probably work: > > > > (native-inputs > > `((,(string-append "gcc-cross-" target) ,(cross-gcc target > > #:libc (cross-libc target))) > > ,(when (false-if-exception (cross-libc target)) > > `(,(string-append "glibc-cross-" target) ,(cross-libc target))) > > (,(string-append "binutils-cross-" target) ,(cross-binutils target)) > > ,(when (target-mingw? target) > > (if (string=? "i686-w64-mingw32" target) > > `("mingw-w64-i686-winpthreads" ,mingw-w64-i686-winpthreads) > > `("mingw-w64-x86_64-winpthreads" ,mingw-w64-x86_64-winpthreads))) > > ,@(package-native-inputs base-rust))) > > Thanks for taking a look. In the latest patches cross-libc isn't > changing to raise an exception (as that ended up being too complicated), > so I'm not sure the false-if-exception is going to work. false-if-exception should work. We use it a couple of times in golang packaging to skip the tests if we're building with gccgo. (unless ;; The tests fail when run with gccgo. (false-if-exception (search-input-file inputs "/bin/gccgo")) (apply (assoc-ref %standard-phases 'check) args))))))) > I'd also maybe stick with modify-inputs, as at least that avoids the > older inputs style. > > If I've followed your first email correctly, are you thinking of > something like this? > > (native-inputs > (if (target-mingw? target) > (modify-inputs (package-native-inputs base-rust) > (prepend (cross-gcc target > #:libc (cross-libc target)) > (cross-binutils target) > (if (string=? "i686-w64-mingw32" target) > mingw-w64-i686-winpthreads > mingw-w64-x86_64-winpthreads))) > (modify-inputs (or (and=> (cross-libc target) > (lambda (x-libc) > (modify-inputs > (package-native-inputs base-rust) > (prepend x-libc)))) > (package-native-inputs base-rust)) > (prepend (cross-gcc target > #:libc (cross-libc target)) > (cross-binutils target))))) Thanks, I hate it :) That said, if it works then it's fine. (I lose my confidence from (cross-libc target) getting renamed to x-libc) I played around with it a bit more. The problem is that we can only logic our way around before modify-inputs or inside prepend/append/delete, so options are a bit limited as to what we can do. I came up with the following, which I think should also work: (native-inputs (modify-inputs (package-native-inputs base-rust) (prepend (cross-binutils target)) (prepend (cond ((and (target-mingw? target) (target-x86-32? target)) mingw-w64-i686-winpthreads) ((and (target-mingw? target) (target-x86-64? target)) mingw-w64-x86_64-winpthreads) ((or (target-linux? target) (target-hurd? target)) (cross-libc target)) ;; We need something, and duplicating cross-binutils ;; doesn't cause any problems. (#t (cross-binutils target)))) (prepend (cross-gcc target #:libc (cross-libc target))))) I don't like the '#t' branch of the cond, but it doesn't seem to break anything. And we're explicit about who gets cross-libc. I would like something like the following to work, but some of the inputs get lost (native-inputs (modify-inputs (package-native-inputs base-rust) (prepend (cond ((and (target-mingw? target) (target-x86-32? target)) (cross-gcc target #:libc (cross-libc target)) mingw-w64-i686-winpthreads (cross-binutils target)) ((and (target-mingw? target) (target-x86-64? target)) (cross-gcc target #:libc (cross-libc target)) mingw-w64-x86_64-winpthreads (cross-binutils target)) ((or (target-linux? target) (target-hurd? target)) (cross-gcc target #:libc (cross-libc target)) (cross-libc target) (cross-binutils target)) (else (cross-gcc target #:libc (cross-libc target)) (cross-binutils target))))))
Efraim Flashner <efraim@flashner.co.il> writes: >> I'd also maybe stick with modify-inputs, as at least that avoids the >> older inputs style. >> >> If I've followed your first email correctly, are you thinking of >> something like this? >> >> (native-inputs >> (if (target-mingw? target) >> (modify-inputs (package-native-inputs base-rust) >> (prepend (cross-gcc target >> #:libc (cross-libc target)) >> (cross-binutils target) >> (if (string=? "i686-w64-mingw32" target) >> mingw-w64-i686-winpthreads >> mingw-w64-x86_64-winpthreads))) >> (modify-inputs (or (and=> (cross-libc target) >> (lambda (x-libc) >> (modify-inputs >> (package-native-inputs base-rust) >> (prepend x-libc)))) >> (package-native-inputs base-rust)) >> (prepend (cross-gcc target >> #:libc (cross-libc target)) >> (cross-binutils target))))) > > Thanks, I hate it :) That said, if it works then it's fine. (I lose my > confidence from (cross-libc target) getting renamed to x-libc) > > I played around with it a bit more. The problem is that we can only > logic our way around before modify-inputs or inside > prepend/append/delete, so options are a bit limited as to what we can > do. I came up with the following, which I think should also work: > > (native-inputs > (modify-inputs (package-native-inputs base-rust) > (prepend (cross-binutils target)) > (prepend > (cond ((and (target-mingw? target) > (target-x86-32? target)) > mingw-w64-i686-winpthreads) > ((and (target-mingw? target) > (target-x86-64? target)) > mingw-w64-x86_64-winpthreads) > ((or (target-linux? target) > (target-hurd? target)) > (cross-libc target)) > ;; We need something, and duplicating cross-binutils > ;; doesn't cause any problems. > (#t (cross-binutils target)))) > (prepend (cross-gcc target > #:libc (cross-libc target))))) I looked at this further and actually tried building the derivations for different targets, and realised that there needs to be a platform-rust-target set for it to work. So maybe we don't need to bother with the inputs here and can just add a guard at the top, e.g. (define make-rust-sysroot/implementation (mlambda (target base-rust) + (unless (platform-rust-target (lookup-platform-by-target target)) + (raise + (condition + (&package-unsupported-target-error + (package base-rust) + (target target))))) + I've sent a new patch series to this effect.
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm index a385344473..f1de34b277 100644 --- a/gnu/packages/rust.scm +++ b/gnu/packages/rust.scm @@ -73,7 +73,9 @@ (define-module (gnu packages rust) #:use-module (ice-9 match) #:use-module (ice-9 optargs) #:use-module (srfi srfi-1) - #:use-module (srfi srfi-26)) + #:use-module (srfi srfi-26) + #:use-module (srfi srfi-34) + #:use-module (srfi srfi-35)) ;; This is the hash for the empty file, and the reason it's relevant is not ;; the most obvious. @@ -1464,7 +1466,11 @@ (define make-rust-sysroot/implementation (modify-inputs (package-native-inputs base-rust) (prepend (cross-gcc target #:libc (cross-libc target)) - (cross-libc target) + (or (cross-libc target) ; could be #f + (raise (condition + (&package-unsupported-target-error + (package (libc-for-target target)) + (target target))))) (cross-binutils target))))) (properties `((hidden? . #t)