guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#70985] [PATCH v2 5/6] gnu: rust: Guard against cross-libc returning


From: Christopher Baines
Subject: [bug#70985] [PATCH v2 5/6] gnu: rust: Guard against cross-libc returning #f.
Date: Tue, 09 Jul 2024 11:25:04 +0200
User-agent: mu4e 1.12.4; emacs 29.3

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)))))

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]