From 9195c2d57bc0e3aad2a4beb6806ba8d6be8b33e4 Mon Sep 17 00:00:00 2001
From: Manolis Ragkousis
Date: Thu, 17 Jul 2014 18:26: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-hurd-extern-inline.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 ++++++++++++++++++++++
.../patches/glibc-hurd-extern-inline.patch | 34 +++++++++++
gnu/packages/patches/glibc-make-4.0.patch | 12 ++++
.../patches/libpthread-glibc-preparation.patch | 58 ++++++++++++++++++
5 files changed, 176 insertions(+)
create mode 100644 gnu/packages/patches/glibc-hurd-extern-inline.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 7d2fbcc..6e26693 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -307,6 +307,8 @@ dist_patch_DATA = \
gnu/packages/patches/glib-tests-timer.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-hurd-extern-inline.patch \
gnu/packages/patches/gnunet-fix-scheduler.patch \
gnu/packages/patches/gnunet-fix-tests.patch \
gnu/packages/patches/gobject-introspection-cc.patch \
@@ -333,6 +335,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 c280cff..2166a77 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2014 Andreas Enge
;;; Copyright © 2012 Nikita Karetnikov
;;; Copyright © 2014 Mark H Weaver
+;;; Copyright © 2014 Manolis Fragkiskos Ragkousis
;;;
;;; This file is part of GNU Guix.
;;;
@@ -35,6 +36,9 @@
#:use-module (gnu packages linux)
#:use-module (gnu packages texinfo)
#:use-module (gnu packages pkg-config)
+ #: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)
@@ -512,6 +516,71 @@ 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-hurd-extern-inline.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 in Hurd is broken for now,
+ ;; 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-hurd-extern-inline.patch b/gnu/packages/patches/glibc-hurd-extern-inline.patch
new file mode 100644
index 0000000..fe45d90
--- /dev/null
+++ b/gnu/packages/patches/glibc-hurd-extern-inline.patch
@@ -0,0 +1,34 @@
+This changes the way _EXTERN_INLINE is defined so we can
+avoid external definition errors.
+https://lists.gnu.org/archive/html/bug-hurd/2014-04/msg00002.html
+
+diff --git a/signal/sigsetops.c b/signal/sigsetops.c
+index 0317662..b92c296 100644
+--- a/signal/sigsetops.c
++++ b/signal/sigsetops.c
+@@ -3,7 +3,9 @@
+
+ #include
+
+-#define _EXTERN_INLINE
++#ifndef _EXTERN_INLINE
++#define _EXTERN_INLINE __extern_inline
++#endif
+ #ifndef __USE_EXTERN_INLINES
+ # define __USE_EXTERN_INLINES 1
+ #endif
+
+This fixes 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..6764b9f
--- /dev/null
+++ b/gnu/packages/patches/libpthread-glibc-preparation.patch
@@ -0,0 +1,58 @@
+This helps to integrate libpthread as a glibc module. It
+writes the configure file, removes an rpc call not yet
+implemented on the version of gnumach we use and defines
+a missing macro.
+
+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
+
+Because we are using and older version of gnumach, there is no
+support for it yet and thread_terminate_release has to be removed.
+The rpc call thread_terminate will be enough for our needs.
+http://lists.gnu.org/archive/html/bug-hurd/2014-05/msg00127.html
+
+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
+
+The __PTHREAD_SPIN_LOCK_INITIALIZER definition is missing, so we
+define it to __SPIN_LOCK_INITIALIZER which already exists.
+
+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.1