From 7d16e8d7a69cbc452fa60c287c2436c69043678e Mon Sep 17 00:00:00 2001
From: Manolis Ragkousis
Date: Wed, 18 Jun 2014 22:16:27 +0000
Subject: [PATCH] gnu: base: Add Glibc-Hurd.
* gnu/packages/base.scm (glibc/hurd): New variable.
* gnu/packages/patches/glibc-make-4.0.patch: New patch.
* gnu/packages/patches/glibc-fix.patch: New patch.
* gnu/packages/patches/libpthread-glibc-preparation.patch: New patch.
* gnu-system.am (dist_patch_DATA): Add it.
---
gnu-system.am | 3 +
gnu/packages/base.scm | 69 ++++++++++++++++++++++
gnu/packages/patches/glibc-fix.patch | 29 +++++++++
gnu/packages/patches/glibc-make-4.0.patch | 12 ++++
.../patches/libpthread-glibc-preparation.patch | 51 ++++++++++++++++
5 files changed, 164 insertions(+)
create mode 100644 gnu/packages/patches/glibc-fix.patch
create mode 100644 gnu/packages/patches/glibc-make-4.0.patch
create mode 100644 gnu/packages/patches/libpthread-glibc-preparation.patch
diff --git a/gnu-system.am b/gnu-system.am
index 36ae689..04b2d62 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -302,6 +302,8 @@ dist_patch_DATA = \
gnu/packages/patches/glib-tests-prlimit.patch \
gnu/packages/patches/glibc-bootstrap-system.patch \
gnu/packages/patches/glibc-ldd-x86_64.patch \
+ gnu/packages/patches/glibc-make-4.0.patch \
+ gnu/packages/patches/glibc-fix.patch \
gnu/packages/patches/gnunet-fix-scheduler.patch \
gnu/packages/patches/gnunet-fix-tests.patch \
gnu/packages/patches/gobject-introspection-cc.patch \
@@ -324,6 +326,7 @@ dist_patch_DATA = \
gnu/packages/patches/libtool-skip-tests.patch \
gnu/packages/patches/libtool-skip-tests-for-mips.patch \
gnu/packages/patches/libssh-CVE-2014-0017.patch \
+ gnu/packages/patches/libpthread-glibc-preparation.patch \
gnu/packages/patches/luit-posix.patch \
gnu/packages/patches/m4-gets-undeclared.patch \
gnu/packages/patches/m4-readlink-EINVAL.patch \
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 2e16f32..7407f06 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2012, 2013, 2014 Ludovic Courtès
;;; Copyright © 2012 Nikita Karetnikov
;;; Copyright © 2014 Mark H Weaver
+;;; Copyright © 2014 Manolis Fragkiskos Ragkousis
;;;
;;; This file is part of GNU Guix.
;;;
@@ -34,6 +35,10 @@
#:use-module (gnu packages linux)
#:use-module (gnu packages texinfo)
#:use-module (gnu packages pkg-config)
+ #:use-module (gnu packages autotools)
+ #:use-module (gnu packages gettext)
+ #:use-module (gnu packages hurd)
+ #:use-module (guix git-download)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix build-system gnu)
@@ -508,6 +513,70 @@ with the Linux kernel.")
(license lgpl2.0+)
(home-page "http://www.gnu.org/software/libc/")))
+(define-public glibc/hurd
+ (package (inherit glibc)
+ (name "glibc-hurd")
+ (version "2.18")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "git://git.sv.gnu.org/hurd/glibc")
+ (commit "a9d8d3808f18de4da9b587e9bdfb6cca4704344b")))
+ (sha256
+ (base32
+ "0jmczzdyps5syhrqyf7lgl3h77br8s74qw0417jp8b4f29ks7pbz"))
+ (file-name (string-append name "-" version))
+ (patches (list (search-patch "glibc-make-4.0.patch")
+ (search-patch "glibc-manual-fix.patch")))))
+
+ ;; Libc provides , which includes a bunch of Hurd and Mach headers,
+ ;; so both should be propagated.
+ (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
+ ("hurd-headers" ,hurd-headers)
+ ("hurd-minimal" ,hurd-minimal)))
+ (native-inputs
+ `(("patch/libpthread-patch" ,(search-patch "libpthread-glibc-preparation.patch"))
+ ("mig" ,mig)
+ ("perl" ,perl)
+ ("texinfo",texinfo)
+ ("gettext" ,gnu-gettext)
+ ("libpthread" ,(origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "git://git.sv.gnu.org/hurd/libpthread")
+ (commit "f517024dce3e21c525a7b634eab61302d6b99150")))
+ (sha256
+ (base32
+ "0yqfm1hfqlyjzqv3mgf9a3mh4qxx1mqkzn5xiac2vlvji8nns35y"))
+ (file-name "libpthread" )))))
+
+ (arguments
+ (substitute-keyword-arguments (package-arguments glibc)
+ ((#:configure-flags cf)
+ `(append (list "--host=i686-pc-gnu"
+ ;; Since Hurd supports only i686
+ ;; disable everything else
+ "--disable-multi-arch"
+ ;; nscd is not available so we disable it
+ "--disable-nscd")
+ ,cf))
+ ((#:phases phases)
+ `(alist-cons-after
+ 'unpack 'prepare-libpthread
+ (lambda* (#:key inputs #:allow-other-keys)
+ (copy-recursively (assoc-ref inputs "libpthread") "libpthread")
+
+ (zero? (system* "patch" "-p1" "-i"
+ (assoc-ref %build-inputs
+ "patch/libpthread-patch")))
+
+ ;; Instead of make install-headers we do this
+ ;; We change the permissions so we can overwrite it
+ (chmod "bits/pthreadtypes.h" #o777)
+ (copy-recursively "libpthread/sysdeps/generic/bits" "bits"))
+ ,phases))))))
+
(define-public tzdata
(package
(name "tzdata")
diff --git a/gnu/packages/patches/glibc-fix.patch b/gnu/packages/patches/glibc-fix.patch
new file mode 100644
index 0000000..62b0aee
--- /dev/null
+++ b/gnu/packages/patches/glibc-fix.patch
@@ -0,0 +1,29 @@
+diff --git a/signal/sigsetops.c b/signal/sigsetops.c
+index 0317662..77bd1dc 100644
+--- a/signal/sigsetops.c
++++ b/signal/sigsetops.c
+@@ -3,7 +3,6 @@
+
+ #include
+
+-#define _EXTERN_INLINE
+ #ifndef __USE_EXTERN_INLINES
+ # define __USE_EXTERN_INLINES 1
+ #endif
+--
+1.9.0
+
+fix the error @node found before @end deftypefun
+
+diff --git a/manual/contrib.texi b/manual/contrib.texi
+index 3b9d23c..376b40d 100644
+--- a/manual/contrib.texi
++++ b/manual/contrib.texi
+@@ -1,3 +1,4 @@
address@hidden deftypefun
+ @node Contributors, Free Manuals, Platform, Top
+ @c %MENU% Who wrote what parts of the GNU C Library
+ @appendix Contributors to @theglibc{}
+--
+1.9.2
+
diff --git a/gnu/packages/patches/glibc-make-4.0.patch b/gnu/packages/patches/glibc-make-4.0.patch
new file mode 100644
index 0000000..d83de1d
--- /dev/null
+++ b/gnu/packages/patches/glibc-make-4.0.patch
@@ -0,0 +1,12 @@
+Allow libc to be compiled with GNU Make 4.0.
+
+--- glibc-2.18/configure 2013-08-11 00:52:55.000000000 +0200
++++ glibc-2.18/configure 2013-10-16 16:53:09.000000000 +0200
+@@ -4772,7 +4772,7 @@ $as_echo_n "checking version of $MAKE...
+ ac_prog_version=`$MAKE --version 2>&1 | sed -n 's/^.*GNU Make[^0-9]*\([0-9][0-9.]*\).*$/\1/p'`
+ case $ac_prog_version in
+ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
+- 3.79* | 3.[89]*)
++ 3.79* | 3.[89]* | 4.*)
+ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
+ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
diff --git a/gnu/packages/patches/libpthread-glibc-preparation.patch b/gnu/packages/patches/libpthread-glibc-preparation.patch
new file mode 100644
index 0000000..cbb3551
--- /dev/null
+++ b/gnu/packages/patches/libpthread-glibc-preparation.patch
@@ -0,0 +1,51 @@
+This will allow libpthread to be build as an addon.
+
+diff --git a/libpthread/configure b/libpthread/configure
+new file mode 100644
+index 0000000..2cdbc71
+--- /dev/null
++++ b/libpthread/configure
+@@ -0,0 +1,2 @@
++libc_add_on_canonical=libpthread
++libc_add_on_subdirs=.
+\ No newline at end of file
+--
+1.9.0
+
+There is no definition for __thread_terminate_release yet, so according to Samuel we disable it.
+
+diff --git a/libpthread/sysdeps/mach/pt-thread-terminate.c b/libpthread/sysdeps/mach/pt-thread-terminate.c
+index 6672065..129a611 100644
+--- a/libpthread/sysdeps/mach/pt-thread-terminate.c
++++ b/libpthread/sysdeps/mach/pt-thread-terminate.c
+@@ -70,9 +70,9 @@ __pthread_thread_terminate (struct __pthread *thread)
+ __mach_port_destroy (__mach_task_self (), wakeup_port);
+
+ /* Terminate and release all that's left. */
+- err = __thread_terminate_release (kernel_thread, mach_task_self (),
+- kernel_thread, reply_port,
+- stackaddr, stacksize);
++ /* err = __thread_terminate_release (kernel_thread, mach_task_self (), */
++ /* kernel_thread, reply_port, */
++ /* stackaddr, stacksize); */
+
+ /* The kernel does not support it yet. Leak but at least terminate
+ correctly. */
+--
+1.9.2
+
+__SPIN_LOCK_INITIALIZER gets defined to zero so we can start using libpthread.
+
+diff --git a/libpthread/sysdeps/mach/bits/spin-lock.h b/libpthread/sysdeps/mach/bits/spin-lock.h
+index 537dac9..fca0e5a 100644
+--- a/libpthread/sysdeps/mach/bits/spin-lock.h
++++ b/libpthread/sysdeps/mach/bits/spin-lock.h
+@@ -30,7 +30,7 @@ typedef __spin_lock_t __pthread_spinlock_t;
+
+ /* Initializer for a spin lock object. */
+ #ifndef __PTHREAD_SPIN_LOCK_INITIALIZER
+-#error __PTHREAD_SPIN_LOCK_INITIALIZER undefined: should be defined by .
++#define __PTHREAD_SPIN_LOCK_INITIALIZER __SPIN_LOCK_INITIALIZER
+ #endif
+
+ __END_DECLS
--
2.0.0