Subject: [bug#63641] [PATCH 2/8] gnu: glibc/hurd-headers: Properly cross-build.

From: Josselin Poiret <[email-masked]>
Date: Mon, 22 May 2023 11:04:12 +0200

From: Josselin Poiret <[email-masked]>

* gnu/packages/base.scm (glibc/hurd-headers): Rely on cross-mig, and remove
hardcoded configure flag `--host=i586-pc-gnu`.
* gnu/packages/cross-base.scm (cross-kernel-headers*): Add `--host` and
`--build` configure flags.
---
 gnu/packages/base.scm       | 13 ++++++-------
 gnu/packages/cross-base.scm |  6 +++++-
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index d2f276c447..f944ab5d47 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -1423,17 +1423,15 @@ (define-public glibc/hurd-headers
     (native-inputs
      (modify-inputs (package-native-inputs glibc)
        (prepend (if (%current-target-system)
-                    ;; XXX: When targeting i586-pc-gnu, we need a 32-bit MiG,
-                    ;; hence this hack.
-                    (package (inherit mig)
-                             (arguments `(#:system "i686-linux")))
-                    mig))))
+                   (let* ((cross-base (resolve-interface '(gnu packages cross-base)))
+                          (cross-mig (module-ref cross-base 'cross-mig)))
+                     (cross-mig (%current-target-system)))
+                   mig))))
     (arguments
      (substitute-keyword-arguments (package-arguments glibc)
        ;; We just pass the flags really needed to build the headers.
        ((#:configure-flags flags)
         `(list "--enable-add-ons"
-               "--host=i586-pc-gnu"
                ,@%glibc/hurd-configure-flags))
        ((#:phases _)
         '(modify-phases %standard-phases
@@ -1448,7 +1446,8 @@ (define-public glibc/hurd-headers
                  (close-port
                   (open-output-file
                    (string-append out "/include/gnu/stubs.h"))))))
-           (delete 'build)))))))                  ; nothing to build
+           (delete 'build)))))                  ; nothing to build
+    (supported-systems %hurd-systems)))
 
 (define-public tzdata
   (package
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 8d0b41180b..50e86083c3 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -492,7 +492,11 @@ (define* (cross-kernel-headers* target
                                               hurd "/include")))
                    (for-each (cut setenv <> cpath)
                              ',%gcc-cross-include-paths)
-                   #t)))))))
+                   #t)))))
+         ((#:configure-flags flags)
+          `(cons* ,(string-append "--build=" (%current-system))
+                  ,(string-append "--host=" target)
+                  ,flags))))
 
       (propagated-inputs `(("gnumach-headers" ,xgnumach-headers)
                            ("hurd-headers" ,xhurd-headers)))
-- 
2.40.1