GNU bug report logs - #74758
[PATCH] pack: Allow cross-compiling with '--relocatable'.

Previous Next

Package: guix-patches;

Reported by: Brian Kubisiak <brian <at> kubisiak.com>

Date: Mon, 9 Dec 2024 22:17:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 74758 in the body.
You can then email your comments to 74758 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#74758; Package guix-patches. (Mon, 09 Dec 2024 22:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Brian Kubisiak <brian <at> kubisiak.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 09 Dec 2024 22:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Brian Kubisiak <brian <at> kubisiak.com>
To: guix-patches <at> gnu.org
Subject: [PATCH] pack: Allow cross-compiling with '--relocatable'.
Date: Mon, 9 Dec 2024 14:13:51 -0800
* guix/scripts/pack.scm (c-compiler-compiler): Remove exception when
cross-compiling and always build gexp->script for the host.
[toolchain]: Use standard-cross-packages when cross-compiling.
[search-paths]: Use package-search-paths instead of
package-native-search-paths when cross-compiling.
[run]: Use cc-for-target and strip-for-target.

Change-Id: I5503e48b3394fdfee06999f8d1ad82f5f0d9af96
---
 guix/scripts/pack.scm | 47 ++++++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm
index 58cd55b129..d0e66c3013 100644
--- a/guix/scripts/pack.scm
+++ b/guix/scripts/pack.scm
@@ -1105,12 +1105,30 @@ (define-gexp-compiler (c-compiler-compiler (compiler <c-compiler>) system target
   "Lower COMPILER to a single script that does the right thing."
   (define toolchain
     (or (c-compiler-toolchain compiler)
-        (list (first (assoc-ref (standard-packages) "gcc"))
-              (first (assoc-ref (standard-packages) "ld-wrapper"))
-              (first (assoc-ref (standard-packages) "binutils"))
-              (first (assoc-ref (standard-packages) "libc"))
-              (gexp-input (first (assoc-ref (standard-packages) "libc"))
-                          "static"))))
+        (if target
+            (let* ((cross-packages-host
+                    (standard-cross-packages target 'host))
+                   (cross-packages-target
+                    (standard-cross-packages target 'target))
+                   (xgcc
+                    (first (assoc-ref cross-packages-host "cross-gcc"))))
+              (list xgcc
+                    ;; ld-wrapper-cross isn't included with
+                    ;; STANDARD-CROSS-PACKAGES, pull it from the inputs of
+                    ;; cross-gcc instead
+                    (first (assoc-ref (package-native-inputs xgcc)
+                                      "ld-wrapper-cross"))
+                    (first (assoc-ref cross-packages-host "cross-binutils"))
+                    (first (assoc-ref cross-packages-target "cross-libc"))
+                    (gexp-input (first (assoc-ref cross-packages-target
+                                                  "cross-libc:static"))
+                                "static")))
+            (list (first (assoc-ref (standard-packages) "gcc"))
+                  (first (assoc-ref (standard-packages) "ld-wrapper"))
+                  (first (assoc-ref (standard-packages) "binutils"))
+                  (first (assoc-ref (standard-packages) "libc"))
+                  (gexp-input (first (assoc-ref (standard-packages) "libc"))
+                              "static")))))

   (define inputs
     (match (append-map package-propagated-inputs
@@ -1120,7 +1138,9 @@ (define-gexp-compiler (c-compiler-compiler (compiler <c-compiler>) system target

   (define search-paths
     (cons $PATH
-          (append-map package-native-search-paths
+          (append-map (if target
+                          package-search-paths
+                          package-native-search-paths)
                       (filter package? inputs))))

   (define run
@@ -1144,17 +1164,12 @@ (define-gexp-compiler (c-compiler-compiler (compiler <c-compiler>) system target
                             '#$inputs)

           (let ((output (output-file (command-line))))
-            (apply invoke "gcc" (cdr (command-line)))
-            (invoke "strip" output)))))
-
-  (when target
-    ;; TODO: Yep, we'll have to do it someday!
-    (leave (G_ "cross-compilation not implemented here;
-please email '~a'~%")
-           (@ (guix config) %guix-bug-report-address)))
+            (apply invoke #$(cc-for-target target) (cdr (command-line)))
+            (invoke #$(strip-for-target target) output)))))

   (gexp->script "c-compiler" run
-                #:guile (c-compiler-guile compiler)))
+                #:guile (c-compiler-guile compiler)
+                #:target #f))

 
 ;;;

base-commit: 9001514e242ad15c190588439930b0fa4f6782e3
--
2.46.0





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Sun, 15 Dec 2024 23:17:02 GMT) Full text and rfc822 format available.

Notification sent to Brian Kubisiak <brian <at> kubisiak.com>:
bug acknowledged by developer. (Sun, 15 Dec 2024 23:17:02 GMT) Full text and rfc822 format available.

Message #10 received at 74758-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Brian Kubisiak <brian <at> kubisiak.com>
Cc: 74758-done <at> debbugs.gnu.org
Subject: Re: [bug#74758] [PATCH] pack: Allow cross-compiling with
 '--relocatable'.
Date: Mon, 16 Dec 2024 00:16:02 +0100
Hi,

Brian Kubisiak <brian <at> kubisiak.com> skribis:

> * guix/scripts/pack.scm (c-compiler-compiler): Remove exception when
> cross-compiling and always build gexp->script for the host.
> [toolchain]: Use standard-cross-packages when cross-compiling.
> [search-paths]: Use package-search-paths instead of
> package-native-search-paths when cross-compiling.
> [run]: Use cc-for-target and strip-for-target.
>
> Change-Id: I5503e48b3394fdfee06999f8d1ad82f5f0d9af96

Excellent.  Applied, thanks!

>  guix/scripts/pack.scm | 47 ++++++++++++++++++++++++++++---------------
>  1 file changed, 31 insertions(+), 16 deletions(-)

I’m glad the implementation turned out to be quite small!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 13 Jan 2025 12:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 158 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.