code:
This patch allows libc to be used with the heavily-patched kernel found
on CentOS 6, which identifies itself as 2.6.32.

See <https://lists.gnu.org/archive/html/guix-devel/2018-02/msg00392.html>.

Patch taken from Nixpkgs.

diff --git a/sysdeps/unix/sysv/linux/configure b/sysdeps/unix/sysv/linux/configure
index cace758c01..38fe7fe0b0 100644
--- a/sysdeps/unix/sysv/linux/configure
+++ b/sysdeps/unix/sysv/linux/configure
@@ -69,7 +69,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kernel header at least $minimum_kernel" >&5
 $as_echo_n "checking for kernel header at least $minimum_kernel... " >&6; }
 decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
-abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
+abinum=`echo "2.6.32.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <linux/version.h>
diff --git a/sysdeps/unix/sysv/linux/configure.ac b/sysdeps/unix/sysv/linux/configure.ac
index 13abda0a51..6abc12eaed 100644
--- a/sysdeps/unix/sysv/linux/configure.ac
+++ b/sysdeps/unix/sysv/linux/configure.ac
@@ -50,7 +50,7 @@ fi
 AC_MSG_CHECKING(for kernel header at least $minimum_kernel)
 changequote(,)dnl
 decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
-abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
+abinum=`echo "2.6.32.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
 changequote([,])dnl
 AC_TRY_COMPILE([#include <linux/version.h>
 #if LINUX_VERSION_CODE < $decnum
diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h
index 823cd8224d..482caaeeec 100644
--- a/sysdeps/unix/sysv/linux/dl-osinfo.h
+++ b/sysdeps/unix/sysv/linux/dl-osinfo.h
@@ -39,7 +39,7 @@
 	  GLRO(dl_osversion) = version;					      \
 									      \
 	/* Now we can test with the required version.  */		      \
-	if (__LINUX_KERNEL_VERSION > 0 && version < __LINUX_KERNEL_VERSION)   \
+	if (__LINUX_KERNEL_VERSION > 0 && version < __LINUX_KERNEL_VERSION && version != 0x020620)   \
 	  /* Not sufficent.  */						      \
 	  FATAL ("FATAL: kernel too old\n");				      \
       }									      \


code:
This patch enables building glibc-2.2.5 using TCC and GNU Make 4.x and Mes C Library.

  * Makefile: Do not link with (non-existent) libgc_eh.
  * Makefile: Add SHELL variable, ready for substitution, export it.
  * Makefile: Do not build or assume librpc_compat_pic.
  * Makefile: Do not build libmesusage.
  * gen-as-const: Always add preamble.
  * [BOOTSTRAP_GLIBC]: Really disable rpc.

Upstream status: Not presented upstream.

diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/elf/Makefile glibc-2.16.0/elf/Makefile
--- /home/janneke/src/glibc-2.16.0/elf/Makefile	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/elf/Makefile	2018-09-02 12:54:44.616962543 +0200
@@ -17,6 +17,8 @@

 # Makefile for elf subdirectory of GNU C Library.

+SHELL := /bin/sh
+
 subdir		:= elf

 headers		= elf.h bits/elfclass.h link.h bits/link.h
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/include/libc-symbols.h glibc-2.16.0/include/libc-symbols.h
--- /home/janneke/src/glibc-2.16.0/include/libc-symbols.h	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/include/libc-symbols.h	2018-09-02 22:41:00.798467803 +0200
@@ -558,9 +558,9 @@ for linking")
 # define libc_hidden_weak(name) hidden_weak (name)
 # ifdef LINK_OBSOLETE_RPC
    /* libc_hidden_nolink_sunrpc should only get used in sunrpc code.  */
-#  define libc_hidden_nolink_sunrpc(name, version) hidden_def (name)
+#  define libc_hidden_nolink_sunrpc(name, version)
 # else
-#  define libc_hidden_nolink_sunrpc(name, version) hidden_nolink (name, libc, version)
+#  define libc_hidden_nolink_sunrpc(name, version)
 # endif
 # define libc_hidden_ver(local, name) hidden_ver (local, name)
 # define libc_hidden_data_def(name) hidden_data_def (name)
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/Makeconfig glibc-2.16.0/Makeconfig
--- /home/janneke/src/glibc-2.16.0/Makeconfig	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/Makeconfig	2018-09-03 00:00:25.290357414 +0200
@@ -23,6 +23,9 @@ ifneq (,)
 This makefile requires GNU Make.
 endif

+SHELL := /bin/sh
+export SHELL
+
 all: # Make this the default goal

 ifneq "$(origin +included-Makeconfig)" "file"
@@ -521,9 +524,9 @@ ifneq ($(have-cc-with-libunwind),yes)
 else
   libunwind = -lunwind
 endif
-libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
+libgcc_eh := #-Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
 gnulib := -lgcc $(libgcc_eh)
-static-gnulib := -lgcc -lgcc_eh $(libunwind)
+static-gnulib := -lgcc $(libunwind)
 libc.so-gnulib := -lgcc
 endif
 +preinit = $(addprefix $(csu-objpfx),crti.o)
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/Makefile glibc-2.16.0/Makefile
--- /home/janneke/src/glibc-2.16.0/Makefile	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/Makefile	2018-09-02 23:01:10.485803965 +0200
@@ -22,6 +22,9 @@ ifneq (,)
 This makefile requires GNU Make.
 endif

+SHELL := /bin/sh
+export SHELL
+
 include Makeconfig

@@ -135,13 +138,10 @@ $(common-objpfx)linkobj/libc.so: $(elfob
 				 $(shlib-lds)
 	$(build-shlib)

-$(common-objpfx)linkobj/libc_pic.a: $(common-objpfx)libc_pic.a \
-				    $(common-objpfx)sunrpc/librpc_compat_pic.a
+$(common-objpfx)linkobj/libc_pic.a: $(common-objpfx)libc_pic.a
 	$(..)./scripts/mkinstalldirs $(common-objpfx)linkobj
 	(cd $(common-objpfx)linkobj; \
 	 $(AR) x ../libc_pic.a; \
-	 rm $$($(AR) t ../sunrpc/librpc_compat_pic.a | sed 's/^compat-//'); \
-	 $(AR) x ../sunrpc/librpc_compat_pic.a; \
 	 $(AR) cr libc_pic.a *.os; \
 	 rm *.os)
 endif
@@ -151,7 +151,7 @@ endif
 # the current libc build for testing.
 $(common-objpfx)testrun.sh: $(common-objpfx)config.make \
 			    $(..)Makeconfig $(..)Makefile
-	(echo '#!/bin/sh'; \
+	(echo '#! $(SHELL)'; \
 	 echo 'builddir=`dirname "$$0"`'; \
 	 echo 'GCONV_PATH="$${builddir}/iconvdata" \'; \
 	 echo 'exec $(subst $(common-objdir),"$${builddir}",\
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/Makefile.in glibc-2.16.0/Makefile.in
--- /home/janneke/src/glibc-2.16.0/Makefile.in	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/Makefile.in	2018-09-02 13:03:01.892962551 +0200
@@ -9,3 +9,6 @@ all .DEFAULT:
 install:
 	LANGUAGE=C LC_ALL=C; export LANGUAGE LC_ALL; \
 	$(MAKE) -r PARALLELMFLAGS="$(PARALLELMFLAGS)" -C $(srcdir) objdir=`pwd` $@
+
+export SHELL
+export BASH
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/malloc/Makefile glibc-2.16.0/malloc/Makefile
--- /home/janneke/src/glibc-2.16.0/malloc/Makefile	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/malloc/Makefile	2018-09-02 17:11:33.461547394 +0200
@@ -35,7 +35,7 @@ install-lib := libmcheck.a
 non-lib.a := libmcheck.a

 # Additional library.
-extra-libs = libmemusage
+extra-libs = #libmemusage
 extra-libs-others = $(extra-libs)

 libmemusage-routines = memusage
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/nscd/cache.c glibc-2.16.0/nscd/cache.c
--- /home/janneke/src/glibc-2.16.0/nscd/cache.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/nscd/cache.c	2018-09-02 23:38:31.757616750 +0200
@@ -74,7 +74,11 @@ struct datahead *
 cache_search (request_type type, const void *key, size_t len,
 	      struct database_dyn *table, uid_t owner)
 {
+#if !BOOTSTRAP_GLIBC
   unsigned long int hash = __nis_hash (key, len) % table->head->module;
+#else
+  unsigned long int hash = 0;
+#endif

   unsigned long int nsearched = 0;
   struct datahead *result = NULL;
@@ -153,7 +153,11 @@ cache_add (int type, const void *key, si
 	       first ? _(" (first)") : "");
     }

+#if !BOOTSTRAP_GLIBC
   unsigned long int hash = __nis_hash (key, len) % table->head->module;
+#else
+  unsigned long int hash = 0;
+#endif
   struct hashentry *newp;

   newp = mempool_alloc (table, sizeof (struct hashentry), 0);
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/nscd/Makefile glibc-2.16.0/nscd/Makefile
--- /home/janneke/src/glibc-2.16.0/nscd/Makefile	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/nscd/Makefile	2018-09-02 23:49:29.948031787 +0200
@@ -126,9 +126,7 @@ include $(patsubst %,$(..)cppflags-itera
 $(objpfx)nscd: $(nscd-modules:%=$(objpfx)%.o)

 ifeq ($(build-shared),yes)
-$(objpfx)nscd: $(common-objpfx)rt/librt.so $(shared-thread-library) \
-	       $(common-objpfx)nis/libnsl.so
+$(objpfx)nscd: $(common-objpfx)rt/librt.so $(shared-thread-library)
 else
-$(objpfx)nscd: $(common-objpfx)rt/librt.a $(static-thread-library) \
-	       $(common-objpfx)nis/libnsl.a
+$(objpfx)nscd: $(common-objpfx)rt/librt.a $(static-thread-library)
 endif
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/nscd/nscd_helper.c glibc-2.16.0/nscd/nscd_helper.c
--- /home/janneke/src/glibc-2.16.0/nscd/nscd_helper.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/nscd/nscd_helper.c	2018-09-02 23:38:04.941189464 +0200
@@ -474,7 +474,7 @@ struct datahead *
 __nscd_cache_search (request_type type, const char *key, size_t keylen,
 		     const struct mapped_database *mapped, size_t datalen)
 {
-  unsigned long int hash = __nis_hash (key, keylen) % mapped->head->module;
+  unsigned long int hash = 0;
   size_t datasize = mapped->datasize;

   ref_t trail = mapped->head->array[hash];
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/nss/getent.c glibc-2.16.0/nss/getent.c
--- /home/janneke/src/glibc-2.16.0/nss/function.def	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/nss/function.def	2018-09-18 13:54:49.582060539 +0200
@@ -63,10 +63,12 @@
 DEFINE_GET (files, pwnam)
 DEFINE_GET (files, pwuid)

+#if !BOOTSTRAP_GLIBC
 /* rpc */
 DEFINE_ENT (files, rpc)
 DEFINE_GETBY (files, rpc, name)
 DEFINE_GETBY (files, rpc, number)
+#endif

 /* services */
 DEFINE_ENT (files, serv)
diff -u ~/src/glibc-2.16.0/nss/getent.c glibc-2.16.0/nss/getent.c
--- /home/janneke/src/glibc-2.16.0/nss/getent.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/nss/getent.c	2018-09-18 13:57:41.856849140 +0200
@@ -700,6 +700,7 @@
   return result;
 }

+#if !BOOTSTRAP_GLIBC
 /* Now is all for rpc */
 static inline void
 print_rpc (struct rpcent *rpc)
@@ -745,6 +746,7 @@

   return result;
 }
+#endif //rpc

 /* for services */
 static void
@@ -880,7 +882,9 @@
 D(networks)
 D(passwd)
 D(protocols)
+#if !BOOTSTRAP_GLIBC
 D(rpc)
+#endif
 D(services)
 D(shadow)
 #undef D
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/resolv/netdb.h glibc-2.16.0/resolv/netdb.h
--- /home/janneke/src/glibc-2.16.0/resolv/netdb.h	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/resolv/netdb.h	2018-09-08 08:49:30.537811219 +0200
@@ -26,11 +26,13 @@

 #include <netinet/in.h>
 #include <stdint.h>
+#if 0 //!BOOTSTRAP_GLIBC
 #ifdef __USE_MISC
 /* This is necessary to make this include file properly replace the
    Sun version.  */
 # include <rpc/netdb.h>
 #endif
+#endif

 #ifdef __USE_GNU
 # define __need_sigevent_t
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/Rules glibc-2.16.0/Rules
--- /home/janneke/src/glibc-2.16.0/Rules	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/Rules	2018-09-02 10:52:06.927362861 +0200
@@ -24,6 +24,9 @@ ifneq (,)
 This makefile requires GNU Make.
 endif

+export SHELL
+export BASH
+
 all: # Don't let the default goal come from Makeconfig.

 include $(firstword $(..) ../)Makeconfig
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/scripts/gen-as-const.awk glibc-2.16.0/scripts/gen-as-const.awk
--- /home/janneke/src/glibc-2.16.0/scripts/gen-as-const.awk	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/scripts/gen-as-const.awk	2018-09-01 18:08:37.266516330 +0200
@@ -14,6 +14,12 @@ BEGIN { started = 0 }

 NF >= 1 && !started {
   if (test) {
+    print "\n#include <stddef.h>";
+    print "\n#include <stdint.h>";
+#    print "\ntypedef unsigned long size_t;";
+    print "\n#ifndef offsetof";
+    print "\n#define offsetof(type, field) ((size_t)&((type *)0)->field)";
+    print "\n#endif";
     print "\n#include <inttypes.h>";
     print "\n#include <stdio.h>";
     print "\n#include <bits/wordsize.h>";
@@ -33,8 +39,15 @@ NF >= 1 && !started {
       " source, #name, U (asconst_##name), #expr, (c_t) (expr));" \
       " } else ++good;\n";
   }
-  else
+  else {
+    print "\n#include <stddef.h>";
+    print "\n#include <stdint.h>";
+#    print "\ntypedef unsigned long size_t;";
+    print "\n#ifndef offsetof";
+    print "\n#define offsetof(type, field) ((size_t)&((type *)0)->field)";
+    print "\n#endif";
     print "void dummy(void) {";
+  }
   started = 1;
 }

diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/sunrpc/auth_none.c glibc-2.16.0/sunrpc/auth_none.c
--- /home/janneke/src/glibc-2.16.0/sunrpc/auth_none.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/sunrpc/auth_none.c	2018-09-02 22:09:21.629007932 +0200
@@ -95,7 +95,9 @@ authnone_create (void)
   __libc_once (authnone_private_guard, authnone_create_once);
   return &authnone_private.no_client;
 }
+#if !BOOTSTRAP_GLIBC
 libc_hidden_nolink_sunrpc (authnone_create, GLIBC_2_0)
+#endif

 static bool_t
 authnone_marshal (AUTH *client, XDR *xdrs)
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/sunrpc/authuxprot.c glibc-2.16.0/sunrpc/authuxprot.c
--- /home/janneke/src/glibc-2.16.0/sunrpc/authuxprot.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/sunrpc/authuxprot.c	2018-09-02 22:15:51.927158451 +0200
@@ -63,4 +63,6 @@ xdr_authunix_parms (XDR * xdrs, struct a
     }
   return FALSE;
 }
+#if !BOOTSTRAP_GLIBC
 libc_hidden_nolink_sunrpc (xdr_authunix_parms, GLIBC_2_0)
+#endif
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/sunrpc/bindrsvprt.c glibc-2.16.0/sunrpc/bindrsvprt.c
--- /home/janneke/src/glibc-2.16.0/sunrpc/bindrsvprt.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/sunrpc/bindrsvprt.c	2018-09-02 22:24:32.687187675 +0200
@@ -96,4 +96,7 @@ bindresvport (int sd, struct sockaddr_in

   return res;
 }
+#if !BOOTSTRAP_GLIBC
 libc_hidden_def (bindresvport)
+#endif
+
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/sunrpc/clnt_raw.c glibc-2.16.0/sunrpc/clnt_raw.c
--- /home/janneke/src/glibc-2.16.0/sunrpc/clnt_raw.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/sunrpc/clnt_raw.c	2018-09-02 22:33:21.151343826 +0200
@@ -40,6 +40,7 @@
 #include <rpc/svc.h>
 #include <rpc/xdr.h>
 #include <libintl.h>
+#include <stddef.h>

 #define MCALL_MSG_SIZE 24

@@ -129,7 +130,9 @@ clntraw_create (u_long prog, u_long vers
   client->cl_auth = authnone_create ();
   return client;
 }
+#if !BOOTSTRAP_GLIBC
 libc_hidden_nolink_sunrpc (clntraw_create, GLIBC_2_0)
+#endif

 static enum clnt_stat
 clntraw_call (h, proc, xargs, argsp, xresults, resultsp, timeout)
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/sunrpc/clnt_simp.c glibc-2.16.0/sunrpc/clnt_simp.c
--- /home/janneke/src/glibc-2.16.0/sunrpc/clnt_simp.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/sunrpc/clnt_simp.c	2018-09-02 22:34:14.884175251 +0200
@@ -139,7 +139,9 @@ callrpc (const char *host, u_long prognu
     crp->valid = 0;
   return (int) clnt_stat;
 }
+#if !BOOTSTRAP_GLIBC
 libc_hidden_nolink_sunrpc (callrpc, GLIBC_2_0)
+#endif

 #ifdef _RPC_THREAD_SAFE_
 void

license: mit


code:
This patch enables building glibc-2.2.5 using TCC and GNU Make 4.x and Mes C Library.

  * Makefile: Do not assemble from stdin, use file indirection.
  * Makefile: Add new target: install-lib-all.
  * Makefile: Avoid building stub DOC.
  * [_LIBC_REENTRANT]: Add missing guarding.
  * [MES_BOOTSTRAP]: Disable some GCC extensions.
  * [MES_BOOTSTRAP]: Add missing GCC div/mod defines.

Upstream status: Not presented upstream.

diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/config.h.in glibc-2.2.5/config.h.in
--- ../glibc-2.2.5/config.h.in	2001-11-16 02:02:56.000000000 +0100
+++ glibc-2.2.5/config.h.in	2018-06-17 21:30:02.313029074 +0200
@@ -1,3 +1,10 @@
+#if MES_BOOTSTRAP && BOOTSTRAP_GLIBC
+#undef __umoddi3
+#define __umoddi3(a,b) ((a)%(b))
+#undef __udivdi3
+#define __udivdi3(a,b) ((a)/(b))
+#endif
+
 #if !defined ASSEMBLER && !defined _ISOMAC && !defined __OPTIMIZE__
 # error "glibc cannot be compiled without optimization"
 #endif
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/configure glibc-2.2.5/configure
--- ../glibc-2.2.5/configure	2002-01-08 23:16:44.000000000 +0100
+++ glibc-2.2.5/configure	2018-06-07 20:47:26.608895319 +0200
@@ -1530,7 +1530,7 @@ echo "configure:1530: checking version o
   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 -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/Makeconfig glibc-2.2.5/Makeconfig
--- ../glibc-2.2.5/Makeconfig	2001-09-12 20:49:45.000000000 +0200
+++ glibc-2.2.5/Makeconfig	2018-06-20 16:33:35.472167202 +0200
@@ -400,7 +400,7 @@ ifndef +link
 						     $(start-installed-name))\
 			   $(+preinit) $(link-extra-libs) \
 			   $(common-objpfx)libc% $(+postinit),$^) \
-	      $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit)
+	      $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit) -lc -lgcc2
 endif
 # Command for statically linking programs with the C library.
 ifndef +link-static
@@ -412,7 +412,7 @@ ifndef +link-static
 						     $(start-installed-name))\
 			   $(+preinit) $(link-extra-libs-static) \
 			   $(common-objpfx)libc% $(+postinit),$^) \
-	      $(link-extra-libs-static) $(link-libc-static) $(+postctor) $(+postinit)
+	      $(link-extra-libs-static) $(link-libc-static) $(+postctor) $(+postinit) -lc -lgcc2
 endif
 # Command for statically linking bounded-pointer programs with the C library.
 ifndef +link-bounded
@@ -424,7 +424,7 @@ ifndef +link-bounded
 						     $(start-installed-name))\
 			   $(+preinit) $(link-extra-libs-bounded) \
 			   $(common-objpfx)libc% $(+postinit),$^) \
-	      $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit)
+	      $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit) -lc -lgcc2
 endif
 ifndef config-LDFLAGS
 ifeq (yesyes,$(build-shared)$(elf))
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/Makerules glibc-2.2.5/Makerules
--- ../glibc-2.2.5/Makerules	2001-11-16 02:02:19.000000000 +0100
+++ glibc-2.2.5/Makerules	2018-06-10 15:03:42.390329860 +0200
@@ -748,6 +748,18 @@ endef
 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
 			     $(inst_libdir)/$(patsubst %,$(libtype$o),\
 						     $(libprefix)$(libc-name)))
+
+ifeq (yes,$(build-shared))
+install-lib-all: $(inst_libdir)/libc.a \
+                $(inst_slibdir)/libc.so$(libc.so-version) \
+		$(inst_slibdir)/libc-$(version).so \
+		$(inst_libdir)/libc.so \
+	install-lib
+else
+install-lib-all: $(inst_libdir)/libc.a \
+	install-lib
+endif
+
 install: $(installed-libcs)
 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
 	$(make-target-directory)
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/misc/syslog.c glibc-2.2.5/misc/syslog.c
--- ../glibc-2.2.5/misc/syslog.c	2001-08-31 01:13:49.000000000 +0200
+++ glibc-2.2.5/misc/syslog.c	2018-06-09 09:01:20.008918690 +0200
@@ -216,9 +216,11 @@ vsyslog(pri, fmt, ap)

 	/* Prepare for multiple users.  We have to take care: open and
 	   write are cancellation points.  */
+#if _LIBC_REENTRANT
 	__libc_cleanup_region_start (1, (void (*) (void *)) cancel_handler,
 				     &oldaction_ptr);
 	__libc_lock_lock (syslog_lock);
+#endif

 	/* Prepare for a broken connection.  */
  	memset (&action, 0, sizeof (action));
@@ -268,9 +270,11 @@ vsyslog(pri, fmt, ap)
 	if (sigpipe == 0)
 		__sigaction (SIGPIPE, &oldaction, (struct sigaction *) NULL);

+#if _LIBC_REENTRANT
 	/* End of critical section.  */
 	__libc_cleanup_region_end (0);
 	__libc_lock_unlock (syslog_lock);
+#endif

 	free (buf);
 }
@@ -326,16 +330,20 @@ openlog_internal(const char *ident, int
 void
 openlog (const char *ident, int logstat, int logfac)
 {
+#if _LIBC_REENTRANT
   /* Protect against multiple users.  */
   __libc_cleanup_region_start (1,
 			       (void (*) __P ((void *))) __libc_mutex_unlock,
 			       &syslog_lock);
   __libc_lock_lock (syslog_lock);
+#endif

   openlog_internal (ident, logstat, logfac);

+#if _LIBC_REENTRANT
   /* Free the lock.  */
   __libc_cleanup_region_end (1);
+#endif
 }

 static void
@@ -358,18 +366,22 @@ closelog_internal()
 void
 closelog ()
 {
+#if _LIBC_REENTRANT
   /* Protect against multiple users.  */
   __libc_cleanup_region_start (1,
 			       (void (*) __P ((void *))) __libc_mutex_unlock,
 			       &syslog_lock);
   __libc_lock_lock (syslog_lock);
+#endif

   closelog_internal ();
   LogTag = NULL;
   LogType = SOCK_DGRAM; /* this is the default */

+#if _LIBC_REENTRANT
   /* Free the lock.  */
   __libc_cleanup_region_end (1);
+#endif
 }

 #ifdef _LIBC_REENTRANT
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/Rules glibc-2.2.5/Rules
--- ../glibc-2.2.5/Rules	2001-08-30 00:44:35.000000000 +0200
+++ glibc-2.2.5/Rules	2018-06-09 08:15:54.880683675 +0200
@@ -218,7 +218,7 @@ endif
 	fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; 	\
 	filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`;	\
 	iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`;	\
-	fopen_max=$${fopen_max:-16};					\
+	fopen_max=$${fu_fopen_max:-16};					\
 	filename_max=$${filename_max:-1024};				\
 	if [ -z $$iov_max ]; then					\
 	  define_iov_max="# undef IOV_MAX";				\
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/stdio-common/perror.c glibc-2.2.5/stdio-common/perror.c
--- ../glibc-2.2.5/stdio-common/perror.c	2001-09-01 07:33:01.000000000 +0200
+++ glibc-2.2.5/stdio-common/perror.c	2018-06-09 10:42:25.909899529 +0200
@@ -48,6 +48,9 @@ perror_internal (FILE *fp, const char *s
 }

+#if MES_BOOTSTRAP
+#define fileno_unlocked(x) 1
+#endif
 /* Print a line on stderr consisting of the text in S, a colon, a space,
    a message describing the meaning of the contents of `errno' and a newline.
    If S is NULL or "", the colon and space are omitted.  */
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/sysdeps/i386/fpu/ftestexcept.c glibc-2.2.5/sysdeps/i386/fpu/ftestexcept.c
--- ../glibc-2.2.5/sysdeps/i386/fpu/ftestexcept.c	2001-07-06 06:55:53.000000000 +0200
+++ glibc-2.2.5/sysdeps/i386/fpu/ftestexcept.c	2018-06-09 09:45:13.363031424 +0200
@@ -25,8 +25,10 @@ fetestexcept (int excepts)
 {
   int temp;

+#if !MES_BOOTSTRAP
   /* Get current exceptions.  */
   __asm__ ("fnstsw %0" : "=a" (temp));
+#endif

   return temp & excepts & FE_ALL_EXCEPT;
 }
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/sysdeps/unix/make-syscalls.sh glibc-2.2.5/sysdeps/unix/make-syscalls.sh
--- ../glibc-2.2.5/sysdeps/unix/make-syscalls.sh	2001-09-13 00:19:30.000000000 +0200
+++ glibc-2.2.5/sysdeps/unix/make-syscalls.sh	2018-06-20 15:16:01.813004453 +0200
@@ -173,7 +173,7 @@ shared-only-routines += $file
   done

   # And finally, pipe this all into the compiler.
-  echo '	) | $(COMPILE.S) -x assembler-with-cpp -o $@ -'
+  echo '	) > stdin.c; $(COMPILE.S) -x assembler-with-cpp -o $@ stdin.c'

   case $weak in
   *@*)
@@ -284,7 +284,7 @@ shared-only-routines += $file
     echo "\
 	 echo ''; \\
 	 echo '#include <bp-thunks.h>'; \\
-	) | \$(COMPILE.c) -x c -o \$@ -"
+	) > stdin.c; \$(COMPILE.c) -x c -o \$@ stdin.c"
 ### Use this for debugging intermediate output:
 ### 	) >\$(@:.ob=.c)
 ### 	\$(subst -c,-E,\$(COMPILE.c)) -o \$(@:.ob=.ib) \$(@:.ob=.c)
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/sysdeps/unix/sysv/linux/sys/timex.h glibc-2.2.5/sysdeps/unix/sysv/linux/sys/timex.h
--- ../glibc-2.2.5/sysdeps/unix/sysv/linux/sys/timex.h	2001-07-06 06:56:21.000000000 +0200
+++ glibc-2.2.5/sysdeps/unix/sysv/linux/sys/timex.h	2018-06-09 20:09:07.713806647 +0200
@@ -54,10 +54,12 @@ struct timex
   long int errcnt;	/* calibration errors (ro) */
   long int stbcnt;	/* stability limit exceeded (ro) */

+#if !MES_BOOTSTRAP
   /* ??? */
   int  :32; int  :32; int  :32; int  :32;
   int  :32; int  :32; int  :32; int  :32;
   int  :32; int  :32; int  :32; int  :32;
+#endif
 };

 /* Mode codes (timex.mode) */
--- ../glibc-2.2.5/manual/Makefile	2001-08-28 10:05:40.000000000 +0200
+++ glibc-2.2.5/manual/Makefile	2018-06-09 10:13:03.093633660 +0200
@@ -247,7 +247,11 @@
 .PHONY: stubs
 stubs: $(objpfx)stubs
 endif
-$(objpfx)stubs ../po/manual.pot $(objpfx)stamp%:
+po/manual.pot $(objpfx)stubs:
+	$(make-target-directory)
+	touch $@
+
+$(objpfx)stamp%:
 	$(make-target-directory)
 	touch $@


code:
We want to allow builds in chroots that lack /bin/sh.  Thus, system(3)
and popen(3) need to be tweaked to use the right shell.  For the bootstrap
glibc, we just use whatever `sh' can be found in $PATH.  The final glibc
instead uses the hard-coded absolute file name of `bash'.

--- a/sysdeps/posix/system.c
+++ b/sysdeps/posix/system.c
@@ -134,7 +134,7 @@ do_system (const char *line)
       INIT_LOCK ();

       /* Exec the shell.  */
-      (void) __execve (SHELL_PATH, (char *const *) new_argv, __environ);
+      (void) __execvpe (SHELL_NAME, (char *const *) new_argv, __environ);
       _exit (127);
     }
   else if (pid < (pid_t) 0)

--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -145,7 +145,7 @@ _IO_new_proc_open (fp, command, mode)
 	    _IO_close (fd);
 	}

-      _IO_execl ("/bin/sh", "sh", "-c", command, (char *) 0);
+      execlp ("sh", "sh", "-c", command, (char *) 0);
       _IO__exit (127);
     }
   _IO_close (child_end);


code:
We want to allow builds in chroots that lack /bin/sh.  Thus, system(3)
and popen(3) need to be tweaked to use the right shell.  For the bootstrap
glibc, we just use whatever `sh' can be found in $PATH.  The final glibc
instead uses the hard-coded absolute file name of `bash'.

--- a/sysdeps/posix/system.c
+++ b/sysdeps/posix/system.c
@@ -106,8 +106,8 @@ do_system (const char *line)
       (void) UNBLOCK;

       /* Exec the shell.  */
-      (void) __execve (SHELL_PATH, (char *const *) new_argv, __environ);
+      (void) execvp (SHELL_NAME, (char *const *) new_argv);
       _exit (127);
     }
   else if (pid < (pid_t) 0)
     /* The fork failed.  */
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -170,7 +170,7 @@ _IO_new_proc_open (fp, command, mode)
       for (p = proc_file_chain; p; p = p->next)
 	_IO_close (_IO_fileno ((_IO_FILE *) p));

-      _IO_execl ("/bin/sh", "sh", "-c", command, (char *) 0);
+      execlp ("sh", "sh", "-c", command, (char *) 0);
       _IO__exit (127);
     }
   _IO_close (child_end);


code:
We want to allow builds in chroots that lack /bin/sh.  Thus, system(3)
and popen(3) need to be tweaked to use the right shell.  For the bootstrap
glibc, we just use whatever `sh' can be found in $PATH.  The final glibc
instead uses the hard-coded absolute file name of `bash'.

In addition, status should be initialized to 0 and not -1.

diff --git a/libio/iopopen.c b/libio/iopopen.c
index ebc381ed7c..e0d3ed1bc3 100644
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -85,7 +85,7 @@ spawn_process (posix_spawn_file_actions_t *fa, FILE *fp, const char *command,
 	return false;
     }

-  if (__posix_spawn (&((_IO_proc_file *) fp)->pid, _PATH_BSHELL, fa, 0,
+  if (posix_spawnp (&((_IO_proc_file *) fp)->pid, "sh", fa, 0,
 		     (char *const[]){ (char*) "sh", (char*) "-c",
 		     (char *) command, NULL }, __environ) != 0)
     return false;
diff --git a/sysdeps/posix/system.c b/sysdeps/posix/system.c
index a03f478fc7..94da6facf3 100644
--- a/sysdeps/posix/system.c
+++ b/sysdeps/posix/system.c
@@ -101,7 +101,7 @@ cancel_handler (void *arg)
 static int
 do_system (const char *line)
 {
-  int status = -1;
+  int status = 0;
   int ret;
   pid_t pid;
   struct sigaction sa;
@@ -145,7 +145,7 @@ do_system (const char *line)
   __posix_spawnattr_setflags (&spawn_attr,
 			      POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK);

-  ret = __posix_spawn (&pid, SHELL_PATH, 0, &spawn_attr,
+  ret = posix_spawnp (&pid, SHELL_NAME, 0, &spawn_attr,
 		       (char *const[]){ (char *) SHELL_NAME,
 					(char *) "-c",
 					(char *) line, NULL },


code:
Fix a regression in glibc 2.27 when built without ldconfig.  See
<https://sourceware.org/bugzilla/show_bug.cgi?id=22977> for details.

diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index 6137304b0b..7d630f36d8 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -508,7 +508,7 @@ for linking")
 # ifndef __ASSEMBLER__
 #  if !defined SHARED && IS_IN (libc) && !defined LIBC_NONSHARED \
       && (!defined PIC || !defined NO_HIDDEN_EXTERN_FUNC_IN_PIE) \
-      && !defined NO_HIDDEN
+      && !defined NO_HIDDEN && defined USE_LDCONFIG
 #   define __hidden_proto_hiddenattr(attrs...) \
   __attribute__ ((visibility ("hidden"), ##attrs))
 #   define hidden_proto(name, attrs...) \


code:
This is needed to run Python on the Hurd, especially during the build of
python-boot0.

Adapted from https://salsa.debian.org/glibc-team/glibc/-/blob/glibc-2.31/debian/patches/hurd-i386/unsubmitted-clock_t_centiseconds.diff

Use the realtime clock for the monotonic clock. This is of course not a proper
implementation (which is being done in Mach), but will permit to fix at least
the iceweasel stack.

vlc however doesn't build when _POSIX_CLOCK_SELECTION is enabled but
_POSIX_TIMERS is not, and they refuse to fix that (see #765578), so disable the
former.

From 0aa1dfd580cf9ad7b812c307b128decb782b825f Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Mon, 2 Mar 2020 18:59:04 +0100
Subject: [PATCH 2/2] Use realtime clock for the monotonic clock.

---
 sysdeps/mach/clock_gettime.c       | 2 +-
 sysdeps/mach/hurd/bits/posix_opt.h | 6 +++---
 sysdeps/posix/clock_getres.c       | 1 +
 sysdeps/pthread/timer_create.c     | 2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/sysdeps/mach/clock_gettime.c b/sysdeps/mach/clock_gettime.c
index ac3547df3c..af8681ba4e 100644
--- a/sysdeps/mach/clock_gettime.c
+++ b/sysdeps/mach/clock_gettime.c
@@ -25,7 +25,7 @@
 int
 __clock_gettime (clockid_t clock_id, struct timespec *ts)
 {
-  if (clock_id != CLOCK_REALTIME)
+  if (clock_id != CLOCK_MONOTONIC && clock_id != CLOCK_REALTIME)
     {
       errno = EINVAL;
       return -1;
diff --git a/sysdeps/mach/hurd/bits/posix_opt.h b/sysdeps/mach/hurd/bits/posix_opt.h
index 0050151332..27b3a28ab7 100644
--- a/sysdeps/mach/hurd/bits/posix_opt.h
+++ b/sysdeps/mach/hurd/bits/posix_opt.h
@@ -163,10 +163,10 @@
 #define _POSIX_THREAD_PROCESS_SHARED	-1

 /* The monotonic clock might be available.  */
-#define _POSIX_MONOTONIC_CLOCK	0
+#define _POSIX_MONOTONIC_CLOCK	200809L

-/* The clock selection interfaces are available.  */
-#define _POSIX_CLOCK_SELECTION	200809L
+/* The clock selection interfaces are not really available yet.  */
+#define _POSIX_CLOCK_SELECTION	-1

 /* Advisory information interfaces could be available in future.  */
 #define _POSIX_ADVISORY_INFO	0
diff --git a/sysdeps/posix/clock_getres.c b/sysdeps/posix/clock_getres.c
index fcd79fd554..1dd02aa449 100644
--- a/sysdeps/posix/clock_getres.c
+++ b/sysdeps/posix/clock_getres.c
@@ -52,6 +52,7 @@ __clock_getres (clockid_t clock_id, struct timespec *res)
   switch (clock_id)
     {
     case CLOCK_REALTIME:
+    case CLOCK_MONOTONIC:
       retval = realtime_getres (res);
       break;

diff --git a/sysdeps/pthread/timer_create.c b/sysdeps/pthread/timer_create.c
index 9d8a9ea8ae..3430582c09 100644
--- a/sysdeps/pthread/timer_create.c
+++ b/sysdeps/pthread/timer_create.c
@@ -48,7 +48,7 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid)
       return -1;
     }

-  if (clock_id != CLOCK_REALTIME)
+  if (clock_id != CLOCK_REALTIME && clock_id != CLOCK_MONOTONIC)
     {
       __set_errno (EINVAL);
       return -1;
--
2.24.0


code:
This is needed to run Python on the Hurd, especially during the build of
python-boot0.

Adapted from https://salsa.debian.org/glibc-team/glibc/-/blob/glibc-2.31/debian/patches/hurd-i386/unsubmitted-clock_t_centiseconds.diff

    commit d57f2f9b4bd007846af2fb4217486ea572579010
    Author: Richard Braun <rbraun@sceen.net>
    Date:   Tue Aug 27 11:35:31 2013 +0200

        Express CPU time (clock_t of times(2)) in centiseconds

From 170c292b643fdc1eb56881e6592b07c0c019993e Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Mon, 2 Mar 2020 18:28:54 +0100
Subject: [PATCH 1/2] Express CPU time (clock_t) in centiseconds

---
 sysdeps/mach/hurd/clock.c     | 8 ++++----
 sysdeps/mach/hurd/getclktck.c | 5 ++---
 sysdeps/mach/hurd/setitimer.c | 2 +-
 sysdeps/mach/hurd/times.c     | 2 +-
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/sysdeps/mach/hurd/clock.c b/sysdeps/mach/hurd/clock.c
index 7cb42df786..4db49b579d 100644
--- a/sysdeps/mach/hurd/clock.c
+++ b/sysdeps/mach/hurd/clock.c
@@ -44,10 +44,10 @@ clock (void)
   if (err)
     return __hurd_fail (err);

-  total = bi.user_time.seconds * 1000000 + bi.user_time.microseconds;
-  total += tti.user_time.seconds * 1000000 + tti.user_time.microseconds;
-  total += bi.system_time.seconds * 1000000 + bi.system_time.microseconds;
-  total += tti.system_time.seconds * 1000000 + tti.system_time.microseconds;
+  total = bi.user_time.seconds * 100 + bi.user_time.microseconds / 10000;
+  total += tti.user_time.seconds * 100 + tti.user_time.microseconds / 10000;
+  total += bi.system_time.seconds * 100 + bi.system_time.microseconds / 10000;
+  total += tti.system_time.seconds * 100 + tti.system_time.microseconds / 10000;

   return total;
 }
diff --git a/sysdeps/mach/hurd/getclktck.c b/sysdeps/mach/hurd/getclktck.c
index 943e36e805..5a3cf0930b 100644
--- a/sysdeps/mach/hurd/getclktck.c
+++ b/sysdeps/mach/hurd/getclktck.c
@@ -18,12 +18,11 @@

 #include <time.h>

-/* Return frequency of `times'.
-   Since Mach reports CPU times in microseconds, we always use 1 million.  */
+/* Return frequency of `times'.  */
 int
 __getclktck (void)
 {
-  return 1000000;
+  return 100;
 }

 /* Before glibc 2.2, the Hurd actually did this differently, so we
diff --git a/sysdeps/mach/hurd/setitimer.c b/sysdeps/mach/hurd/setitimer.c
index b16f4ddd5d..8bf1464830 100644
--- a/sysdeps/mach/hurd/setitimer.c
+++ b/sysdeps/mach/hurd/setitimer.c
@@ -43,7 +43,7 @@ quantize_timeval (struct timeval *tv)
   static time_t quantum = -1;

   if (quantum == -1)
-    quantum = 1000000 / __getclktck ();
+    quantum = 100 / __getclktck ();

   tv->tv_usec = ((tv->tv_usec + (quantum - 1)) / quantum) * quantum;
   if (tv->tv_usec >= 1000000)
diff --git a/sysdeps/mach/hurd/times.c b/sysdeps/mach/hurd/times.c
index 23ed992783..cbf6039b19 100644
--- a/sysdeps/mach/hurd/times.c
+++ b/sysdeps/mach/hurd/times.c
@@ -29,7 +29,7 @@
 static inline clock_t
 clock_from_time_value (const time_value_t *t)
 {
-  return t->seconds * 1000000 + t->microseconds;
+  return t->seconds * 100 + t->microseconds / 10000;
 }

 /* Store the CPU time used by this process and all its
--
2.24.0


code:
From d6d2caef3e44d0713bb6625f697a1ec615abae70 Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
Date: Sun, 5 Apr 2020 16:29:54 +0200
Subject: [PATCH 4/4] misc: Choose a longer arbitrary line length.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This allows running specifying a `getty' in the GNU Guix store.

* misc/getttyent.c (MAXLINELENGTH): Use 512 (instead of 100) as
another "great" arbitrary limit.

Co-Authored-By: Ludovic Courtès <ludo@gnu.org>
---
 misc/getttyent.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/misc/getttyent.c b/misc/getttyent.c
index 92d92b026f..508d296291 100644
--- a/misc/getttyent.c
+++ b/misc/getttyent.c
@@ -66,7 +66,7 @@ __getttyent (void)
 	static struct ttyent tty;
 	int c;
 	char *p;
-#define	MAXLINELENGTH	100
+#define	MAXLINELENGTH	512
 	static char line[MAXLINELENGTH];

 	if (!tf && !__setttyent())
--
2.26.0


code:
Provide a 'mach_print' symbol in libc.

--- a/sysdeps/mach/hurd/i386/libc.abilist	2020-04-01 19:22:44.710088821 +0200
+++ b/sysdeps/mach/hurd/i386/libc.abilist	2020-04-01 19:22:52.062051161 +0200
@@ -338,6 +338,7 @@
 GLIBC_2.2.6 __mach_port_allocate F
 GLIBC_2.2.6 __mach_port_deallocate F
 GLIBC_2.2.6 __mach_port_insert_right F
+GLIBC_2.21 __mach_print F
 GLIBC_2.2.6 __mach_reply_port F
 GLIBC_2.2.6 __mach_task_self_ D 0x4
 GLIBC_2.2.6 __mach_thread_self F

--- a/mach/Versions
+++ b/mach/Versions
@@ -56,6 +56,7 @@
   }
   GLIBC_2.21 {
     __mach_host_self_;
+    mach_print;
   }

   HURD_CTHREADS_0.3 {


code:
This patch implements "magic" lookup for "pid/…", as used when looking up
/proc/self.

The patch comes from the 't/magic-pid' branch
at <https://git.savannah.gnu.org/cgit/hurd/glibc.git>.  It squashes
commit 392e52286a302ca6157fbd221295e64ab6b6d8ba (by Justus Winter)
and commit 392e52286a302ca6157fbd221295e64ab6b6d8ba (a subsequent fix by
Samuel Thibault).

From: Justus Winter <4winter@informatik.uni-hamburg.de>
Subject: [PATCH] hurd: Handle `pid' magical lookup retry

        * hurd/lookup-retry.c: Handle `pid' magical lookup
        retry.

diff --git a/hurd/lookup-retry.c b/hurd/lookup-retry.c
index aee2ba8f93..6ed8de1653 100644
--- a/hurd/lookup-retry.c
+++ b/hurd/lookup-retry.c
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <_itoa.h>
 #include <eloop-threshold.h>
+#include <unistd.h>

 /* Translate the error from dir_lookup into the error the user sees.  */
 static inline error_t
@@ -59,6 +60,7 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
   error_t err;
   char *file_name;
   int nloops;
+  file_t lastdir = MACH_PORT_NULL;

   error_t lookup_op (file_t startdir)
     {
@@ -107,14 +109,15 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 	{
 	case FS_RETRY_REAUTH:
 	  if (err = reauthenticate (*result))
-	    return err;
+	    goto out;
 	  /* Fall through.  */

 	case FS_RETRY_NORMAL:
 	  if (nloops++ >= __eloop_threshold ())
 	    {
 	      __mach_port_deallocate (__mach_task_self (), *result);
-	      return ELOOP;
+	      err = ELOOP;
+	      goto out;
 	    }

 	  /* An empty RETRYNAME indicates we have the final port.  */
@@ -174,7 +177,7 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)

 	      if (err)
 		__mach_port_deallocate (__mach_task_self (), *result);
-	      return err;
+	      goto out;
 	    }

 	  startdir = *result;
@@ -189,7 +192,10 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 	      if (*result != MACH_PORT_NULL)
 		__mach_port_deallocate (__mach_task_self (), *result);
 	      if (nloops++ >= __eloop_threshold ())
-		return ELOOP;
+		{
+		  err = ELOOP;
+		  goto out;
+		}
 	      file_name = &retryname[1];
 	      break;

@@ -208,7 +214,8 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 		      (*end != '/' && *end != '\0'))
 		    {
 		      errno = save;
-		      return ENOENT;
+		      err = ENOENT;
+		      goto out;
 		    }
 		  if (! get_dtable_port)
 		    err = EGRATUITOUS;
@@ -226,9 +233,12 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 		    }
 		  errno = save;
 		  if (err)
-		    return err;
+		    goto out;
 		  if (*end == '\0')
-		    return 0;
+		    {
+		      err = 0;
+		      goto out;
+		    }
 		  else
 		    {
 		      /* Do a normal retry on the remaining components.  */
@@ -255,9 +265,12 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 		  if (err = __host_info (__mach_host_self (), HOST_BASIC_INFO,
 					 (integer_t *) &hostinfo,
 					 &hostinfocnt))
-		    return err;
+		    goto out;
 		  if (hostinfocnt != HOST_BASIC_INFO_COUNT)
-		    return EGRATUITOUS;
+		    {
+		      err = EGRATUITOUS;
+		      goto out;
+		    }
 		  p = _itoa (hostinfo.cpu_subtype, &retryname[8], 10, 0);
 		  *--p = '/';
 		  p = _itoa (hostinfo.cpu_type, &retryname[8], 10, 0);
@@ -293,10 +306,11 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 		      }

 		  case '\0':
-		    return opentty (result);
+		    err = opentty (result);
+		    goto out;
 		  case '/':
 		    if (err = opentty (&startdir))
-		      return err;
+		      goto out;
 		    strcpy (retryname, &retryname[4]);
 		    break;
 		  default:
@@ -306,14 +320,48 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 		goto bad_magic;
 	      break;

+	    case 'p':
+	      if (retryname[1] == 'i' && retryname[2] == 'd' &&
+		  (retryname[3] == '/' || retryname[3] == 0))
+		{
+		  char *p, buf[1024];  /* XXX */
+		  size_t len;
+		  p = _itoa (__getpid (), &buf[sizeof buf], 10, 0);
+		  len = &buf[sizeof buf] - p;
+		  memcpy (buf, p, len);
+		  strcpy (buf + len, &retryname[3]);
+		  strcpy (retryname, buf);
+
+		  /* Do a normal retry on the remaining components.  */
+		  __mach_port_mod_refs (__mach_task_self (), lastdir,
+					MACH_PORT_RIGHT_SEND, 1);
+		  startdir = lastdir;
+		  file_name = retryname;
+		}
+	      else
+		goto bad_magic;
+	      break;
+
 	    default:
 	    bad_magic:
-	      return EGRATUITOUS;
+	      err = EGRATUITOUS;
+	      goto out;
 	    }
 	  break;

 	default:
-	  return EGRATUITOUS;
+	  err = EGRATUITOUS;
+	  goto out;
+	}
+
+      if (MACH_PORT_VALID (*result) && *result != lastdir)
+	{
+	  if (MACH_PORT_VALID (lastdir))
+	    __mach_port_deallocate (__mach_task_self (), lastdir);
+
+	  lastdir = *result;
+	  __mach_port_mod_refs (__mach_task_self (), lastdir,
+				MACH_PORT_RIGHT_SEND, 1);
 	}

       if (startdir != MACH_PORT_NULL)
@@ -326,6 +374,10 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 	err = (*use_init_port) (dirport, &lookup_op);
     } while (! err);

+out:
+  if (MACH_PORT_VALID (lastdir))
+    __mach_port_deallocate (__mach_task_self (), lastdir);
+
   return err;
 }
 weak_alias (__hurd_file_name_lookup_retry, hurd_file_name_lookup_retry)


code:
This patch is needed to build e2fsprogs, util-linux.

Taken from https://salsa.debian.org/glibc-team/glibc/-/blob/glibc-2.31/debian/patches/hurd-i386/tg-hurdsig-SA_SIGINFO.diff

From: Jeremie Koenig <jk@jk.fr.eu.org>
Subject: [PATCH] implement SA_SIGINFO signal handlers.

    52baaca Hurd signals: Copy bits/sigaction.h
    4232c66 Hurd signals: SA_SIGINFO support
    1831cfe Hurd signals: Use POSIX sigcodes

---
 hurd/hurd/signal.h                       |    5 +
 hurd/hurdfault.c                         |    2
 hurd/hurdinit.c                          |    2
 hurd/hurdsig.c                           |    6 -
 sysdeps/mach/hurd/bits/sigaction.h       |   86 +++++++++++++++++++++
 sysdeps/mach/hurd/i386/bits/sigcontext.h |    4
 sysdeps/mach/hurd/i386/exc2signal.c      |  123 +++++++++++++++++++-----------
 sysdeps/mach/hurd/i386/trampoline.c      |  125 ++++++++++++++++++++++++++++---
 sysdeps/mach/hurd/kill.c                 |    2
 sysdeps/mach/hurd/setitimer.c            |    2
 10 files changed, 293 insertions(+), 64 deletions(-)

Index: glibc-2.31/hurd/hurd/signal.h
===================================================================
--- glibc-2.31.orig/hurd/hurd/signal.h
+++ glibc-2.31/hurd/hurd/signal.h
@@ -290,6 +290,11 @@ extern int _hurd_raise_signal (struct hu
 extern void _hurd_exception2signal (struct hurd_signal_detail *detail,
 				    int *signo);

+/* Translate a Mach exception into a signal with a legacy sigcode.  */
+
+extern void _hurd_exception2signal_legacy (struct hurd_signal_detail *detail,
+					   int *signo);
+

 /* Make the thread described by SS take the signal described by SIGNO and
    DETAIL.  If the process is traced, this will in fact stop with a SIGNO
Index: glibc-2.31/hurd/hurdfault.c
===================================================================
--- glibc-2.31.orig/hurd/hurdfault.c
+++ glibc-2.31/hurd/hurdfault.c
@@ -70,7 +70,7 @@ _hurdsig_fault_catch_exception_raise (ma
      codes into a signal number and subcode.  */
   _hurd_exception2signal (&d, &signo);

-  return HURD_PREEMPT_SIGNAL_P (&_hurdsig_fault_preemptor, signo, d.code)
+  return HURD_PREEMPT_SIGNAL_P (&_hurdsig_fault_preemptor, signo, d.exc_subcode)
     ? 0 : EGREGIOUS;
 }

Index: glibc-2.31/hurd/hurdinit.c
===================================================================
--- glibc-2.31.orig/hurd/hurdinit.c
+++ glibc-2.31/hurd/hurdinit.c
@@ -177,7 +177,7 @@ _hurd_new_proc_init (char **argv,
     /* This process is "traced", meaning it should stop on signals or exec.
        We are all set up now to handle signals.  Stop ourselves, to inform
        our parent (presumably a debugger) that the exec has completed.  */
-    __msg_sig_post (_hurd_msgport, SIGTRAP, 0, __mach_task_self ());
+    __msg_sig_post (_hurd_msgport, SIGTRAP, TRAP_TRACE, __mach_task_self ());
 }

 #include <shlib-compat.h>
Index: glibc-2.31/hurd/hurdsig.c
===================================================================
--- glibc-2.31.orig/hurd/hurdsig.c
+++ glibc-2.31/hurd/hurdsig.c
@@ -730,7 +730,7 @@ post_signal (struct hurd_sigstate *ss,
       {				/* PE cannot be null.  */
 	do
 	  {
-	    if (HURD_PREEMPT_SIGNAL_P (pe, signo, detail->code))
+	    if (HURD_PREEMPT_SIGNAL_P (pe, signo, detail->exc_subcode))
 	      {
 		if (pe->preemptor)
 		  {
@@ -1374,7 +1374,7 @@ _S_msg_sig_post (mach_port_t me,
   if (err = signal_allowed (signo, refport))
     return err;

-  d.code = sigcode;
+  d.code = d.exc_subcode = sigcode;
   d.exc = 0;

   /* Post the signal to a global receiver thread (or mark it pending in
@@ -1403,7 +1403,7 @@ _S_msg_sig_post_untraced (mach_port_t me
   if (err = signal_allowed (signo, refport))
     return err;

-  d.code = sigcode;
+  d.code = d.exc_subcode = sigcode;
   d.exc = 0;

   /* Post the signal to the designated signal-receiving thread.  This will
Index: glibc-2.31/sysdeps/mach/hurd/bits/sigaction.h
===================================================================
--- /dev/null
+++ glibc-2.31/sysdeps/mach/hurd/bits/sigaction.h
@@ -0,0 +1,86 @@
+/* Copyright (C) 1991-2015 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _BITS_SIGACTION_H
+#define _BITS_SIGACTION_H 1
+
+#ifndef _SIGNAL_H
+# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
+#endif
+
+/* These definitions match those used by the 4.4 BSD kernel.
+   If the operating system has a `sigaction' system call that correctly
+   implements the POSIX.1 behavior, there should be a system-dependent
+   version of this file that defines `struct sigaction' and the `SA_*'
+   constants appropriately.  */
+
+/* Structure describing the action to be taken when a signal arrives.  */
+struct sigaction
+  {
+    /* Signal handler.  */
+#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED
+    union
+      {
+	/* Used if SA_SIGINFO is not set.  */
+	__sighandler_t sa_handler;
+	/* Used if SA_SIGINFO is set.  */
+	void (*sa_sigaction) (int, siginfo_t *, void *);
+      }
+    __sigaction_handler;
+# define sa_handler	__sigaction_handler.sa_handler
+# define sa_sigaction	__sigaction_handler.sa_sigaction
+#else
+    __sighandler_t sa_handler;
+#endif
+
+    /* Additional set of signals to be blocked.  */
+    __sigset_t sa_mask;
+
+    /* Special flags.  */
+    int sa_flags;
+  };
+
+/* Bits in `sa_flags'.  */
+#if defined __USE_XOPEN_EXTENDED || defined __USE_MISC
+# define SA_ONSTACK	0x0001	/* Take signal on signal stack.  */
+#endif
+#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
+# define SA_RESTART	0x0002	/* Restart syscall on signal return.  */
+# define SA_NODEFER	0x0010	/* Don't automatically block the signal when
+				    its handler is being executed.  */
+# define SA_RESETHAND	0x0004	/* Reset to SIG_DFL on entry to handler.  */
+#endif
+#define	SA_NOCLDSTOP	0x0008	/* Don't send SIGCHLD when children stop.  */
+#define SA_SIGINFO	0x0040	/* Signal handler with SA_SIGINFO args */
+
+#ifdef __USE_MISC
+# define SA_INTERRUPT	0	/* Historical no-op ("not SA_RESTART").  */
+
+/* Some aliases for the SA_ constants.  */
+# define SA_NOMASK    SA_NODEFER
+# define SA_ONESHOT   SA_RESETHAND
+# define SA_STACK     SA_ONSTACK
+#endif
+
+
+/* Values for the HOW argument to `sigprocmask'.  */
+#define	SIG_BLOCK	1	/* Block signals.  */
+#define	SIG_UNBLOCK	2	/* Unblock signals.  */
+#define	SIG_SETMASK	3	/* Set the set of blocked signals.  */
+
+#endif
Index: glibc-2.31/sysdeps/mach/hurd/i386/bits/sigcontext.h
===================================================================
--- glibc-2.31.orig/sysdeps/mach/hurd/i386/bits/sigcontext.h
+++ glibc-2.31/sysdeps/mach/hurd/i386/bits/sigcontext.h
@@ -97,6 +97,10 @@ struct sigcontext
 #define sc_ps	sc_efl

+/* The deprecated sigcode values below are passed as an extra, non-portable
+   argument to regular signal handlers.  You should use SA_SIGINFO handlers
+   instead, which use the standard POSIX signal codes.  */
+
 /* Codes for SIGFPE.  */
 #define FPE_INTOVF_TRAP		0x1 /* integer overflow */
 #define FPE_INTDIV_FAULT	0x2 /* integer divide by zero */
Index: glibc-2.31/sysdeps/mach/hurd/i386/exc2signal.c
===================================================================
--- glibc-2.31.orig/sysdeps/mach/hurd/i386/exc2signal.c
+++ glibc-2.31/sysdeps/mach/hurd/i386/exc2signal.c
@@ -23,8 +23,8 @@
 /* Translate the Mach exception codes, as received in an `exception_raise' RPC,
    into a signal number and signal subcode.  */

-void
-_hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
+static void
+exception2signal (struct hurd_signal_detail *detail, int *signo, int posix)
 {
   detail->error = 0;

@@ -36,44 +36,62 @@ _hurd_exception2signal (struct hurd_sign
       break;

     case EXC_BAD_ACCESS:
-      if (detail->exc_code == KERN_INVALID_ADDRESS
-	  || detail->exc_code == KERN_PROTECTION_FAILURE
-	  || detail->exc_code == KERN_WRITE_PROTECTION_FAILURE)
-	*signo = SIGSEGV;
-      else
-	*signo = SIGBUS;
-      detail->code = detail->exc_subcode;
+      switch (detail->exc_code)
+        {
+	case KERN_INVALID_ADDRESS:
+	case KERN_MEMORY_FAILURE:
+	  *signo = SIGSEGV;
+	  detail->code = posix ? SEGV_MAPERR : detail->exc_subcode;
+	  break;
+
+	case KERN_PROTECTION_FAILURE:
+	case KERN_WRITE_PROTECTION_FAILURE:
+	  *signo = SIGSEGV;
+	  detail->code = posix ? SEGV_ACCERR : detail->exc_subcode;
+	  break;
+
+	default:
+	  *signo = SIGBUS;
+	  detail->code = posix ? BUS_ADRERR : detail->exc_subcode;
+	  break;
+	}
       detail->error = detail->exc_code;
       break;

     case EXC_BAD_INSTRUCTION:
       *signo = SIGILL;
-      if (detail->exc_code == EXC_I386_INVOP)
-	detail->code = ILL_INVOPR_FAULT;
-      else if (detail->exc_code == EXC_I386_STKFLT)
-	detail->code = ILL_STACK_FAULT;
-      else
-	detail->code = 0;
+      switch (detail->exc_code)
+        {
+	case EXC_I386_INVOP:
+	  detail->code = posix ? ILL_ILLOPC : ILL_INVOPR_FAULT;
+	  break;
+
+	case EXC_I386_STKFLT:
+	  detail->code = posix ? ILL_BADSTK : ILL_STACK_FAULT;
+	  break;
+
+	default:
+	  detail->code = 0;
+	  break;
+	}
       break;

     case EXC_ARITHMETIC:
+      *signo = SIGFPE;
       switch (detail->exc_code)
 	{
 	case EXC_I386_DIV:	/* integer divide by zero */
-	  *signo = SIGFPE;
-	  detail->code = FPE_INTDIV_FAULT;
+	  detail->code = posix ? FPE_INTDIV : FPE_INTDIV_FAULT;
 	  break;

 	case EXC_I386_INTO:	/* integer overflow */
-	  *signo = SIGFPE;
-	  detail->code = FPE_INTOVF_TRAP;
+	  detail->code = posix ? FPE_INTOVF : FPE_INTOVF_TRAP;
 	  break;

 	  /* These aren't anywhere documented or used in Mach 3.0.  */
 	case EXC_I386_NOEXT:
 	case EXC_I386_EXTOVR:
 	default:
-	  *signo = SIGFPE;
 	  detail->code = 0;
 	  break;

@@ -82,51 +100,43 @@ _hurd_exception2signal (struct hurd_sign
 	     Give an error code corresponding to the first bit set.  */
 	  if (detail->exc_subcode & FPS_IE)
 	    {
-	      *signo = SIGILL;
-	      detail->code = ILL_FPEOPR_FAULT;
+	      /* NB: We used to send SIGILL here but we can't distinguish
+		 POSIX vs. legacy with respect to what signal we send.  */
+	      detail->code = posix ? FPE_FLTINV : 0 /*ILL_FPEOPR_FAULT*/;
 	    }
 	  else if (detail->exc_subcode & FPS_DE)
 	    {
-	      *signo = SIGFPE;
-	      detail->code = FPE_FLTDNR_FAULT;
+	      detail->code = posix ? FPE_FLTUND : FPE_FLTDNR_FAULT;
 	    }
 	  else if (detail->exc_subcode & FPS_ZE)
 	    {
-	      *signo = SIGFPE;
-	      detail->code = FPE_FLTDIV_FAULT;
+	      detail->code = posix ? FPE_FLTDIV : FPE_FLTDIV_FAULT;
 	    }
 	  else if (detail->exc_subcode & FPS_OE)
 	    {
-	      *signo = SIGFPE;
-	      detail->code = FPE_FLTOVF_FAULT;
+	      detail->code = posix ? FPE_FLTOVF : FPE_FLTOVF_FAULT;
 	    }
 	  else if (detail->exc_subcode & FPS_UE)
 	    {
-	      *signo = SIGFPE;
-	      detail->code = FPE_FLTUND_FAULT;
+	      detail->code = posix ? FPE_FLTUND : FPE_FLTUND_FAULT;
 	    }
 	  else if (detail->exc_subcode & FPS_PE)
 	    {
-	      *signo = SIGFPE;
-	      detail->code = FPE_FLTINX_FAULT;
+	      detail->code = posix ? FPE_FLTRES : FPE_FLTINX_FAULT;
 	    }
 	  else
 	    {
-	      *signo = SIGFPE;
 	      detail->code = 0;
 	    }
 	  break;

 	  /* These two can only be arithmetic exceptions if we
-	     are in V86 mode, which sounds like emulation to me.
-	     (See Mach 3.0 i386/trap.c.)  */
+	     are in V86 mode.  (See Mach 3.0 i386/trap.c.)  */
 	case EXC_I386_EMERR:
-	  *signo = SIGFPE;
-	  detail->code = FPE_EMERR_FAULT;
+	  detail->code = posix ? 0 : FPE_EMERR_FAULT;
 	  break;
 	case EXC_I386_BOUND:
-	  *signo = SIGFPE;
-	  detail->code = FPE_EMBND_FAULT;
+	  detail->code = posix ? FPE_FLTSUB : FPE_EMBND_FAULT;
 	  break;
 	}
       break;
@@ -143,7 +153,7 @@ _hurd_exception2signal (struct hurd_sign
       if (detail->exc_code == EXC_I386_BOUND)
 	{
 	  *signo = SIGFPE;
-	  detail->code = FPE_SUBRNG_FAULT;
+	  detail->code = posix ? FPE_FLTSUB : FPE_SUBRNG_FAULT;
 	}
       else
 	{
@@ -154,13 +164,34 @@ _hurd_exception2signal (struct hurd_sign

     case EXC_BREAKPOINT:
       *signo = SIGTRAP;
-      if (detail->exc_code == EXC_I386_SGL)
-	detail->code = DBG_SINGLE_TRAP;
-      else if (detail->exc_code == EXC_I386_BPT)
-	detail->code = DBG_BRKPNT_FAULT;
-      else
-	detail->code = 0;
+      switch (detail->exc_code)
+        {
+	case EXC_I386_SGL:
+	  detail->code = posix ? TRAP_BRKPT : DBG_SINGLE_TRAP;
+	  break;
+
+	case EXC_I386_BPT:
+	  detail->code = posix ? TRAP_BRKPT : DBG_BRKPNT_FAULT;
+	  break;
+
+	default:
+	  detail->code = 0;
+	  break;
+	}
       break;
     }
 }
 libc_hidden_def (_hurd_exception2signal)
+
+void
+_hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
+{
+  exception2signal (detail, signo, 1);
+}
+
+void
+_hurd_exception2signal_legacy (struct hurd_signal_detail *detail, int *signo)
+{
+  exception2signal (detail, signo, 0);
+}
+
Index: glibc-2.31/sysdeps/mach/hurd/i386/trampoline.c
===================================================================
--- glibc-2.31.orig/sysdeps/mach/hurd/i386/trampoline.c
+++ glibc-2.31/sysdeps/mach/hurd/i386/trampoline.c
@@ -19,13 +19,66 @@
 #include <hurd/signal.h>
 #include <hurd/userlink.h>
 #include <thread_state.h>
+#include <mach/exception.h>
 #include <mach/machine/eflags.h>
 #include <assert.h>
 #include <errno.h>
 #include "hurdfault.h"
 #include <intr-msg.h>
+#include <sys/ucontext.h>

+/* Fill in a siginfo_t structure for SA_SIGINFO-enabled handlers.  */
+static void fill_siginfo (siginfo_t *si, int signo,
+			  const struct hurd_signal_detail *detail,
+			  const struct machine_thread_all_state *state)
+{
+  si->si_signo = signo;
+  si->si_errno = detail->error;
+  si->si_code = detail->code;
+
+  /* XXX We would need a protocol change for sig_post to include
+   * this information.  */
+  si->si_pid = -1;
+  si->si_uid = -1;
+
+  /* Address of the faulting instruction or memory access.  */
+  if (detail->exc == EXC_BAD_ACCESS)
+    si->si_addr = (void *) detail->exc_subcode;
+  else
+    si->si_addr = (void *) state->basic.eip;
+
+  /* XXX On SIGCHLD, this should be the exit status of the child
+   * process.  We would need a protocol change for the proc server
+   * to send this information along with the signal.  */
+  si->si_status = 0;
+
+  si->si_band = 0;              /* SIGPOLL is not supported yet.  */
+  si->si_value.sival_int = 0;   /* sigqueue() is not supported yet.  */
+}
+
+/* Fill in a ucontext_t structure SA_SIGINFO-enabled handlers.  */
+static void fill_ucontext (ucontext_t *uc, const struct sigcontext *sc)
+{
+  uc->uc_flags = 0;
+  uc->uc_link = NULL;
+  uc->uc_sigmask = sc->sc_mask;
+  uc->uc_stack.ss_sp = (__ptr_t) sc->sc_esp;
+  uc->uc_stack.ss_size = 0;
+  uc->uc_stack.ss_flags = 0;
+
+  /* Registers.  */
+  memcpy (&uc->uc_mcontext.gregs[REG_GS], &sc->sc_gs,
+	  (REG_TRAPNO - REG_GS) * sizeof (int));
+  uc->uc_mcontext.gregs[REG_TRAPNO] = 0;
+  uc->uc_mcontext.gregs[REG_ERR] = 0;
+  memcpy (&uc->uc_mcontext.gregs[REG_EIP], &sc->sc_eip,
+	  (NGREG - REG_EIP) * sizeof (int));
+
+  /* XXX FPU state.  */
+  memset (&uc->uc_mcontext.fpregs, 0, sizeof (fpregset_t));
+}
+
 struct sigcontext *
 _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
 			int signo, struct hurd_signal_detail *detail,
@@ -43,15 +96,38 @@ _hurd_setup_sighandler (struct hurd_sigs
   struct
     {
       int signo;
-      long int sigcode;
-      struct sigcontext *scp;	/* Points to ctx, below.  */
+      union
+	{
+	  /* Extra arguments for traditional signal handlers */
+	  struct
+	    {
+	      long int sigcode;
+	      struct sigcontext *scp;       /* Points to ctx, below.  */
+	    } legacy;
+
+	  /* Extra arguments for SA_SIGINFO handlers */
+	  struct
+	    {
+	      siginfo_t *siginfop;          /* Points to siginfo, below.  */
+	      ucontext_t *uctxp;            /* Points to uctx, below.  */
+	    } posix;
+	};
       void *sigreturn_addr;
       void *sigreturn_returns_here;
       struct sigcontext *return_scp; /* Same; arg to sigreturn.  */
+
+      /* NB: sigreturn assumes link is next to ctx.  */
       struct sigcontext ctx;
       struct hurd_userlink link;
+      ucontext_t ucontext;
+      siginfo_t siginfo;
     } *stackframe;

+  /* sigaction for preemptors */
+  static const struct sigaction legacy_sigaction = {
+    .sa_flags = SA_RESTART
+  };
+
   if (ss->context)
     {
       /* We have a previous sigcontext that sigreturn was about
@@ -94,9 +170,13 @@ _hurd_setup_sighandler (struct hurd_sigs
      the SP on sigreturn.  */
     state->basic.uesp = state->basic.ecx;

-  /* XXX what if handler != action->handler (for instance, if a signal
-   * preemptor took over) ? */
   action = & _hurd_sigstate_actions (ss) [signo];
+  if ( (action->sa_flags & SA_SIGINFO)
+        && handler != (__sighandler_t) action->sa_sigaction
+   || !(action->sa_flags & SA_SIGINFO)
+        && handler != action->sa_handler)
+    /* A signal preemptor took over, use legacy semantic.  */
+    action = &legacy_sigaction;

   if ((action->sa_flags & SA_ONSTACK)
       && !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK)))
@@ -140,15 +220,9 @@ _hurd_setup_sighandler (struct hurd_sigs
 	  = &stackframe->link.thread.next;
       ss->active_resources = &stackframe->link;

-      /* Set up the arguments for the signal handler.  */
-      stackframe->signo = signo;
-      stackframe->sigcode = detail->code;
-      stackframe->scp = stackframe->return_scp = scp = &stackframe->ctx;
-      stackframe->sigreturn_addr = &__sigreturn;
-      stackframe->sigreturn_returns_here = firewall; /* Crash on return.  */
-
       /* Set up the sigcontext from the current state of the thread.  */

+      scp = &stackframe->ctx;
       scp->sc_onstack = ss->sigaltstack.ss_flags & SS_ONSTACK ? 1 : 0;

       /* struct sigcontext is laid out so that starting at sc_gs mimics a
@@ -162,6 +236,35 @@ _hurd_setup_sighandler (struct hurd_sigs
 			      &state->fpu, &scp->sc_i386_float_state,
 			      sizeof (state->fpu));

+      /* Set up the arguments for the signal handler.  */
+      stackframe->signo = signo;
+      if (action->sa_flags & SA_SIGINFO)
+	{
+	  stackframe->posix.siginfop = &stackframe->siginfo;
+	  stackframe->posix.uctxp = &stackframe->ucontext;
+	  fill_siginfo (&stackframe->siginfo, signo, detail, state);
+	  fill_ucontext (&stackframe->ucontext, scp);
+	}
+      else
+	{
+	  if (detail->exc)
+	    {
+	      int nsigno;
+	      _hurd_exception2signal_legacy (detail, &nsigno);
+	      assert (nsigno == signo);
+	    }
+	  else
+	    detail->code = 0;
+
+	  stackframe->legacy.sigcode = detail->code;
+	  stackframe->legacy.scp = &stackframe->ctx;
+	}
+
+      /* Set up the bottom of the stack.  */
+      stackframe->sigreturn_addr = &__sigreturn;
+      stackframe->sigreturn_returns_here = firewall; /* Crash on return.  */
+      stackframe->return_scp = &stackframe->ctx;
+
       _hurdsig_end_catch_fault ();

       if (! ok)
Index: glibc-2.31/sysdeps/mach/hurd/kill.c
===================================================================
--- glibc-2.31.orig/sysdeps/mach/hurd/kill.c
+++ glibc-2.31/sysdeps/mach/hurd/kill.c
@@ -64,7 +64,7 @@ __kill (pid_t pid, int sig)
 	    {
 	      if (msgport != MACH_PORT_NULL)
 		/* Send a signal message to his message port.  */
-		return __msg_sig_post (msgport, sig, 0, refport);
+		return __msg_sig_post (msgport, sig, SI_USER, refport);

 	      /* The process has no message port.  Perhaps try direct
 		 frobnication of the task.  */
Index: glibc-2.31/sysdeps/mach/hurd/setitimer.c
===================================================================
--- glibc-2.31.orig/sysdeps/mach/hurd/setitimer.c
+++ glibc-2.31/sysdeps/mach/hurd/setitimer.c
@@ -105,7 +105,7 @@ timer_thread (void)
 	  __msg_sig_post_request (_hurd_msgport,
 				  _hurd_itimer_port,
 				  MACH_MSG_TYPE_MAKE_SEND_ONCE,
-				  SIGALRM, 0, __mach_task_self ());
+				  SIGALRM, SI_TIMER, __mach_task_self ());
 	  break;

 	case MACH_RCV_INTERRUPTED:
Index: glibc-2.31/sysdeps/mach/hurd/i386/sigcontextinfo.h
===================================================================
--- glibc-2.31.orig/sysdeps/mach/hurd/i386/sigcontextinfo.h
+++ glibc-2.31/sysdeps/mach/hurd/i386/sigcontextinfo.h
@@ -18,11 +18,10 @@
 #ifndef _SIGCONTEXTINFO_H
 #define _SIGCONTEXTINFO_H

-#define SIGCONTEXT struct sigcontext
 static inline uintptr_t
-sigcontext_get_pc (struct sigcontext ctx)
+sigcontext_get_pc (struct ucontext_t *ctx)
 {
-  return ctx.sc_eip;
+  return ctx->uc_mcontext.gregs[REG_EIP];
 }

 #endif


code:
This patch allows us to use glibc's build system to build locales
in a package separate from glibc.

  1. Use 'localedef' from $PATH since we are not rebuilding it.
  2. Use '--no-archive' to avoid building the big locale archive, and
     because the already-built 'localedef' would want to write it
     to '/run/current-system/locale', which is not possible.
  3. Pass $(inst_complocaledir)/$$locale to install files in the right
     place, and because otherwise, 'localedef' fails with:
     "cannot write output files to `(null)'".

--- glibc-2.27/localedata/Makefile
+++ glibc-2.27/localedata/Makefile
@@ -199,7 +199,7 @@ INSTALL-SUPPORTED-LOCALES=$(addprefix install-, $(SUPPORTED-LOCALES))

 # Sometimes the whole collection of locale files should be installed.
 LOCALEDEF=I18NPATH=. GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
-$(rtld-prefix) $(common-objpfx)locale/localedef
+  localedef --no-archive
 install-locales: $(INSTALL-SUPPORTED-LOCALES)

 install-locales-dir:
@@ -224,7 +224,7 @@ $(INSTALL-SUPPORTED-LOCALES): install-locales-dir
 	input=`echo $$locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'`; \
 	$(LOCALEDEF) $$flags --alias-file=../intl/locale.alias \
 		     -i locales/$$input -f charmaps/$$charset \
-		     $(addprefix --prefix=,$(install_root)) $$locale \
+		     $(addprefix --prefix=,$(install_root)) $(inst_complocaledir)/$$locale \
 	&& echo ' done'; \

 tst-setlocale-ENV = LC_ALL=ja_JP.EUC-JP


code:
This patch allows us to use glibc's build system to build locales
in a package separate from glibc.

  1. Use 'localedef' from $PATH since we are not rebuilding it.
  2. Use '--no-archive' to avoid building the big locale archive, and
     because the already-built 'localedef' would want to write it
     to '/run/current-system/locale', which is not possible.
  3. Pass $(inst_complocaledir)/$$locale to install files in the right
     place, and because otherwise, 'localedef' fails with:
     "cannot write output files to `(null)'".

diff -ru glibc-2.29-old/localedata/Makefile glibc-2.29-new/localedata/Makefile
--- glibc-2.29-old/localedata/Makefile	2019-01-31 11:45:36.000000000 -0500
+++ glibc-2.29-new/localedata/Makefile	2019-07-03 22:48:35.662015071 -0400
@@ -385,7 +385,7 @@

 # Sometimes the whole collection of locale files should be installed.
 LOCALEDEF=I18NPATH=. GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
-$(rtld-prefix) $(common-objpfx)locale/localedef
+  localedef --no-archive
 install-locales: install-locale-archive

 # Create and install the locale-archive file.
@@ -414,7 +414,7 @@
 	input=`echo $$locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'`; \
 	$(LOCALEDEF) $$flags --alias-file=../intl/locale.alias \
 		     -i locales/$$input -f charmaps/$$charset \
-		     $(addprefix --prefix=,$(install_root)) $$locale \
+		     $(addprefix --prefix=,$(install_root)) $(inst_complocaledir)/$$locale \
 	&& echo ' done';
 endef


code:
This patch reinstates fallback code when the 'prlimit64' system call is
missing by reverting the relevant part of this upstream commit:

  commit 695d7d138eda449678a1650a8b8b58181033353f
  Author: Joseph Myers <joseph@codesourcery.com>
  Date:   Tue May 9 14:05:09 2017 +0000

      Assume prlimit64 is available.

The fallback code is useful on systems that lack 'prlimit64', such as the
2.6.32-on-steroid kernel found on RHEL 6:

  <https://lists.gnu.org/archive/html/guix-devel/2018-03/msg00349.html>

diff --git a/sysdeps/unix/sysv/linux/getrlimit64.c b/sysdeps/unix/sysv/linux/getrlimit64.c
index 37c173286f..56af3c0646 100644
--- b/sysdeps/unix/sysv/linux/getrlimit64.c
+++ a/sysdeps/unix/sysv/linux/getrlimit64.c
@@ -35,7 +35,40 @@
 int
 __getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
 {
-  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, NULL, rlimits);
+#ifdef __NR_prlimit64
+  int res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, NULL, rlimits);
+  if (res == 0 || errno != ENOSYS)
+    return res;
+#endif
+
+/* The fallback code only makes sense if the platform supports either
+   __NR_ugetrlimit and/or __NR_getrlimit.  */
+#if defined (__NR_ugetrlimit) || defined (__NR_getrlimit)
+# ifndef __NR_ugetrlimit
+#  define __NR_ugetrlimit __NR_getrlimit
+# endif
+# if __RLIM_T_MATCHES_RLIM64_T
+#  define rlimits32 (*rlimits)
+# else
+  struct rlimit rlimits32;
+# endif
+
+  if (INLINE_SYSCALL_CALL (ugetrlimit, resource, &rlimits32) < 0)
+    return -1;
+
+# if !__RLIM_T_MATCHES_RLIM64_T
+  if (rlimits32.rlim_cur == RLIM_INFINITY)
+    rlimits->rlim_cur = RLIM64_INFINITY;
+  else
+    rlimits->rlim_cur = rlimits32.rlim_cur;
+  if (rlimits32.rlim_max == RLIM_INFINITY)
+    rlimits->rlim_max = RLIM64_INFINITY;
+  else
+    rlimits->rlim_max = rlimits32.rlim_max;
+# endif /* !__RLIM_T_MATCHES_RLIM64_T */
+#endif /* defined (__NR_ugetrlimit) || defined (__NR_getrlimit)  */
+
+  return 0;
 }
 libc_hidden_def (__getrlimit64)

diff --git a/sysdeps/unix/sysv/linux/setrlimit.c b/sysdeps/unix/sysv/linux/setrlimit.c
index 01812ac355..8773c78236 100644
--- b/sysdeps/unix/sysv/linux/setrlimit.c
+++ a/sysdeps/unix/sysv/linux/setrlimit.c
@@ -34,6 +34,7 @@
 int
 __setrlimit (enum __rlimit_resource resource, const struct rlimit *rlim)
 {
+# ifdef __NR_prlimit64
   struct rlimit64 rlim64;

   if (rlim->rlim_cur == RLIM_INFINITY)
@@ -45,7 +46,11 @@
   else
     rlim64.rlim_max = rlim->rlim_max;

-  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, &rlim64, NULL);
+  int res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, &rlim64, NULL);
+  if (res == 0 || errno != ENOSYS)
+    return res;
+# endif
+  return INLINE_SYSCALL_CALL (setrlimit, resource, rlim);
 }

 # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
diff --git a/sysdeps/unix/sysv/linux/setrlimit64.c b/sysdeps/unix/sysv/linux/setrlimit64.c
index 2dd129d99e..db1960fc18 100644
--- b/sysdeps/unix/sysv/linux/setrlimit64.c
+++ a/sysdeps/unix/sysv/linux/setrlimit64.c
@@ -36,7 +36,36 @@
 int
 __setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits)
 {
-  return INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlimits, NULL);
+  int res;
+
+#ifdef __NR_prlimit64
+  res = INLINE_SYSCALL_CALL (prlimit64, 0, resource, rlimits, NULL);
+  if (res == 0 || errno != ENOSYS)
+    return res;
+#endif
+
+/* The fallback code only makes sense if the platform supports
+   __NR_setrlimit.  */
+#ifdef __NR_setrlimit
+# if !__RLIM_T_MATCHES_RLIM64_T
+  struct rlimit rlimits32;
+
+  if (rlimits->rlim_cur >= RLIM_INFINITY)
+    rlimits32.rlim_cur = RLIM_INFINITY;
+  else
+    rlimits32.rlim_cur = rlimits->rlim_cur;
+  if (rlimits->rlim_max >= RLIM_INFINITY)
+    rlimits32.rlim_max = RLIM_INFINITY;
+  else
+    rlimits32.rlim_max = rlimits->rlim_max;
+# else
+#  define rlimits32 (*rlimits)
+# endif
+
+  res = INLINE_SYSCALL_CALL (setrlimit, resource, &rlimits32);
+#endif
+
+  return res;
 }
 weak_alias (__setrlimit64, setrlimit64)


code:
This patch is taken from debian's glibc package (generate-supported.mk).
It install the localedata/SUPPORTED file of the glibc. This file lists
all the supported locales of the glibc.

diff --git a/localedata/Makefile b/localedata/Makefile
--- a/localedata/Makefile
+++ b/localedata/Makefile
@@ -176,7 +176,8 @@
 else
 install-others := $(addprefix $(inst_i18ndir)/, \
 			      $(addsuffix .gz, $(charmaps)) \
-			      $(locales))
+			      $(locales)) \
+                   $(inst_i18ndir)/SUPPORTED
 endif

 tests: $(objdir)/iconvdata/gconv-modules
@@ -401,6 +402,14 @@

 include SUPPORTED

+$(inst_i18ndir)/SUPPORTED: SUPPORTED $(+force)
+	for locale in $(SUPPORTED-LOCALES); do \
+		[ $$locale = true ] && continue; \
+		echo $$locale | sed 's,/, ,' >> LOCALES; \
+	done
+	$(make-target-directory)
+	$(INSTALL_DATA) LOCALES $@
+
 INSTALL-SUPPORTED-LOCALE-ARCHIVE=$(addprefix install-archive-, $(SUPPORTED-LOCALES))
 INSTALL-SUPPORTED-LOCALE-FILES=$(addprefix install-files-, $(SUPPORTED-LOCALES))


code:
The format of locale data can be incompatible between libc versions, and
loading incompatible data can lead to 'setlocale' returning EINVAL at best
or triggering an assertion failure at worst.  See
https://lists.gnu.org/archive/html/guix-devel/2015-09/msg00717.html
for background information.

To address that, this patch changes libc to honor a new 'GUIX_LOCPATH'
variable, and to look for locale data in version-specific sub-directories of
that variable.  So, if GUIX_LOCPATH=/foo:/bar, locale data is searched for in
/foo/X.Y and /bar/X.Y, where X.Y is the libc version number.

That way, a single 'GUIX_LOCPATH' setting can work even if different libc
versions coexist on the system.

--- a/locale/newlocale.c
+++ b/locale/newlocale.c
@@ -30,6 +30,7 @@
 /* Lock for protecting global data.  */
 __libc_rwlock_define (extern , __libc_setlocale_lock attribute_hidden)

+extern error_t compute_locale_search_path (char **, size_t *);

 /* Use this when we come along an error.  */
 #define ERROR_RETURN							      \
@@ -48,7 +49,6 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
   __locale_t result_ptr;
   char *locale_path;
   size_t locale_path_len;
-  const char *locpath_var;
   int cnt;
   size_t names_len;

@@ -102,17 +102,8 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
   locale_path = NULL;
   locale_path_len = 0;

-  locpath_var = getenv ("LOCPATH");
-  if (locpath_var != NULL && locpath_var[0] != '\0')
-    {
-      if (__argz_create_sep (locpath_var, ':',
-			     &locale_path, &locale_path_len) != 0)
-	return NULL;
-
-      if (__argz_add_sep (&locale_path, &locale_path_len,
-			  _nl_default_locale_path, ':') != 0)
-	return NULL;
-    }
+  if (compute_locale_search_path (&locale_path, &locale_path_len) != 0)
+    return NULL;

   /* Get the names for the locales we are interested in.  We either
      allow a composite name or a single name.  */
diff --git a/locale/setlocale.c b/locale/setlocale.c
index ead030d..0c0e314 100644
--- a/locale/setlocale.c
+++ b/locale/setlocale.c
@@ -215,12 +215,65 @@ setdata (int category, struct __locale_data *data)
     }
 }

+/* Return in *LOCALE_PATH and *LOCALE_PATH_LEN the locale data search path as
+   a colon-separated list.  Return ENOMEN on error, zero otherwise.  */
+error_t
+compute_locale_search_path (char **locale_path, size_t *locale_path_len)
+{
+  char* guix_locpath_var = getenv ("GUIX_LOCPATH");
+  char *locpath_var = getenv ("LOCPATH");
+
+  if (guix_locpath_var != NULL && guix_locpath_var[0] != '\0')
+    {
+      /* Entries in 'GUIX_LOCPATH' take precedence over 'LOCPATH'.  These
+	 entries are systematically prefixed with "/X.Y" where "X.Y" is the
+	 libc version.  */
+      if (__argz_create_sep (guix_locpath_var, ':',
+			     locale_path, locale_path_len) != 0
+	  || __argz_suffix_entries (locale_path, locale_path_len,
+				    "/" VERSION) != 0)
+	goto bail_out;
+    }
+
+  if (locpath_var != NULL && locpath_var[0] != '\0')
+    {
+      char *reg_locale_path = NULL;
+      size_t reg_locale_path_len = 0;
+
+      if (__argz_create_sep (locpath_var, ':',
+			     &reg_locale_path, &reg_locale_path_len) != 0)
+	goto bail_out;
+
+      if (__argz_append (locale_path, locale_path_len,
+			 reg_locale_path, reg_locale_path_len) != 0)
+	goto bail_out;
+
+      free (reg_locale_path);
+    }
+
+  if (*locale_path != NULL)
+    {
+      /* Append the system default locale directory.  */
+      if (__argz_add_sep (locale_path, locale_path_len,
+			  _nl_default_locale_path, ':') != 0)
+	goto bail_out;
+    }
+
+  return 0;
+
+ bail_out:
+  free (*locale_path);
+  *locale_path = NULL;
+  *locale_path_len = 0;
+
+  return ENOMEM;
+}
+
 char *
 setlocale (int category, const char *locale)
 {
   char *locale_path;
   size_t locale_path_len;
-  const char *locpath_var;
   char *composite;

   /* Sanity check for CATEGORY argument.  */
@@ -251,17 +304,10 @@ setlocale (int category, const char *locale)
   locale_path = NULL;
   locale_path_len = 0;

-  locpath_var = getenv ("LOCPATH");
-  if (locpath_var != NULL && locpath_var[0] != '\0')
+  if (compute_locale_search_path (&locale_path, &locale_path_len) != 0)
     {
-      if (__argz_create_sep (locpath_var, ':',
-			     &locale_path, &locale_path_len) != 0
-	  || __argz_add_sep (&locale_path, &locale_path_len,
-			     _nl_default_locale_path, ':') != 0)
-	{
-	  __libc_rwlock_unlock (__libc_setlocale_lock);
-	  return NULL;
-	}
+      __libc_rwlock_unlock (__libc_setlocale_lock);
+      return NULL;
     }

   if (category == LC_ALL)
diff --git a/string/Makefile b/string/Makefile
index 8424a61..f925503 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -38,7 +38,7 @@ routines	:= strcat strchr strcmp strcoll strcpy strcspn		\
 		   swab strfry memfrob memmem rawmemchr strchrnul	\
 		   $(addprefix argz-,append count create ctsep next	\
 				     delete extract insert stringify	\
-				     addsep replace)			\
+				     addsep replace suffix)		\
 		   envz basename					\
 		   strcoll_l strxfrm_l string-inlines memrchr		\
 		   xpg-strerror strerror_l
diff --git a/string/argz-suffix.c b/string/argz-suffix.c
new file mode 100644
index 0000000..505b0f2
--- /dev/null
+++ b/string/argz-suffix.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 2015 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ludovic Courtès <ludo@gnu.org>.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <argz.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+error_t
+__argz_suffix_entries (char **argz, size_t *argz_len, const char *suffix)
+
+{
+  size_t suffix_len = strlen (suffix);
+  size_t count = __argz_count (*argz, *argz_len);
+  size_t new_argz_len = *argz_len + count * suffix_len;
+  char *new_argz = malloc (new_argz_len);
+
+  if (new_argz)
+    {
+      char *p = new_argz, *entry;
+
+      for (entry = *argz;
+	   entry != NULL;
+	   entry = argz_next (*argz, *argz_len, entry))
+	{
+	  p = stpcpy (p, entry);
+	  p = stpcpy (p, suffix);
+	  p++;
+	}
+
+      free (*argz);
+      *argz = new_argz;
+      *argz_len = new_argz_len;
+
+      return 0;
+    }
+  else
+    return ENOMEM;
+}
+weak_alias (__argz_suffix_entries, argz_suffix_entries)
diff --git a/string/argz.h b/string/argz.h
index bb62a31..d276a35 100644
--- a/string/argz.h
+++ b/string/argz.h
@@ -134,6 +134,16 @@ extern error_t argz_replace (char **__restrict __argz,
 			     const char *__restrict __str,
 			     const char *__restrict __with,
 			     unsigned int *__restrict __replace_count);
+
+/* Suffix each entry of ARGZ & ARGZ_LEN with SUFFIX.  Return 0 on success,
+   and ENOMEN if memory cannot be allocated.  */
+extern error_t __argz_suffix_entries (char **__restrict __argz,
+				      size_t *__restrict __argz_len,
+				      const char *__restrict __suffix);
+extern error_t argz_suffix_entries (char **__restrict __argz,
+				    size_t *__restrict __argz_len,
+				    const char *__restrict __suffix);
+

 /* Returns the next entry in ARGZ & ARGZ_LEN after ENTRY, or NULL if there
    are no more.  If entry is NULL, then the first entry is returned.  This


code:
# HG changeset patch
# User Torbjorn Granlund <tege@gmplib.org>
# Date 1396602422 -7200
# Node ID 676e2d0f0e4dd301a7066079d2c9326c25c34a40
# Parent  0194a75b56b21a9196626430af86c5bd9110c42d
Conditionalise ARM asm on !__thumb__.

diff -r 0194a75b56b2 -r 676e2d0f0e4d mpn/generic/div_qr_1n_pi1.c
--- a/mpn/generic/div_qr_1n_pi1.c	Thu Apr 03 23:58:51 2014 +0200
+++ b/mpn/generic/div_qr_1n_pi1.c	Fri Apr 04 11:07:02 2014 +0200
@@ -130,7 +130,7 @@
 	     "%2" ((UDItype)(a0)), "r" ((UDItype)(b0)) __CLOBBER_CC)
 #endif

-#if defined (__arm__) && W_TYPE_SIZE == 32
+#if defined (__arm__) && !defined (__thumb__) && W_TYPE_SIZE == 32
 #define add_mssaaaa(m, sh, sl, ah, al, bh, bl)				\
   __asm__ (  "adds	%2, %5, %6\n\t"					\
 	     "adcs	%1, %3, %4\n\t"					\


code:
Skip a test that randomly fails on ARMv7: <http://bugs.gnu.org/21620>.

--- a/tests/mpz/reuse.c
+++ b/tests/mpz/reuse.c
@@ -213,6 +213,7 @@ main (int argc, char **argv)
   mpz_t bs;
   unsigned long bsi, size_range;

+  exit (77);					  /* skip */
   tests_start ();
   TESTS_REPS (reps, argv, argc);


code:
This test seems to require a D-Bus connection not available in the build
environment.

diff -ur /tmp/guix-build-gnome-shell-3.34.2.drv-0/gnome-shell-3.34.2/src/st/meson.build b/src/st/meson.build
--- /tmp/guix-build-gnome-shell-3.34.2.drv-0/gnome-shell-3.34.2/src/st/meson.build	1969-12-31 19:00:00.000000000 -0500
+++ b/src/st/meson.build	2019-12-23 00:46:14.721198022 -0500
@@ -132,18 +132,6 @@
   sources: st_enums[1]
 )

-test_theme = executable('test-theme',
-  sources: 'test-theme.c',
-  c_args: st_cflags,
-  dependencies: [mutter_dep, gtk_dep],
-  build_rpath: mutter_typelibdir,
-  link_with: libst
-)
-
-test('CSS styling support', test_theme,
-  workdir: meson.current_source_dir()
-)
-
 libst_gir = gnome.generate_gir(libst,
   sources: st_gir_sources,
   nsversion: '1.0',


code:
Adjust GNOME-Shell so that it uses a Guix theme by default.

Patch by Ludovic Courtès <ludo@gnu.org>.

diff -ur a/data/gnome-shell-theme.gresource.xml b/data/gnome-shell-theme.gresource.xml
--- a/data/gnome-shell-theme.gresource.xml	2019-12-11 15:06:31.000000000 -0500
+++ b/data/gnome-shell-theme.gresource.xml	2019-12-21 00:31:55.895866241 -0500
@@ -19,6 +19,8 @@
     <file>no-events.svg</file>
     <file>no-notifications.svg</file>
     <file>noise-texture.png</file>
+    <file>guix-background.png</file>
+    <file>guix-logo.png</file>
     <file>pad-osd.css</file>
     <file alias="icons/pointer-double-click-symbolic.svg">pointer-double-click-symbolic.svg</file>
     <file alias="icons/pointer-drag-symbolic.svg">pointer-drag-symbolic.svg</file>
diff -ur a/data/theme/gnome-shell-sass/_common.scss b/data/theme/gnome-shell-sass/_common.scss
--- a/data/theme/gnome-shell-sass/_common.scss	2019-12-11 15:06:31.000000000 -0500
+++ b/data/theme/gnome-shell-sass/_common.scss	2019-12-21 00:33:49.495832135 -0500
@@ -1994,7 +1994,16 @@
   }
 }

-  .login-dialog-logo-bin { padding: 24px 0px; }
+  .login-dialog-logo-bin {
+      /* Make it a bit narrower than .login-dialog-user-list.  */
+      width: 12em;
+      height: 8em;
+      background: url(resource:///org/gnome/shell/theme/guix-logo.png);
+      background-color: transparent;
+      background-repeat: no-repeat;
+      background-size: contain;
+      background-position: center; }
+
   .login-dialog-banner { color: darken($osd_fg_color,10%); }
   .login-dialog-button-box { spacing: 5px; }
   .login-dialog-message-warning { color: $warning_color; }
@@ -2143,9 +2152,10 @@
 }

 #lockDialogGroup {
-  background: lighten(#2e3436, 8%) url(resource:///org/gnome/shell/theme/noise-texture.png);
-  background-repeat: repeat;
-}
+  background: lighten(#2e3436, 8%) url(resource:///org/gnome/shell/theme/guix-background.png);
+  background-repeat: no-repeat;
+  background-size: cover;
+  background-position: center; }

 #screenShieldNotifications {
   StButton#vhandle, StButton#hhandle {


code:
From: Emmanuele Bassi <ebassi@gnome.org>

See also: https://gitlab.gnome.org/GNOME/gnome-todo/commit/6cdabc4dd0c6c804a093b94c269461ce376fed4f
--- gnome-todo-3.28.1/plugins/eds/gtd-eds-autoptr.h.orig	2020-05-06 14:20:49.589902539 +0200
+++ gnome-todo-3.28.1/plugins/eds/gtd-eds-autoptr.h	2020-05-06 14:20:54.593919721 +0200
@@ -25,4 +25,3 @@
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ECalComponent, g_object_unref);
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ECalComponentId, e_cal_component_free_id);
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ECalClient, g_object_unref);
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (ESource, g_object_unref);


code:
Gnome-tweaks does not look at GSETTINGS_SCHEMA_PATH or XDG_DATA_DIRS, it
assumes that schemas are installed in one global directory
(GSETTINGS_SCHEMA_DIR/gsettingsschemadir).

Guix/GuixSD uses a different directory for every gir package and has
packages pick-up files using XDG_DATA_DIRS.

Upstream ticket: https://bugzilla.gnome.org/show_bug.cgi?id=764537
janneke@gnu.org

--- gnome-tweak-3.18.1.orig/gtweak/gsettings.py	2015-04-08 15:21:32.000000000 +0200
+++ gnome-tweak-tool-3.18.1/gtweak/gsettings.py	2016-04-03 11:26:38.658482704 +0200
@@ -16,7 +16,8 @@
 # along with gnome-tweak-tool.  If not, see <http://www.gnu.org/licenses/>.

 import logging
-import os.path
+import os
+import sys
 import xml.dom.minidom
 import gettext

@@ -31,6 +32,13 @@
 class GSettingsMissingError(Exception):
     pass

+def file_from_path(path, file_name):
+    for dir in path:
+        f = os.path.join(dir, file_name)
+        if os.path.exists(f):
+            return f
+    return None
+
 class _GSettingsSchema:
     def __init__(self, schema_name, schema_dir=None, schema_filename=None, **options):
         if not schema_dir:
@@ -38,9 +46,14 @@
         if not schema_filename:
             schema_filename = schema_name + ".gschema.xml"

+        schema_prefix = os.path.join('glib-2.0', 'schemas')
         schema_path = os.path.join(schema_dir, schema_filename)
         if not os.path.exists(schema_path):
-            logging.critical("Could not find schema %s" % schema_path)
+            schema_path = file_from_path(os.environ.get ('GSETTINGS_SCHEMA_PATH', '').split(os.path.pathsep), schema_filename)
+        if not (schema_path and os.path.exists(schema_path)):
+            schema_path = file_from_path(os.environ.get ('XDG_DATA_DIRS', '').split(os.path.pathsep), os.path.join(schema_prefix, schema_filename))
+        if not (schema_path and os.path.exists(schema_path)):
+            logging.critical("Could not find schema %s" % schema_filename)
             assert(False)

         self._schema_name = schema_name


code:
Make GnuPG automatically find a pinentry installed by Guix. Try using
$HOME or, if that variable is not set, use the system password database,
or fall back to looking in "/".

More information:

https://bugs.gnu.org/24076

diff --git a/common/homedir.c b/common/homedir.c
index 4b6e46e88..f7ae68ba5 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -33,6 +33,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <pwd.h>

 #ifdef HAVE_W32_SYSTEM
 #include <winsock2.h>   /* Due to the stupid mingw64 requirement to
@@ -67,6 +68,10 @@
  * gnupg_homedir and gnupg_set_homedir.  Malloced.  */
 static char *the_gnupg_homedir;

+/* The user's home directory. Used in Guix to help GnuPG find the
+ * pinentry. */
+static char *the_user_homedir;
+
 /* Flag indicating that home directory is not the default one.  */
 static byte non_default_homedir;

@@ -509,6 +514,25 @@ gnupg_homedir (void)
   return the_gnupg_homedir;
 }

+/* Return the user's home directory */
+const char *
+user_homedir (void)
+{
+  const char *dir;
+  dir = getenv("HOME");
+  if (dir == NULL)
+    {
+       struct passwd *pw = NULL;
+       pw = getpwuid (getuid ());
+       if (pw != NULL)
+         dir = pw->pw_dir;
+       else
+         dir = "/";
+    }
+  if (!the_user_homedir)
+    the_user_homedir = make_absfilename (dir, NULL);
+  return the_user_homedir;
+}

 /* Return whether the home dir is the default one.  */
 int
@@ -971,6 +995,7 @@ get_default_pinentry_name (int reset)
   } names[] = {
     /* The first entry is what we return in case we found no
        other pinentry.  */
+    { user_homedir, "/.guix-profile/bin/pinentry" },
     { gnupg_bindir, DIRSEP_S "pinentry" EXEEXT_S },
 #ifdef HAVE_W32_SYSTEM
     /* Try Gpg4win directory (with bin and without.) */


code:
Not sent upstream.

From e23de62e28f64599148ff06e439fac116a391299 Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
Date: Fri, 10 Apr 2020 07:24:48 +0200
Subject: [PATCH] guile: Cross build fix.

To cross-build, both the host guile and the native guile-for-build
must be available.  If the native guile is not available, no snarfing
is done and the guile cross build is skipped.

During the cross-build gnutls.scm does not load when compliling
extra.scm, becase of missing definitions from guile-gnutls-v-2.

* guile/modules/gnutls.in (protocol/ssl-3 protocol/tls-1.0,
protocol/tls-1.1, credentials/anonymous, cipher/rijndael-256-cbc,
cipher/rijndael-128-cbc, cipher/rijndael-cbc, cipher/arcfour-128,
certificate-verify/allow-any-x509-v1-ca-certificate,
certificate-verify/allow-x509-v1-ca-certificate): Define to #f
initially.  When "GNUTLS_GUILE_CROSS_COMPILING" not set, set! to value
from "guile-gnutls-v-2" load-extension C module.
---
 guile/modules/gnutls.in | 40 +++++++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/guile/modules/gnutls.in b/guile/modules/gnutls.in
index 6461c404a..954e315de 100644
--- a/guile/modules/gnutls.in
+++ b/guile/modules/gnutls.in
@@ -564,22 +564,36 @@ This defines 'variable' as an alias for 'alias', and emits a warning when
                    (identifier? #'id)
                    #'alias))))))))))

-
 ;; Renaming.
-(define protocol/ssl-3 protocol/ssl3)
-(define protocol/tls-1.0 protocol/tls1-0)
-(define protocol/tls-1.1 protocol/tls1-1)
+(define protocol/ssl-3 #f)
+(define protocol/tls-1.0 #f)
+(define protocol/tls-1.1 #f)

 ;; Aliases.
-(define credentials/anonymous   credentials/anon)
-(define cipher/rijndael-256-cbc cipher/aes-256-cbc)
-(define cipher/rijndael-128-cbc cipher/aes-128-cbc)
-(define cipher/rijndael-cbc     cipher/aes-128-cbc)
-(define cipher/arcfour-128      cipher/arcfour)
-(define certificate-verify/allow-any-x509-v1-ca-certificate
-  certificate-verify/allow-any-x509-v1-ca-crt)
-(define certificate-verify/allow-x509-v1-ca-certificate
-  certificate-verify/allow-x509-v1-ca-crt)
+(define credentials/anonymous   #f)
+(define cipher/rijndael-256-cbc #f)
+(define cipher/rijndael-128-cbc #f)
+(define cipher/rijndael-cbc     #f)
+(define cipher/arcfour-128      #f)
+(define certificate-verify/allow-any-x509-v1-ca-certificate #f)
+(define certificate-verify/allow-x509-v1-ca-certificate #f)
+
+(unless (getenv "GNUTLS_GUILE_CROSS_COMPILING")
+  ;; Renaming.
+  (set! protocol/ssl-3 protocol/ssl3)
+  (set! protocol/tls-1.0 protocol/tls1-0)
+  (set! protocol/tls-1.1 protocol/tls1-1)
+
+  ;; Aliases.
+  (set! credentials/anonymous   credentials/anon)
+  (set! cipher/rijndael-256-cbc cipher/aes-256-cbc)
+  (set! cipher/rijndael-128-cbc cipher/aes-128-cbc)
+  (set! cipher/rijndael-cbc     cipher/aes-128-cbc)
+  (set! cipher/arcfour-128      cipher/arcfour)
+  (set! certificate-verify/allow-any-x509-v1-ca-certificate
+    certificate-verify/allow-any-x509-v1-ca-crt)
+  (set! certificate-verify/allow-x509-v1-ca-certificate
+    certificate-verify/allow-x509-v1-ca-crt))

 ;; Deprecated OpenPGP bindings.
 (define-deprecated certificate-type/openpgp)
--
2.26.0


code:
Version 3.5.11 added a test to check that the default trust store is readable.
It does not exist in the build environment, so pretend everything is fine.

diff a/tests/trust-store.c b/tests/trust-store.c
--- a/tests/trust-store.c
+++ b/tests/trust-store.c
@@ -61,7 +61,7 @@
 	} else if (ret < 0) {
 		fail("error loading system trust store: %s\n", gnutls_strerror(ret));
 	} else if (ret == 0) {
-		fail("no certificates were found in system trust store!\n");
+		success("no trust store in the Guix build environment!\n");
 	}

 	gnutls_certificate_free_credentials(x509_cred);


code:
Skip a GC test known to be flaky:

  https://issues.guix.gnu.org/issue/37425
  https://github.com/golang/go/issues/27636

--- go/src/runtime/gc_test.go	2019-09-16 23:10:18.200680387 +0200
+++ go/src/runtime/gc_test.go	2019-09-16 23:11:50.324360646 +0200
@@ -27,6 +27,9 @@ func TestGcSys(t *testing.T) {
 	if runtime.GOOS == "linux" && runtime.GOARCH == "arm64" {
 		t.Skip("skipping test; GOOS=linux GOARCH=arm64 https://github.com/golang/go/issues/27636")
 	}
+	if runtime.GOOS == "linux" {
+		t.Skip("skipping test; GOOS=linux https://issues.guix.gnu.org/issue/37425")
+	}
 	got := runTestProg(t, "testprog", "GCSys")
 	want := "OK\n"
 	if got != want {


code:
# Names of libraries included in typelib files are opened by dlopen.  Here we
# add the full path.
#
# This patch was provided by Luca Bruno <lucabru@src.gnome.org>  for
# 'gobject-introspection' 1.40.0 in Nix.
#
# It has since been updated to work with newer versions of
# gobject-introspection.
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -95,6 +95,39 @@ def get_windows_option_group(parser):
     return group

+def _get_default_fallback_libpath():
+    # Newer multiple-output-optimized stdenv has an environment variable
+    # $outputLib which in turn specifies another variable which then is used as
+    # the destination for the library contents (${!outputLib}/lib).
+    store_path = os.environ.get(os.environ.get("outputLib")) if "outputLib" in os.environ else None
+    if store_path is None:
+        outputs = os.environ.get("outputs", "out").split()
+        if "lib" in outputs:
+            # For multiple output derivations let's try whether there is a $lib
+            # environment variable and use that as the base store path.
+            store_path = os.environ.get("lib")
+        elif "out" in outputs:
+            # Otherwise we have a single output derivation, so the libraries
+            # most certainly will end up in "$out/lib".
+            store_path = os.environ.get("out")
+
+    if store_path is not None:
+        # Even if we have a $lib as output, there still should be a $lib/lib
+        # directory.
+        return os.path.join(store_path, 'lib')
+    else:
+        # If we haven't found a possible scenario, let's return an empty string
+        # so that the shared library won't be prepended with a path.
+        #
+        # Note that this doesn't mean that all hope is lost, because after all
+        # we can still use --fallback-library-path to set one.
+        #
+        # Also, we're not returning None, because that would make it very
+        # difficult to disable adding fallback paths altogether using something
+        # like: --fallback-library-path=""
+        return ""
+
+
 def _get_option_parser():
     parser = optparse.OptionParser('%prog [options] sources',
                                    version='%prog ' + giscanner.__version__)
@@ -205,6 +238,10 @@ match the namespace prefix.""")
     parser.add_option("", "--filelist",
                       action="store", dest="filelist", default=[],
                       help="file containing headers and sources to be scanned")
+    parser.add_option("", "--fallback-library-path",
+                      action="store", dest="fallback_libpath",
+                      default=_get_default_fallback_libpath(),
+                      help="Path to prepend to unknown shared libraries")

     group = get_preprocessor_option_group(parser)
     parser.add_option_group(group)
--- a/giscanner/shlibs.py
+++ b/giscanner/shlibs.py
@@ -57,6 +57,14 @@ def _ldd_library_pattern(library_name):
     $""" % re.escape(library_name), re.VERBOSE)

+def _ldd_library_guix_pattern(library_name):
+    store_dir = re.escape(
+      os.environ.get("NIX_STORE", default="/gnu/store")
+    )
+    pattern = r'(%s(?:/[^/]*)+lib%s[^A-Za-z0-9_-][^\s\(\)]*)'
+    return re.compile(pattern % (store_dir, re.escape(library_name)))
+
+
 # This is a what we do for non-la files. We assume that we are on an
 # ELF-like system where ldd exists and the soname extracted with ldd is
 # a filename that can be opened with dlopen().
@@ -106,7 +112,8 @@ def _resolve_non_libtool(options, binary, libraries):
             output = output.decode("utf-8", "replace")

         shlibs = resolve_from_ldd_output(libraries, output)
-        return list(map(sanitize_shlib_path, shlibs))
+        fallback_libpath = options.fallback_libpath or "";
+        return list(map(lambda p: os.path.join(fallback_libpath, p), map(sanitize_shlib_path, shlibs)))

 def sanitize_shlib_path(lib):
@@ -115,19 +122,18 @@ def sanitize_shlib_path(lib):
     # In case we get relative paths on macOS (like @rpath) then we fall
     # back to the basename as well:
     # https://gitlab.gnome.org/GNOME/gobject-introspection/issues/222
-    if sys.platform == "darwin":
-        if not os.path.isabs(lib):
-            return os.path.basename(lib)
-        return lib
-    else:
+
+    # Always use absolute paths if available
+    if not os.path.isabs(lib):
         return os.path.basename(lib)
+    return lib

 def resolve_from_ldd_output(libraries, output):
     patterns = {}
     for library in libraries:
         if not os.path.isfile(library):
-            patterns[library] = _ldd_library_pattern(library)
+            patterns[library] = (_ldd_library_pattern(library), _ldd_library_guix_pattern(library))
     if len(patterns) == 0:
         return []

@@ -139,8 +145,12 @@ def resolve_from_ldd_output(libraries, output):
         if line.endswith(':'):
             continue
         for word in line.split():
-            for library, pattern in patterns.items():
-                m = pattern.match(word)
+            for library, (pattern, guix_pattern) in patterns.items():
+                store_dir = os.environ.get("NIX_STORE", default="/gnu/store")
+                if line.find(store_dir) != -1:
+                    m = guix_pattern.match(word)
+                else:
+                    m = pattern.match(word)
                 if m:
                     del patterns[library]
                     shlibs.append(m.group())

--- a/giscanner/utils.py
+++ b/giscanner/utils.py
@@ -111,17 +111,11 @@ def extract_libtool_shlib(la_file):
     if dlname is None:
         return None

-    # Darwin uses absolute paths where possible; since the libtool files never
-    # contain absolute paths, use the libdir field
-    if platform.system() == 'Darwin':
-        dlbasename = os.path.basename(dlname)
-        libdir = _extract_libdir_field(la_file)
-        if libdir is None:
-            return dlbasename
-        return libdir + '/' + dlbasename
-    # From the comments in extract_libtool(), older libtools had
-    # a path rather than the raw dlname
-    return os.path.basename(dlname)
+    dlbasename = os.path.basename(dlname)
+    libdir = _extract_libdir_field(la_file)
+    if libdir is None:
+        return dlbasename
+    return libdir + '/' + dlbasename

 def extract_libtool(la_file):
--- a/tests/scanner/test_shlibs.py
+++ b/tests/scanner/test_shlibs.py
@@ -40,6 +64,7 @@ class TestLddParser(unittest.TestCase):

         self.assertEqual(
             sanitize_shlib_path('/foo/bar'),
-            '/foo/bar' if sys.platform == 'darwin' else 'bar')
+            # Always use an absolute filename for Guix
+            '/foo/bar')

     def test_unresolved_library(self):
output = ''