help-guix
[Top][All Lists]
Advanced

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

Re: Installing cross-compiled packages alongside a cross-compile toolcha


From: Richard Sent
Subject: Re: Installing cross-compiled packages alongside a cross-compile toolchain
Date: Fri, 07 Jun 2024 22:43:35 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

Hi Christoph!

Christoph Buck <buck.christoph@googlemail.com> writes:

>> (define gcc-cross-aarch64-linux-toolchain
>>   (let ((chain (cross-gcc-toolchain "aarch64-linux-gnu")))
>>     (package
>>       (inherit chain)
>>       (native-search-paths
>>        (package-search-paths
>>         (lookup-package-input chain "gcc-cross-aarch64-linux-gnu"))))))
>>
>> (packages->manifest `(,gcc-cross-aarch64-linux-toolchain ,libpng))
>> 
>> (define* (enable-cross-compilation entry system target)
>>   (manifest-entry
>>     (inherit entry)
>>     (name (string-append (manifest-entry-name entry) "." system
>>                          (if target
>>                              (string-append "." target)
>>                              "")))
>>     (item (with-parameters ((%current-system system)
>>                             (%current-target-system target))
>>             (manifest-entry-item entry)))
>>     (dependencies (if (not (null? (manifest-entry-dependencies entry)))
>>                       (map (lambda (dep) (enable-cross-compilation dep 
>> system target))
>>                            (manifest-entry-dependencies entry))
>>                       '()))))
>> 
>> (define (cross-build-package package)
>>   (manifest (list (enable-cross-compilation (package->manifest-entry 
>> package) "x86_64-linux" "aarch64-linux-gnu"))))
>
>> (concatenate-manifests (list (specifications->manifest '("cmake"))
>>                              (cross-build-package libpng)
>>                              (packages->manifest 
>> `(,gcc-cross-aarch64-linux-toolchain)))) 
>
> From my rudimentary understanding of guile, this goes recursively
> through all manifest entries of the wrapped dependency and resets the
> `target` to "aarch64-linux-gnu". And indeed, this seems to work:
> 
> Is this the correct way to set this up? Is there a simpler way? It is
> such a common problem and my solution looks rather complicated. Are
> there any insights and tips of people with similiar uses cases?

I also unfortunately don't know of a better solution. I'm not fluent
with how cross-compilation works in Guix, but I think it would be
valuable proposing this (or something like it) as a patch and/or
cookbook entry! It seems too useful to leave hidden away in the mailing
list. (I assume your inspiration was [1], but in my opinion this is
different enough in both context and content to deserve its own
section.)

The closest I can think of is wrapping your Guix software as a package
and using --target, but this is often too much of a barrier to entry
when all you want is a simple development environment. Anything making
cross-compilation easier is a good thing in my eyes.

[1]: https://guix.gnu.org/en/cookbook/en/guix-cookbook.html#Build-Manifest

-- 
Take it easy,
Richard Sent
Making my computer weirder one commit at a time.



reply via email to

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