* [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd systems.
@ 2016-06-08 14:43 Manolis Ragkousis
2016-06-12 11:48 ` Manolis Ragkousis
0 siblings, 1 reply; 10+ messages in thread
From: Manolis Ragkousis @ 2016-06-08 14:43 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 1988 bytes --]
Hello everyone,
This is a simplified version of the patch from wip-hurd for core-updates.
I want to point some things out.
In this version we only have one cross-libc which inherits from the
correct libc in base.scm through the use of the glibc-macro. This
simplifies things a lot.
- (propagated-inputs `(("kernel-headers" ,xlinux-headers)))
+ (propagated-inputs `(("kernel-headers" ,(cross-kernel-headers
target))))
The correct headers are determined by (cross-kernel-headers target).
(native-inputs `(("cross-gcc" ,xgcc)
("cross-binutils" ,xbinutils)
+ ,@(if (string-match (or "i586-pc-gnu" "i586-gnu")
target)
+ `(("cross-mig" ,xmig))
+ '())
,@(package-inputs glibc) ;FIXME: static-bash
,@(package-native-inputs glibc)))))
cross-mig is added only when target is i586-gnu or i586-pc-gnu.
@@ -343,12 +483,14 @@ XBINUTILS and the cross tool chain."
"CROSS_CPLUS_INCLUDE_PATH"
"CROSS_OBJC_INCLUDE_PATH"
"CROSS_OBJCPLUS_INCLUDE_PATH"))
+ ;; We need this for GNU/Hurd.
+ (setenv "CROSS_LIBRARY_PATH" (string-append kernel "/lib"))
#t))
,phases))))
When target is Hurd, we need to setup CROSS_LIBRARY_PATH for libpthread
to find libihash from hurd-core-headers/lib. The way I did it works for
Hurd and doesn't create any problems when targeting Linux.
- ,@(package-arguments glibc))
+ ;; Package-arguments does not use the correct libc, so we use
+ ;; (cross-libc-for-target ...) to determine the correct one.
+ ,@(package-arguments (cross-libc-for-target target)))
,@(package-arguments glibc)) was not detecting the correct libc so I
used (cross-libc-for-target target) to fix that. Maybe there is a better
solution for this.
WDYT?
Thank you,
Manolis
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-cross-libc-Cross-build-the-correct-libc-for-GNU-.patch --]
[-- Type: text/x-patch; name="0001-gnu-cross-libc-Cross-build-the-correct-libc-for-GNU-.patch", Size: 9784 bytes --]
From 63749df1aabfbceeefd500208bb66fb85a013e82 Mon Sep 17 00:00:00 2001
From: Manolis Ragkousis <manolis837@gmail.com>
Date: Wed, 8 Jun 2016 17:15:00 +0300
Subject: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd
systems.
* gnu/packages/cross-base.scm (cross-libc): Add xgnumach-headers, xmig,
xhurd-headers, xglibc/hurd-headers, xhurd-minimal, xhurd-core-headers,
cross-kernel-headers and cross-libc-for-target.
[arguments]: Set "CROSS_LIBRARY_PATH".
[propagated-inputs]: Use "cross-kernel-headers" to determine the correct headers.
[native-inputs]: Use "cross-mig" when target is GNU/Hurd.
---
gnu/packages/cross-base.scm | 149 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 147 insertions(+), 2 deletions(-)
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 58cd38b..db2e104 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -25,6 +26,7 @@
#:use-module (gnu packages base)
#:use-module (gnu packages commencement)
#:use-module (gnu packages linux)
+ #:use-module (gnu packages hurd)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix utils)
@@ -33,6 +35,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
+ #:use-module (ice-9 regex)
#:export (cross-binutils
cross-libc
cross-gcc))
@@ -311,6 +314,141 @@ XBINUTILS and the cross tool chain."
("cross-binutils" ,xbinutils)
,@(package-native-inputs linux-libre-headers)))))
+ (define xgnumach-headers
+ (package (inherit gnumach-headers)
+ (name (string-append (package-name gnumach-headers)
+ "-cross-" target))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(package-native-inputs gnumach-headers)))))
+
+ (define xmig
+ (package (inherit mig)
+ (name (string-append "mig-cross"))
+ (arguments
+ `(#:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26))
+ #:phases (alist-cons-before
+ 'configure 'set-cross-headers-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((mach (assoc-ref inputs "cross-gnumach-headers"))
+ (cpath (string-append mach "/include")))
+ (for-each (cut setenv <> cpath)
+ '("CROSS_C_INCLUDE_PATH"
+ "CROSS_CPLUS_INCLUDE_PATH"
+ "CROSS_OBJC_INCLUDE_PATH"
+ "CROSS_OBJCPLUS_INCLUDE_PATH"))))
+ %standard-phases)
+ #:configure-flags (list ,(string-append "--target=" target))
+ ,@(package-arguments mig)))
+
+ (propagated-inputs `(("cross-gnumach-headers" ,xgnumach-headers)))
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(package-native-inputs mig)))))
+
+ (define xhurd-headers
+ (package (inherit hurd-headers)
+ (name (string-append (package-name hurd-headers)
+ "-cross-" target))
+
+ (propagated-inputs `(("cross-mig" ,xmig)))
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ("cross-mig" ,xmig)
+ ,@(alist-delete "mig"(package-native-inputs hurd-headers))))))
+
+ (define xglibc/hurd-headers
+ (package (inherit glibc/hurd-headers)
+ (name (string-append (package-name glibc/hurd-headers)
+ "-cross-" target))
+
+ (arguments
+ (substitute-keyword-arguments
+ `(#:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26))
+ ,@(package-arguments glibc/hurd-headers))
+ ((#:phases phases)
+ `(alist-cons-before
+ 'pre-configure 'set-cross-headers-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((mach (assoc-ref inputs "gnumach-headers"))
+ (hurd (assoc-ref inputs "hurd-headers"))
+ (cpath (string-append mach "/include:"
+ hurd "/include")))
+ (for-each (cut setenv <> cpath)
+ '("CROSS_C_INCLUDE_PATH"
+ "CROSS_CPLUS_INCLUDE_PATH"
+ "CROSS_OBJC_INCLUDE_PATH"
+ "CROSS_OBJCPLUS_INCLUDE_PATH"))))
+ ,phases))))
+
+ (propagated-inputs `(("gnumach-headers" ,xgnumach-headers)
+ ("hurd-headers" ,xhurd-headers)))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ("cross-mig" ,xmig)
+ ,@(alist-delete "mig"(package-native-inputs glibc/hurd-headers))))))
+
+ (define xhurd-minimal
+ (package (inherit hurd-minimal)
+ (name (string-append (package-name hurd-minimal)
+ "-cross-" target))
+ (arguments
+ (substitute-keyword-arguments
+ `(#:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26))
+ ,@(package-arguments hurd-minimal))
+ ((#:phases phases)
+ `(alist-cons-before
+ 'configure 'set-cross-headers-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((glibc-headers (assoc-ref inputs "cross-glibc-hurd-headers"))
+ (cpath (string-append glibc-headers "/include")))
+ (for-each (cut setenv <> cpath)
+ '("CROSS_C_INCLUDE_PATH"
+ "CROSS_CPLUS_INCLUDE_PATH"
+ "CROSS_OBJC_INCLUDE_PATH"
+ "CROSS_OBJCPLUS_INCLUDE_PATH"))))
+ ,phases))))
+
+ (inputs `(("cross-glibc-hurd-headers" ,xglibc/hurd-headers)))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ("cross-mig" ,xmig)
+ ,@(alist-delete "mig"(package-native-inputs hurd-minimal))))))
+
+ (define xhurd-core-headers
+ (package (inherit hurd-core-headers)
+ (name (string-append (package-name hurd-core-headers)
+ "-cross-" target))
+
+ (inputs `(("gnumach-headers" ,xgnumach-headers)
+ ("hurd-headers" ,xhurd-headers)
+ ("hurd-minimal" ,xhurd-minimal)))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(package-native-inputs hurd-core-headers)))))
+
+ (define (cross-kernel-headers target)
+ "Return headers depending on TARGET."
+ (match target
+ ((or "i586-pc-gnu" "i586-gnu") xhurd-core-headers)
+ (_ xlinux-headers)))
+
+ (define (cross-libc-for-target target)
+ "Return libc depending on TARGET."
+ (match target
+ ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
+ (_ glibc/linux)))
+
(package (inherit glibc)
(name (string-append "glibc-cross-" target))
(arguments
@@ -328,7 +466,9 @@ XBINUTILS and the cross tool chain."
(guix build utils)
(srfi srfi-26))
- ,@(package-arguments glibc))
+ ;; Package-arguments does not use the correct libc, so we use
+ ;; (cross-libc-for-target ...) to determine the correct one.
+ ,@(package-arguments (cross-libc-for-target target)))
((#:configure-flags flags)
`(cons ,(string-append "--host=" target)
,flags))
@@ -343,12 +483,14 @@ XBINUTILS and the cross tool chain."
"CROSS_CPLUS_INCLUDE_PATH"
"CROSS_OBJC_INCLUDE_PATH"
"CROSS_OBJCPLUS_INCLUDE_PATH"))
+ ;; We need this for GNU/Hurd.
+ (setenv "CROSS_LIBRARY_PATH" (string-append kernel "/lib"))
#t))
,phases))))
;; Shadow the native "kernel-headers" because glibc's recipe expects the
;; "kernel-headers" input to point to the right thing.
- (propagated-inputs `(("kernel-headers" ,xlinux-headers)))
+ (propagated-inputs `(("kernel-headers" ,(cross-kernel-headers target))))
;; FIXME: 'static-bash' should really be an input, not a native input, but
;; to do that will require building an intermediate cross libc.
@@ -356,6 +498,9 @@ XBINUTILS and the cross tool chain."
(native-inputs `(("cross-gcc" ,xgcc)
("cross-binutils" ,xbinutils)
+ ,@(if (string-match (or "i586-pc-gnu" "i586-gnu") target)
+ `(("cross-mig" ,xmig))
+ '())
,@(package-inputs glibc) ;FIXME: static-bash
,@(package-native-inputs glibc)))))
--
2.8.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd systems.
2016-06-08 14:43 [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd systems Manolis Ragkousis
@ 2016-06-12 11:48 ` Manolis Ragkousis
2016-06-12 16:38 ` Ludovic Courtès
0 siblings, 1 reply; 10+ messages in thread
From: Manolis Ragkousis @ 2016-06-12 11:48 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 346 bytes --]
Hello everyone,
The previous version of my patch was not using target to correctly
determine which glibc to inherit. It was using %current-target-system
which caused me many problems.
With this version I modified it to use cross-libc-for-target so there
will not be any problems in case %current-target-system is not set.
Thank you,
Manolis
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-cross-libc-Cross-build-the-correct-libc-for-GNU-.patch --]
[-- Type: text/x-patch; name="0001-gnu-cross-libc-Cross-build-the-correct-libc-for-GNU-.patch", Size: 12288 bytes --]
From 92689506f1969ac67631f77024511a5c96f341e8 Mon Sep 17 00:00:00 2001
From: Manolis Ragkousis <manolis837@gmail.com>
Date: Wed, 8 Jun 2016 17:15:00 +0300
Subject: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd
systems.
* gnu/packages/cross-base.scm (cross-libc): Add xgnumach-headers, xmig,
xhurd-headers, xglibc/hurd-headers, xhurd-minimal, xhurd-core-headers,
cross-kernel-headers and cross-libc-for-target. Use "cross-libc-for-target"
to determine the correct libc to use.
[arguments]: Set "CROSS_LIBRARY_PATH".
[propagated-inputs]: Use "cross-kernel-headers" to determine the correct headers.
[native-inputs]: Use "cross-mig" when target is GNU/Hurd.
---
gnu/packages/cross-base.scm | 226 ++++++++++++++++++++++++++++++++++++--------
1 file changed, 185 insertions(+), 41 deletions(-)
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 9d0f86a..a1e02c3 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -25,6 +26,7 @@
#:use-module (gnu packages base)
#:use-module (gnu packages commencement)
#:use-module (gnu packages linux)
+ #:use-module (gnu packages hurd)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix utils)
@@ -33,6 +35,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
+ #:use-module (ice-9 regex)
#:export (cross-binutils
cross-libc
cross-gcc))
@@ -311,53 +314,194 @@ XBINUTILS and the cross tool chain."
("cross-binutils" ,xbinutils)
,@(package-native-inputs linux-libre-headers)))))
- (package (inherit glibc)
- (name (string-append "glibc-cross-" target))
- (arguments
- (substitute-keyword-arguments
- `(;; Disable stripping (see above.)
- #:strip-binaries? #f
+ (define xgnumach-headers
+ (package (inherit gnumach-headers)
+ (name (string-append (package-name gnumach-headers)
+ "-cross-" target))
- ;; This package is used as a target input, but it should not have
- ;; the usual cross-compilation inputs since that would include
- ;; itself.
- #:implicit-cross-inputs? #f
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(package-native-inputs gnumach-headers)))))
+
+ (define xmig
+ (package (inherit mig)
+ (name (string-append "mig-cross"))
+ (arguments
+ `(#:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26))
+ #:phases (alist-cons-before
+ 'configure 'set-cross-headers-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((mach (assoc-ref inputs "cross-gnumach-headers"))
+ (cpath (string-append mach "/include")))
+ (for-each (cut setenv <> cpath)
+ '("CROSS_C_INCLUDE_PATH"
+ "CROSS_CPLUS_INCLUDE_PATH"
+ "CROSS_OBJC_INCLUDE_PATH"
+ "CROSS_OBJCPLUS_INCLUDE_PATH"))))
+ %standard-phases)
+ #:configure-flags (list ,(string-append "--target=" target))
+ ,@(package-arguments mig)))
+
+ (propagated-inputs `(("cross-gnumach-headers" ,xgnumach-headers)))
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(package-native-inputs mig)))))
+
+ (define xhurd-headers
+ (package (inherit hurd-headers)
+ (name (string-append (package-name hurd-headers)
+ "-cross-" target))
+
+ (propagated-inputs `(("cross-mig" ,xmig)))
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ("cross-mig" ,xmig)
+ ,@(alist-delete "mig"(package-native-inputs hurd-headers))))))
- ;; We need SRFI 26.
- #:modules ((guix build gnu-build-system)
+ (define xglibc/hurd-headers
+ (package (inherit glibc/hurd-headers)
+ (name (string-append (package-name glibc/hurd-headers)
+ "-cross-" target))
+
+ (arguments
+ (substitute-keyword-arguments
+ `(#:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26))
+ ,@(package-arguments glibc/hurd-headers))
+ ((#:phases phases)
+ `(alist-cons-before
+ 'pre-configure 'set-cross-headers-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((mach (assoc-ref inputs "gnumach-headers"))
+ (hurd (assoc-ref inputs "hurd-headers"))
+ (cpath (string-append mach "/include:"
+ hurd "/include")))
+ (for-each (cut setenv <> cpath)
+ '("CROSS_C_INCLUDE_PATH"
+ "CROSS_CPLUS_INCLUDE_PATH"
+ "CROSS_OBJC_INCLUDE_PATH"
+ "CROSS_OBJCPLUS_INCLUDE_PATH"))))
+ ,phases))))
+
+ (propagated-inputs `(("gnumach-headers" ,xgnumach-headers)
+ ("hurd-headers" ,xhurd-headers)))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ("cross-mig" ,xmig)
+ ,@(alist-delete "mig"(package-native-inputs glibc/hurd-headers))))))
+
+ (define xhurd-minimal
+ (package (inherit hurd-minimal)
+ (name (string-append (package-name hurd-minimal)
+ "-cross-" target))
+ (arguments
+ (substitute-keyword-arguments
+ `(#:modules ((guix build gnu-build-system)
(guix build utils)
(srfi srfi-26))
+ ,@(package-arguments hurd-minimal))
+ ((#:phases phases)
+ `(alist-cons-before
+ 'configure 'set-cross-headers-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((glibc-headers (assoc-ref inputs "cross-glibc-hurd-headers"))
+ (cpath (string-append glibc-headers "/include")))
+ (for-each (cut setenv <> cpath)
+ '("CROSS_C_INCLUDE_PATH"
+ "CROSS_CPLUS_INCLUDE_PATH"
+ "CROSS_OBJC_INCLUDE_PATH"
+ "CROSS_OBJCPLUS_INCLUDE_PATH"))))
+ ,phases))))
- ,@(package-arguments glibc))
- ((#:configure-flags flags)
- `(cons ,(string-append "--host=" target)
- ,flags))
- ((#:phases phases)
- `(alist-cons-before
- 'configure 'set-cross-kernel-headers-path
- (lambda* (#:key inputs #:allow-other-keys)
- (let* ((kernel (assoc-ref inputs "kernel-headers"))
- (cpath (string-append kernel "/include")))
- (for-each (cut setenv <> cpath)
- '("CROSS_C_INCLUDE_PATH"
- "CROSS_CPLUS_INCLUDE_PATH"
- "CROSS_OBJC_INCLUDE_PATH"
- "CROSS_OBJCPLUS_INCLUDE_PATH"))
- #t))
- ,phases))))
-
- ;; Shadow the native "kernel-headers" because glibc's recipe expects the
- ;; "kernel-headers" input to point to the right thing.
- (propagated-inputs `(("kernel-headers" ,xlinux-headers)))
-
- ;; FIXME: 'static-bash' should really be an input, not a native input, but
- ;; to do that will require building an intermediate cross libc.
- (inputs '())
+ (inputs `(("cross-glibc-hurd-headers" ,xglibc/hurd-headers)))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ("cross-mig" ,xmig)
+ ,@(alist-delete "mig"(package-native-inputs hurd-minimal))))))
+
+ (define xhurd-core-headers
+ (package (inherit hurd-core-headers)
+ (name (string-append (package-name hurd-core-headers)
+ "-cross-" target))
- (native-inputs `(("cross-gcc" ,xgcc)
- ("cross-binutils" ,xbinutils)
- ,@(package-inputs glibc) ;FIXME: static-bash
- ,@(package-native-inputs glibc)))))
+ (inputs `(("gnumach-headers" ,xgnumach-headers)
+ ("hurd-headers" ,xhurd-headers)
+ ("hurd-minimal" ,xhurd-minimal)))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(package-native-inputs hurd-core-headers)))))
+
+ (define (cross-kernel-headers target)
+ "Return headers depending on TARGET."
+ (match target
+ ((or "i586-pc-gnu" "i586-gnu") xhurd-core-headers)
+ (_ xlinux-headers)))
+
+ (define (cross-libc-for-target target)
+ "Return libc depending on TARGET."
+ (match target
+ ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
+ (_ glibc/linux)))
+
+ (let ((libc (cross-libc-for-target target)))
+ (package (inherit libc)
+ (name (string-append "glibc-cross-" target))
+ (arguments
+ (substitute-keyword-arguments
+ `(;; Disable stripping (see above.)
+ #:strip-binaries? #f
+
+ ;; This package is used as a target input, but it should not have
+ ;; the usual cross-compilation inputs since that would include
+ ;; itself.
+ #:implicit-cross-inputs? #f
+
+ ;; We need SRFI 26.
+ #:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26))
+
+ ,@(package-arguments libc))
+ ((#:configure-flags flags)
+ `(cons ,(string-append "--host=" target)
+ ,flags))
+ ((#:phases phases)
+ `(alist-cons-before
+ 'configure 'set-cross-kernel-headers-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((kernel (assoc-ref inputs "kernel-headers"))
+ (cpath (string-append kernel "/include")))
+ (for-each (cut setenv <> cpath)
+ '("CROSS_C_INCLUDE_PATH"
+ "CROSS_CPLUS_INCLUDE_PATH"
+ "CROSS_OBJC_INCLUDE_PATH"
+ "CROSS_OBJCPLUS_INCLUDE_PATH"))
+ ;; We need this for GNU/Hurd.
+ (setenv "CROSS_LIBRARY_PATH" (string-append kernel "/lib"))
+ #t))
+ ,phases))))
+
+ ;; Shadow the native "kernel-headers" because glibc's recipe expects the
+ ;; "kernel-headers" input to point to the right thing.
+ (propagated-inputs `(("kernel-headers" ,(cross-kernel-headers target))))
+
+ ;; FIXME: 'static-bash' should really be an input, not a native input, but
+ ;; to do that will require building an intermediate cross libc.
+ (inputs '())
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(if (string-match (or "i586-pc-gnu" "i586-gnu") target)
+ `(("cross-mig" ,xmig))
+ '())
+ ,@(package-inputs libc) ;FIXME: static-bash
+ ,@(package-native-inputs libc))))))
\f
;;;
--
2.8.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd systems.
2016-06-12 11:48 ` Manolis Ragkousis
@ 2016-06-12 16:38 ` Ludovic Courtès
2016-06-16 16:32 ` Manolis Ragkousis
0 siblings, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2016-06-12 16:38 UTC (permalink / raw)
To: Manolis Ragkousis; +Cc: guix-devel
Hi!
Manolis Ragkousis <manolis837@gmail.com> skribis:
> The previous version of my patch was not using target to correctly
> determine which glibc to inherit. It was using %current-target-system
> which caused me many problems.
>
> With this version I modified it to use cross-libc-for-target so there
> will not be any problems in case %current-target-system is not set.
“Problems” is a bit vague, but I’m glad you’ve overcome them. :-)
> From 92689506f1969ac67631f77024511a5c96f341e8 Mon Sep 17 00:00:00 2001
> From: Manolis Ragkousis <manolis837@gmail.com>
> Date: Wed, 8 Jun 2016 17:15:00 +0300
> Subject: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd
> systems.
>
> * gnu/packages/cross-base.scm (cross-libc): Add xgnumach-headers, xmig,
> xhurd-headers, xglibc/hurd-headers, xhurd-minimal, xhurd-core-headers,
> cross-kernel-headers and cross-libc-for-target. Use "cross-libc-for-target"
> to determine the correct libc to use.
> [arguments]: Set "CROSS_LIBRARY_PATH".
> [propagated-inputs]: Use "cross-kernel-headers" to determine the correct headers.
> [native-inputs]: Use "cross-mig" when target is GNU/Hurd.
[...]
> + (define (cross-kernel-headers target)
> + "Return headers depending on TARGET."
> + (match target
> + ((or "i586-pc-gnu" "i586-gnu") xhurd-core-headers)
> + (_ xlinux-headers)))
Could you move this procedure, as well as xgnumach-headers and co., to
the top level? That way there’d be less “clutter” in the definition of
‘cross-libc’ itself. WDYT?
Other than that it LGTM, but if, and only if, you can verify that this
does not cause any regression for other cross-compilation targets.
Normally this should not change derivations at all so you don’t even
need to build them. Just run this:
./pre-inst-env guix build gcc --target=mips64el-linux-gnu -d
both before and after the change, and the result should be the same .drv
file name.
Thanks!
Ludo’.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd systems.
2016-06-12 16:38 ` Ludovic Courtès
@ 2016-06-16 16:32 ` Manolis Ragkousis
2016-06-16 18:44 ` Manolis Ragkousis
2016-06-26 21:31 ` Ludovic Courtès
0 siblings, 2 replies; 10+ messages in thread
From: Manolis Ragkousis @ 2016-06-16 16:32 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
[-- Attachment #1: Type: text/plain, Size: 1024 bytes --]
Hello,
Here is the updated patch.
On 06/12/16 19:38, Ludovic Courtès wrote:
> Could you move this procedure, as well as xgnumach-headers and co., to
> the top level? That way there’d be less “clutter” in the definition of
> ‘cross-libc’ itself. WDYT?
I created (guix build cross-base) which exports cross-mig,
cross-kernel-headers and cross-libc-for-target, which is what we need to
produce a working cross-libc. Cross-mig is only used when target is
GNU/Hurd.
>
> Other than that it LGTM, but if, and only if, you can verify that this
> does not cause any regression for other cross-compilation targets.
> Normally this should not change derivations at all so you don’t even
> need to build them. Just run this:
>
> ./pre-inst-env guix build gcc --target=mips64el-linux-gnu -d
>
> both before and after the change, and the result should be the same .drv
> file name.
The derivations are not the same so I will have to build it and see if
it works. I will report back on that.
Thank you,
Manolis
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-cross-libc-Cross-build-the-correct-libc-for-GNU-.patch --]
[-- Type: text/x-patch; name="0001-gnu-cross-libc-Cross-build-the-correct-libc-for-GNU-.patch", Size: 16719 bytes --]
From f8aedd6fdb1b3f9a93c1786c29f7fc7e40eea7a1 Mon Sep 17 00:00:00 2001
From: Manolis Ragkousis <manolis837@gmail.com>
Date: Thu, 16 Jun 2016 16:13:22 +0300
Subject: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd
systems.
* guix/build/cross-base.scm: New file. Add cross-mig, cross-kernel-headers
and cross-libc-for-target.
* gnu/packages/cross-base.scm (cross-libc): Use the new file. Use
cross-libc-for-target.
[arguments]: Add 'KERNEL/lib' to 'CROSS_LIBRARY_PATH'.
[propagated-inputs]: Use "cross-kernel-headers" to determine the correct headers.
[native-inputs]: Use "cross-mig" when target is GNU/Hurd.
* Makefile.am (MODULES): Add it.
---
Makefile.am | 1 +
gnu/packages/cross-base.scm | 111 +++++++++++-------------
guix/build/cross-base.scm | 205 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 255 insertions(+), 62 deletions(-)
create mode 100644 guix/build/cross-base.scm
diff --git a/Makefile.am b/Makefile.am
index 50cde52..44838d3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -103,6 +103,7 @@ MODULES = \
guix/build/emacs-utils.scm \
guix/build/graft.scm \
guix/build/bournish.scm \
+ guix/build/cross-base.scm \
guix/search-paths.scm \
guix/packages.scm \
guix/import/utils.scm \
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 718e56e..be7870a 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -30,9 +31,11 @@
#:use-module (guix utils)
#:use-module (guix build-system gnu)
#:use-module (guix build-system trivial)
+ #:use-module (guix build cross-base)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
+ #:use-module (ice-9 regex)
#:export (cross-binutils
cross-libc
cross-gcc))
@@ -290,75 +293,59 @@ GCC that does not target a libc; otherwise, target that libc."
(xbinutils (cross-binutils target)))
"Return a libc cross-built for TARGET, a GNU triplet. Use XGCC and
XBINUTILS and the cross tool chain."
- (define xlinux-headers
- (package (inherit linux-libre-headers)
- (name (string-append (package-name linux-libre-headers)
- "-cross-" target))
+ (let ((libc (cross-libc-for-target target)))
+ (package (inherit libc)
+ (name (string-append "glibc-cross-" target))
(arguments
(substitute-keyword-arguments
- `(#:implicit-cross-inputs? #f
- ,@(package-arguments linux-libre-headers))
+ `(;; Disable stripping (see above.)
+ #:strip-binaries? #f
+
+ ;; This package is used as a target input, but it should not have
+ ;; the usual cross-compilation inputs since that would include
+ ;; itself.
+ #:implicit-cross-inputs? #f
+
+ ;; We need SRFI 26.
+ #:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26))
+
+ ,@(package-arguments libc))
+ ((#:configure-flags flags)
+ `(cons ,(string-append "--host=" target)
+ ,flags))
((#:phases phases)
- `(alist-replace
- 'build
- (lambda _
- (setenv "ARCH" ,(system->linux-architecture target))
- (format #t "`ARCH' set to `~a' (cross compiling)~%" (getenv "ARCH"))
-
- (and (zero? (system* "make" "defconfig"))
- (zero? (system* "make" "mrproper" "headers_check"))))
+ `(alist-cons-before
+ 'configure 'set-cross-kernel-headers-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((kernel (assoc-ref inputs "kernel-headers"))
+ (cpath (string-append kernel "/include")))
+ (for-each (cut setenv <> cpath)
+ '("CROSS_C_INCLUDE_PATH"
+ "CROSS_CPLUS_INCLUDE_PATH"
+ "CROSS_OBJC_INCLUDE_PATH"
+ "CROSS_OBJCPLUS_INCLUDE_PATH"))
+ (setenv "CROSS_LIBRARY_PATH"
+ (string-append kernel "/lib")) ;for Hurd's libihash
+ #t))
,phases))))
- (native-inputs `(("cross-gcc" ,xgcc)
- ("cross-binutils" ,xbinutils)
- ,@(package-native-inputs linux-libre-headers)))))
-
- (package (inherit glibc)
- (name (string-append "glibc-cross-" target))
- (arguments
- (substitute-keyword-arguments
- `(;; Disable stripping (see above.)
- #:strip-binaries? #f
-
- ;; This package is used as a target input, but it should not have
- ;; the usual cross-compilation inputs since that would include
- ;; itself.
- #:implicit-cross-inputs? #f
- ;; We need SRFI 26.
- #:modules ((guix build gnu-build-system)
- (guix build utils)
- (srfi srfi-26))
+ ;; Shadow the native "kernel-headers" because glibc's recipe expects the
+ ;; "kernel-headers" input to point to the right thing.
+ (propagated-inputs `(("kernel-headers" ,(cross-kernel-headers target xgcc xbinutils))))
- ,@(package-arguments glibc))
- ((#:configure-flags flags)
- `(cons ,(string-append "--host=" target)
- ,flags))
- ((#:phases phases)
- `(alist-cons-before
- 'configure 'set-cross-kernel-headers-path
- (lambda* (#:key inputs #:allow-other-keys)
- (let* ((kernel (assoc-ref inputs "kernel-headers"))
- (cpath (string-append kernel "/include")))
- (for-each (cut setenv <> cpath)
- '("CROSS_C_INCLUDE_PATH"
- "CROSS_CPLUS_INCLUDE_PATH"
- "CROSS_OBJC_INCLUDE_PATH"
- "CROSS_OBJCPLUS_INCLUDE_PATH"))
- #t))
- ,phases))))
-
- ;; Shadow the native "kernel-headers" because glibc's recipe expects the
- ;; "kernel-headers" input to point to the right thing.
- (propagated-inputs `(("kernel-headers" ,xlinux-headers)))
-
- ;; FIXME: 'static-bash' should really be an input, not a native input, but
- ;; to do that will require building an intermediate cross libc.
- (inputs '())
+ ;; FIXME: 'static-bash' should really be an input, not a native input, but
+ ;; to do that will require building an intermediate cross libc.
+ (inputs '())
- (native-inputs `(("cross-gcc" ,xgcc)
- ("cross-binutils" ,xbinutils)
- ,@(package-inputs glibc) ;FIXME: static-bash
- ,@(package-native-inputs glibc)))))
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(if (string-match "i586-pc-gnu" target)
+ `(("cross-mig" ,(cross-mig target xgcc xbinutils)))
+ '())
+ ,@(package-inputs libc) ;FIXME: static-bash
+ ,@(package-native-inputs libc))))))
\f
;;;
diff --git a/guix/build/cross-base.scm b/guix/build/cross-base.scm
new file mode 100644
index 0000000..501a221
--- /dev/null
+++ b/guix/build/cross-base.scm
@@ -0,0 +1,205 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build cross-base)
+ #:use-module (guix licenses)
+ #:use-module (gnu packages)
+ #:use-module (guix packages)
+ #:use-module (guix build-system gnu)
+ #:use-module (guix build-system trivial)
+ #:use-module (guix build utils)
+ #:use-module (guix utils)
+ #:use-module (gnu packages base)
+ #:use-module (gnu packages linux)
+ #:use-module (gnu packages hurd)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 regex)
+ #:export (cross-mig)
+ #:export (cross-kernel-headers)
+ #:export (cross-libc-for-target))
+
+(define (cross-mig target xgcc xbinutils)
+ "Return MiG cross-built for TARGET."
+
+ (define xgnumach-headers
+ (package (inherit gnumach-headers)
+ (name (string-append (package-name gnumach-headers)
+ "-cross-" target))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(package-native-inputs gnumach-headers)))))
+
+ (package (inherit mig)
+ (name (string-append "mig-cross"))
+ (arguments
+ `(#:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26))
+ #:phases (alist-cons-before
+ 'configure 'set-cross-headers-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((mach (assoc-ref inputs "cross-gnumach-headers"))
+ (cpath (string-append mach "/include")))
+ (for-each (cut setenv <> cpath)
+ '("CROSS_C_INCLUDE_PATH"
+ "CROSS_CPLUS_INCLUDE_PATH"
+ "CROSS_OBJC_INCLUDE_PATH"
+ "CROSS_OBJCPLUS_INCLUDE_PATH"))))
+ %standard-phases)
+ #:configure-flags (list ,(string-append "--target=" target))
+ ,@(package-arguments mig)))
+
+ (propagated-inputs `(("cross-gnumach-headers" ,xgnumach-headers)))
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(package-native-inputs mig)))))
+
+
+
+(define (cross-kernel-headers target xgcc xbinutils)
+ "Return headers depending on TARGET."
+
+ (define xlinux-headers
+ (package (inherit linux-libre-headers)
+ (name (string-append (package-name linux-libre-headers)
+ "-cross-" target))
+ (arguments
+ (substitute-keyword-arguments
+ `(#:implicit-cross-inputs? #f
+ ,@(package-arguments linux-libre-headers))
+ ((#:phases phases)
+ `(alist-replace
+ 'build
+ (lambda _
+ (setenv "ARCH" ,(system->linux-architecture target))
+ (format #t "`ARCH' set to `~a' (cross compiling)~%" (getenv "ARCH"))
+ (and (zero? (system* "make" "defconfig"))
+ (zero? (system* "make" "mrproper" "headers_check"))))
+ ,phases))))
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(package-native-inputs linux-libre-headers)))))
+
+ (define xgnumach-headers
+ (package (inherit gnumach-headers)
+ (name (string-append (package-name gnumach-headers)
+ "-cross-" target))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(package-native-inputs gnumach-headers)))))
+
+ (define xhurd-headers
+ (package (inherit hurd-headers)
+ (name (string-append (package-name hurd-headers)
+ "-cross-" target))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ("cross-mig" ,(cross-mig target xgcc xbinutils))
+ ,@(alist-delete "mig"(package-native-inputs hurd-headers))))))
+
+ (define xglibc/hurd-headers
+ (package (inherit glibc/hurd-headers)
+ (name (string-append (package-name glibc/hurd-headers)
+ "-cross-" target))
+
+ (arguments
+ (substitute-keyword-arguments
+ `(#:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26))
+ ,@(package-arguments glibc/hurd-headers))
+ ((#:phases phases)
+ `(alist-cons-before
+ 'pre-configure 'set-cross-headers-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((mach (assoc-ref inputs "gnumach-headers"))
+ (hurd (assoc-ref inputs "hurd-headers"))
+ (cpath (string-append mach "/include:"
+ hurd "/include")))
+ (for-each (cut setenv <> cpath)
+ '("CROSS_C_INCLUDE_PATH"
+ "CROSS_CPLUS_INCLUDE_PATH"
+ "CROSS_OBJC_INCLUDE_PATH"
+ "CROSS_OBJCPLUS_INCLUDE_PATH"))))
+ ,phases))))
+
+ (propagated-inputs `(("gnumach-headers" ,xgnumach-headers)
+ ("hurd-headers" ,xhurd-headers)))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ("cross-mig" ,(cross-mig target xgcc xbinutils))
+ ,@(alist-delete "mig"(package-native-inputs glibc/hurd-headers))))))
+
+ (define xhurd-minimal
+ (package (inherit hurd-minimal)
+ (name (string-append (package-name hurd-minimal)
+ "-cross-" target))
+ (arguments
+ (substitute-keyword-arguments
+ `(#:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26))
+ ,@(package-arguments hurd-minimal))
+ ((#:phases phases)
+ `(alist-cons-before
+ 'configure 'set-cross-headers-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((glibc-headers (assoc-ref inputs "cross-glibc-hurd-headers"))
+ (cpath (string-append glibc-headers "/include")))
+ (for-each (cut setenv <> cpath)
+ '("CROSS_C_INCLUDE_PATH"
+ "CROSS_CPLUS_INCLUDE_PATH"
+ "CROSS_OBJC_INCLUDE_PATH"
+ "CROSS_OBJCPLUS_INCLUDE_PATH"))))
+ ,phases))))
+
+ (inputs `(("cross-glibc-hurd-headers" ,xglibc/hurd-headers)))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ("cross-mig" ,(cross-mig target xgcc xbinutils))
+ ,@(alist-delete "mig"(package-native-inputs hurd-minimal))))))
+
+ (define xhurd-core-headers
+ (package (inherit hurd-core-headers)
+ (name (string-append (package-name hurd-core-headers)
+ "-cross-" target))
+
+ (inputs `(("gnumach-headers" ,xgnumach-headers)
+ ("hurd-headers" ,xhurd-headers)
+ ("hurd-minimal" ,xhurd-minimal)))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(package-native-inputs hurd-core-headers)))))
+
+ (match target
+ ((or "i586-pc-gnu" "i586-gnu") xhurd-core-headers)
+ (_ xlinux-headers)))
+
+(define (cross-libc-for-target target)
+ "Return libc depending on TARGET."
+ (match target
+ ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
+ (_ glibc/linux)))
--
2.8.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd systems.
2016-06-16 16:32 ` Manolis Ragkousis
@ 2016-06-16 18:44 ` Manolis Ragkousis
2016-06-26 21:31 ` Ludovic Courtès
1 sibling, 0 replies; 10+ messages in thread
From: Manolis Ragkousis @ 2016-06-16 18:44 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
[-- Attachment #1: Type: text/plain, Size: 739 bytes --]
Hello again,
On 06/16/16 19:32, Manolis Ragkousis wrote:
>> Other than that it LGTM, but if, and only if, you can verify that this
>> does not cause any regression for other cross-compilation targets.
>> Normally this should not change derivations at all so you don’t even
>> need to build them. Just run this:
>>
>> ./pre-inst-env guix build gcc --target=mips64el-linux-gnu -d
>>
>> both before and after the change, and the result should be the same .drv
>> file name.
>
> The derivations are not the same so I will have to build it and see if
> it works. I will report back on that.
>
Cross building gcc 6.1.0 for mips fails with or without my patch on the
latest core-updates.
Other packages build without an issue.
Manolis
[-- Attachment #2: yfy4zqizrsr9kx016mraira0irmxf5-gcc-6.1.0.drv.bz2 --]
[-- Type: application/x-bzip, Size: 441625 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd systems.
2016-06-16 16:32 ` Manolis Ragkousis
2016-06-16 18:44 ` Manolis Ragkousis
@ 2016-06-26 21:31 ` Ludovic Courtès
2016-07-19 16:30 ` Manolis Ragkousis
1 sibling, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2016-06-26 21:31 UTC (permalink / raw)
To: Manolis Ragkousis; +Cc: guix-devel
Hi!
Manolis Ragkousis <manolis837@gmail.com> skribis:
> On 06/12/16 19:38, Ludovic Courtès wrote:
>> Could you move this procedure, as well as xgnumach-headers and co., to
>> the top level? That way there’d be less “clutter” in the definition of
>> ‘cross-libc’ itself. WDYT?
>
> I created (guix build cross-base) which exports cross-mig,
> cross-kernel-headers and cross-libc-for-target, which is what we need to
> produce a working cross-libc. Cross-mig is only used when target is
> GNU/Hurd.
The (guix build …) name space is meant for “build-side” code (info
"(guix) G-Expressions"), whereas this is clearly “host” code since it
manipulates packages. So I think it should remain in (gnu packages
cross-base), only moved to the top-level instead of inner definitions.
Sorry if I wasn’t clear!
>> Other than that it LGTM, but if, and only if, you can verify that this
>> does not cause any regression for other cross-compilation targets.
>> Normally this should not change derivations at all so you don’t even
>> need to build them. Just run this:
>>
>> ./pre-inst-env guix build gcc --target=mips64el-linux-gnu -d
>>
>> both before and after the change, and the result should be the same .drv
>> file name.
>
> The derivations are not the same
Bah, I was wrong: it’s expected that derivations are not the same since
there are changes like adding KERNEL/lib to CROSS_LIBRARY_PATH.
Apologies for the confusion.
> so I will have to build it and see if it works. I will report back on
> that.
GCC 6 currently fails to cross build. For a known-good compiler, try
4.9, which currently cross-builds successfully (on master):
--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix build gcc@4 --target=mips64el-linux-gnu -n --no-grafts
guix build: warning: ambiguous package specification `gcc@4'
guix build: warning: choosing gcc-4.9.3 from gnu/packages/gcc.scm:334:2
La jenaj derivoj estus elŝutataj:
/gnu/store/v2rglm6dp21c33lhbcvdzqfsxlxya9qp-gcc-4.9.3-debug
/gnu/store/aarlmyjnd5hrd3gvi6qwmlsajvvvfnxw-gcc-4.9.3-lib
/gnu/store/56cl18prjn8rhvjp1y7agwn5gis27h87-gcc-4.9.3
/gnu/store/1j8pbr9xlzkjx93xvv12z2zflnbw86bg-gmp-6.1.0
/gnu/store/3m8pj7dc10a9m6ds6gwn198a3d7zjr2a-zlib-1.2.8
/gnu/store/5cr66jcq6m4qm5nqah6lplby8vli6h2b-isl-0.11.1
/gnu/store/6kkhcyj1i1bg83h8zx7mrvkp1bfnh8l9-gcc-cross-mips64el-linux-gnu-4.9.3
/gnu/store/9szbxfc2pizaznklqmas7r8qghqidci6-mpc-1.0.3
/gnu/store/ac5yx4spq4i78085yy9sxhzr9zrsvhic-glibc-cross-mips64el-linux-gnu-2.22
/gnu/store/mfn9wr2yl3yq02b87zf1b9vg6n7g9bfw-mpfr-3.1.3
/gnu/store/n2pc3fzq1fwpbmb83g7kmsj80fa1nld9-cloog-0.18.0
/gnu/store/7y12yppfwy0ll99faazp2qsank4nmd3j-gcc-cross-sans-libc-mips64el-linux-gnu-4.9.3
$ git describe
v0.10.0-1526-g9dd674d
--8<---------------cut here---------------end--------------->8---
Could you send an updated patch?
Sorry for the delay and all again!
Ludo’.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd systems.
2016-06-26 21:31 ` Ludovic Courtès
@ 2016-07-19 16:30 ` Manolis Ragkousis
2016-07-20 7:16 ` Vincent Legoll
2016-07-22 12:55 ` Ludovic Courtès
0 siblings, 2 replies; 10+ messages in thread
From: Manolis Ragkousis @ 2016-07-19 16:30 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
[-- Attachment #1: Type: text/plain, Size: 138 bytes --]
Hello Ludo,
This is the updated patch. I have tested it as suggested and it works.
It applies on core-updates-next.
Thank you,
Manolis
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-cross-libc-Cross-build-the-correct-libc-for-GNU-.patch --]
[-- Type: text/x-patch; name="0001-gnu-cross-libc-Cross-build-the-correct-libc-for-GNU-.patch", Size: 11061 bytes --]
From e599bc5b7208be48d4fff0868fb3b53a964dae11 Mon Sep 17 00:00:00 2001
From: Manolis Ragkousis <manolis837@gmail.com>
Date: Wed, 8 Jun 2016 17:15:00 +0300
Subject: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd
systems.
* gnu/packages/cross-base.scm (cross-kernel-headers): Add new variable.
Add xgnumach-headers, xmig, xhurd-headers, xglibc/hurd-headers,
xhurd-minimal, xhurd-core-headers.
(cross-libc): Add cross-libc-for-target.
[arguments]: Set "CROSS_LIBRARY_PATH".
[propagated-inputs]: Use "cross-kernel-headers" to determine the correct headers.
[native-inputs]: Use "cross-mig" when target is GNU/Hurd.
---
gnu/packages/cross-base.scm | 169 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 161 insertions(+), 8 deletions(-)
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 3bd30fd..b4324c2 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -25,6 +26,7 @@
#:use-module (gnu packages base)
#:use-module (gnu packages commencement)
#:use-module (gnu packages linux)
+ #:use-module (gnu packages hurd)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix utils)
@@ -33,6 +35,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
+ #:use-module (ice-9 regex)
#:export (cross-binutils
cross-libc
cross-gcc))
@@ -292,12 +295,12 @@ GCC that does not target a libc; otherwise, target that libc."
(files '("lib" "lib64")))))
(native-search-paths '())))
-(define* (cross-libc target
- #:optional
- (xgcc (cross-gcc target))
- (xbinutils (cross-binutils target)))
- "Return a libc cross-built for TARGET, a GNU triplet. Use XGCC and
-XBINUTILS and the cross tool chain."
+(define* (cross-kernel-headers target
+ #:optional
+ (xgcc (cross-gcc target))
+ (xbinutils (cross-binutils target)))
+ "Return headers depending on TARGET."
+
(define xlinux-headers
(package (inherit linux-libre-headers)
(name (string-append (package-name linux-libre-headers)
@@ -320,6 +323,147 @@ XBINUTILS and the cross tool chain."
("cross-binutils" ,xbinutils)
,@(package-native-inputs linux-libre-headers)))))
+ (define xgnumach-headers
+ (package (inherit gnumach-headers)
+ (name (string-append (package-name gnumach-headers)
+ "-cross-" target))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(package-native-inputs gnumach-headers)))))
+
+ (define xmig
+ (package (inherit mig)
+ (name (string-append "mig-cross"))
+ (arguments
+ `(#:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26))
+ #:phases (alist-cons-before
+ 'configure 'set-cross-headers-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((mach (assoc-ref inputs "cross-gnumach-headers"))
+ (cpath (string-append mach "/include")))
+ (for-each (cut setenv <> cpath)
+ '("CROSS_C_INCLUDE_PATH"
+ "CROSS_CPLUS_INCLUDE_PATH"
+ "CROSS_OBJC_INCLUDE_PATH"
+ "CROSS_OBJCPLUS_INCLUDE_PATH"))))
+ %standard-phases)
+ #:configure-flags (list ,(string-append "--target=" target))
+ ,@(package-arguments mig)))
+
+ (propagated-inputs `(("cross-gnumach-headers" ,xgnumach-headers)))
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ,@(package-native-inputs mig)))))
+
+ (define xhurd-headers
+ (package (inherit hurd-headers)
+ (name (string-append (package-name hurd-headers)
+ "-cross-" target))
+
+ (propagated-inputs `(("cross-mig" ,xmig)))
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ("cross-mig" ,xmig)
+ ,@(alist-delete "mig"(package-native-inputs hurd-headers))))))
+
+ (define xglibc/hurd-headers
+ (package (inherit glibc/hurd-headers)
+ (name (string-append (package-name glibc/hurd-headers)
+ "-cross-" target))
+
+ (arguments
+ (substitute-keyword-arguments
+ `(#:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26))
+ ,@(package-arguments glibc/hurd-headers))
+ ((#:phases phases)
+ `(alist-cons-before
+ 'pre-configure 'set-cross-headers-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((mach (assoc-ref inputs "gnumach-headers"))
+ (hurd (assoc-ref inputs "hurd-headers"))
+ (cpath (string-append mach "/include:"
+ hurd "/include")))
+ (for-each (cut setenv <> cpath)
+ '("CROSS_C_INCLUDE_PATH"
+ "CROSS_CPLUS_INCLUDE_PATH"
+ "CROSS_OBJC_INCLUDE_PATH"
+ "CROSS_OBJCPLUS_INCLUDE_PATH"))))
+ ,phases))))
+
+ (propagated-inputs `(("gnumach-headers" ,xgnumach-headers)
+ ("hurd-headers" ,xhurd-headers)))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ("cross-mig" ,xmig)
+ ,@(alist-delete "mig"(package-native-inputs glibc/hurd-headers))))))
+
+ (define xhurd-minimal
+ (package (inherit hurd-minimal)
+ (name (string-append (package-name hurd-minimal)
+ "-cross-" target))
+ (arguments
+ (substitute-keyword-arguments
+ `(#:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26))
+ ,@(package-arguments hurd-minimal))
+ ((#:phases phases)
+ `(alist-cons-before
+ 'configure 'set-cross-headers-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((glibc-headers (assoc-ref inputs "cross-glibc-hurd-headers"))
+ (cpath (string-append glibc-headers "/include")))
+ (for-each (cut setenv <> cpath)
+ '("CROSS_C_INCLUDE_PATH"
+ "CROSS_CPLUS_INCLUDE_PATH"
+ "CROSS_OBJC_INCLUDE_PATH"
+ "CROSS_OBJCPLUS_INCLUDE_PATH"))))
+ ,phases))))
+
+ (inputs `(("cross-glibc-hurd-headers" ,xglibc/hurd-headers)))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ("cross-mig" ,xmig)
+ ,@(alist-delete "mig"(package-native-inputs hurd-minimal))))))
+
+ (define xhurd-core-headers
+ (package (inherit hurd-core-headers)
+ (name (string-append (package-name hurd-core-headers)
+ "-cross-" target))
+
+ (inputs `(("gnumach-headers" ,xgnumach-headers)
+ ("hurd-headers" ,xhurd-headers)
+ ("hurd-minimal" ,xhurd-minimal)))
+
+ (native-inputs `(("cross-gcc" ,xgcc)
+ ("cross-binutils" ,xbinutils)
+ ("cross-mig" ,xmig)
+ ,@(package-native-inputs hurd-core-headers)))))
+
+ (match target
+ ((or "i586-pc-gnu" "i586-gnu") xhurd-core-headers)
+ (_ xlinux-headers)))
+
+(define* (cross-libc target
+ #:optional
+ (xgcc (cross-gcc target))
+ (xbinutils (cross-binutils target))
+ (xheaders (cross-kernel-headers target)))
+ "Return a libc cross-built for TARGET, a GNU triplet. Use XGCC and
+XBINUTILS and the cross tool chain."
+ (define (cross-libc-for-target target)
+ "Return libc depending on TARGET."
+ (match target
+ ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
+ (_ glibc/linux)))
+
(package (inherit glibc)
(name (string-append "glibc-cross-" target))
(arguments
@@ -337,7 +481,9 @@ XBINUTILS and the cross tool chain."
(guix build utils)
(srfi srfi-26))
- ,@(package-arguments glibc))
+ ;; Package-arguments does not use the correct libc, so we use
+ ;; (cross-libc-for-target ...) to determine the correct one.
+ ,@(package-arguments (cross-libc-for-target target)))
((#:configure-flags flags)
`(cons ,(string-append "--host=" target)
,flags))
@@ -352,12 +498,14 @@ XBINUTILS and the cross tool chain."
"CROSS_CPLUS_INCLUDE_PATH"
"CROSS_OBJC_INCLUDE_PATH"
"CROSS_OBJCPLUS_INCLUDE_PATH"))
+ (setenv "CROSS_LIBRARY_PATH"
+ (string-append kernel "/lib")) ;for Hurd's libihash
#t))
,phases))))
;; Shadow the native "kernel-headers" because glibc's recipe expects the
;; "kernel-headers" input to point to the right thing.
- (propagated-inputs `(("kernel-headers" ,xlinux-headers)))
+ (propagated-inputs `(("kernel-headers" ,xheaders)))
;; FIXME: 'static-bash' should really be an input, not a native input, but
;; to do that will require building an intermediate cross libc.
@@ -365,6 +513,11 @@ XBINUTILS and the cross tool chain."
(native-inputs `(("cross-gcc" ,xgcc)
("cross-binutils" ,xbinutils)
+ ,@(if (string-match (or "i586-pc-gnu" "i586-gnu") target)
+ `(("cross-mig"
+ ,@(assoc-ref (package-native-inputs xheaders)
+ "cross-mig")))
+ '())
,@(package-inputs glibc) ;FIXME: static-bash
,@(package-native-inputs glibc)))))
--
2.9.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd systems.
2016-07-19 16:30 ` Manolis Ragkousis
@ 2016-07-20 7:16 ` Vincent Legoll
2016-07-20 11:39 ` Manolis Ragkousis
2016-07-22 12:55 ` Ludovic Courtès
1 sibling, 1 reply; 10+ messages in thread
From: Vincent Legoll @ 2016-07-20 7:16 UTC (permalink / raw)
To: Manolis Ragkousis; +Cc: guix-devel
Hello,
There's a lot of things specific to hurd in there, wouldn't that better
be located in a separate hurd.scm or something like that ?
--
Vincent Legoll
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd systems.
2016-07-20 7:16 ` Vincent Legoll
@ 2016-07-20 11:39 ` Manolis Ragkousis
0 siblings, 0 replies; 10+ messages in thread
From: Manolis Ragkousis @ 2016-07-20 11:39 UTC (permalink / raw)
To: Vincent Legoll; +Cc: guix-devel
Hello,
On 07/20/16 10:16, Vincent Legoll wrote:
> Hello,
>
> There's a lot of things specific to hurd in there, wouldn't that better
> be located in a separate hurd.scm or something like that ?
>
Well in the way I handle it in the patch, cross-libc no longer contains
any headers at all. Cross-libc now expects that xheaders will point to
the right headers to be used.
And considering that cross-kernel-headers changes packages needed to
create the cross-toolchain, (in our case from (gnu packages linux) and
(gnu packages hurd)), it must be inside (gnu packages cross-base).
I do agree though that in the future I must find a way to reduce the too
many conditionals.
Thank you,
Manolis
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd systems.
2016-07-19 16:30 ` Manolis Ragkousis
2016-07-20 7:16 ` Vincent Legoll
@ 2016-07-22 12:55 ` Ludovic Courtès
1 sibling, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2016-07-22 12:55 UTC (permalink / raw)
To: Manolis Ragkousis; +Cc: guix-devel
Hi Manolis,
Manolis Ragkousis <manolis837@gmail.com> skribis:
> This is the updated patch. I have tested it as suggested and it works.
Great!
(In the future, could you quote the relevant parts of the message you’re
replying to? Otherwise I have to search a little bit to find the
context, which increases delay, frustration, and all that. ;-))
> From e599bc5b7208be48d4fff0868fb3b53a964dae11 Mon Sep 17 00:00:00 2001
> From: Manolis Ragkousis <manolis837@gmail.com>
> Date: Wed, 8 Jun 2016 17:15:00 +0300
> Subject: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd
> systems.
>
> * gnu/packages/cross-base.scm (cross-kernel-headers): Add new variable.
> Add xgnumach-headers, xmig, xhurd-headers, xglibc/hurd-headers,
> xhurd-minimal, xhurd-core-headers.
> (cross-libc): Add cross-libc-for-target.
> [arguments]: Set "CROSS_LIBRARY_PATH".
> [propagated-inputs]: Use "cross-kernel-headers" to determine the correct headers.
> [native-inputs]: Use "cross-mig" when target is GNU/Hurd.
Still LGTM, thank you!
Ludo’.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-07-22 12:55 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-08 14:43 [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd systems Manolis Ragkousis
2016-06-12 11:48 ` Manolis Ragkousis
2016-06-12 16:38 ` Ludovic Courtès
2016-06-16 16:32 ` Manolis Ragkousis
2016-06-16 18:44 ` Manolis Ragkousis
2016-06-26 21:31 ` Ludovic Courtès
2016-07-19 16:30 ` Manolis Ragkousis
2016-07-20 7:16 ` Vincent Legoll
2016-07-20 11:39 ` Manolis Ragkousis
2016-07-22 12:55 ` Ludovic Courtès
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).