From: Manolis Ragkousis <manolis837@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd systems.
Date: Wed, 8 Jun 2016 17:43:25 +0300 [thread overview]
Message-ID: <c4afcd55-b8e2-6dbc-9da4-05ce3c9d5e17@gmail.com> (raw)
[-- 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
next reply other threads:[~2016-06-08 14:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-08 14:43 Manolis Ragkousis [this message]
2016-06-12 11:48 ` [PATCH] gnu: cross-libc: Cross build the correct libc for GNU/Hurd systems 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c4afcd55-b8e2-6dbc-9da4-05ce3c9d5e17@gmail.com \
--to=manolis837@gmail.com \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.