~ruther/guix-local

6cebf0e1d5e13ce6010aace03a3d1d4a1071d49a — Yelninei 1 year, 1 month ago 635da6e
gnu: glibc/hurd: Fix gnulib tests.

With glibc-2.41 several gnulib tests are failing on the Hurd in multiple core packages
- test-once1
- test-pthread_sigmask1
- test-symlink/test-symlinkat

This adds the relevant patches from glibc upstream or the version from the
debian glibc adapted for glibc 2.41.

* gnu/packages/patches/glibc-hurd-2.41-pthread-once.patch: New patch.
* gnu/packages/patches/glibc-hurd-2.41-pthread-sigmask.patch: New patch.
* gnu/packages/patches/glibc-hurd-2.41-symlink.patch: New patch.
* gnu/packages/base.scm (glibc/hurd): Add them.
* gnu/local.mk : Register them.

Change-Id: I90ec984757da54ebbc7cb7817de00f2876f4a81a
M gnu/local.mk => gnu/local.mk +3 -0
@@ 1488,6 1488,9 @@ dist_patch_DATA =						\
  %D%/packages/patches/glibc-hurd-mach-print.patch		\
  %D%/packages/patches/glibc-hurd-pthread_setcancelstate.patch	\
  %D%/packages/patches/glibc-hurd-signal-sa-siginfo.patch	\
  %D%/packages/patches/glibc-hurd-2.41-pthread-once.patch	\
  %D%/packages/patches/glibc-hurd-2.41-pthread-sigmask.patch	\
  %D%/packages/patches/glibc-hurd-2.41-symlink.patch		\
  %D%/packages/patches/glibc-hurd64-gcc-14.2-tls-bug.patch	\
  %D%/packages/patches/glibc-hurd64-intr-msg-clobber.patch	\
  %D%/packages/patches/glibc-ldd-powerpc.patch			\

M gnu/packages/base.scm => gnu/packages/base.scm +3 -0
@@ 1662,6 1662,9 @@ command.")
       (patches
        (append (origin-patches (package-source glibc))
                (search-patches "glibc-hurd-pthread_setcancelstate.patch"
                                "glibc-hurd-2.41-pthread-once.patch"
                                "glibc-hurd-2.41-pthread-sigmask.patch"
                                "glibc-hurd-2.41-symlink.patch"
                                "glibc-hurd64-intr-msg-clobber.patch"
                                "glibc-hurd64-gcc-14.2-tls-bug.patch")))))))


A gnu/packages/patches/glibc-hurd-2.41-pthread-once.patch => gnu/packages/patches/glibc-hurd-2.41-pthread-once.patch +185 -0
@@ 0,0 1,185 @@
Taken from:
https://salsa.debian.org/glibc-team/glibc/-/blob/22f0a9381fe844a5de92a57012833bec225a9686/debian/patches/hurd-i386/local-pthread_once.diff
This is glibc ccdb68e829a31e4cda8339ea0d2dc3e51fb81ba5 adapted for glibc 2.41

Note: compared to upstream, this was changed to exposing pthread_once as version
2.41.

commit ccdb68e829a31e4cda8339ea0d2dc3e51fb81ba5
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Sun Mar 2 15:16:45 2025 +0100

    htl: move pthread_once into libc

diff --git a/htl/Makefile b/htl/Makefile
index 310097914f..603af24ce4 100644
--- a/htl/Makefile
+++ b/htl/Makefile
@@ -31,7 +31,6 @@ libpthread-routines := \
   pt-key-delete \
   pt-getspecific \
   pt-setspecific \
-  pt-once \
   pt-alloc \
   pt-create \
   pt-getattr \
@@ -186,6 +185,7 @@ routines := \
   pt-mutexattr-setrobust \
   pt-mutexattr-settype \
   pt-nthreads \
+  pt-once \
   pt-pthread_self \
   pt-self pt-equal \
   pt-setschedparam \
diff --git a/htl/Versions b/htl/Versions
index 3d2cb4e7a4..a07a3b3708 100644
--- a/htl/Versions
+++ b/htl/Versions
@@ -63,6 +63,7 @@ libc {
     pthread_mutexattr_setprotocol;
     pthread_mutexattr_setpshared;
     pthread_mutexattr_settype;
+    pthread_once;
     pthread_sigmask;
   }
 
@@ -158,6 +159,7 @@ libc {
     pthread_mutexattr_setpshared;
     pthread_mutexattr_setrobust; pthread_mutexattr_setrobust_np;
     pthread_mutexattr_settype;
+    pthread_once;
     pthread_sigmask;
   }
 
@@ -211,6 +213,7 @@ libc {
     __pthread_mutexattr_destroy;
     __pthread_mutexattr_init;
     __pthread_mutexattr_settype;
+    __pthread_once;
     __pthread_sigstate;
     __pthread_sigstate_destroy;
     __pthread_sigmask;
@@ -264,8 +267,6 @@ libpthread {
     pthread_mutex_timedlock; pthread_mutex_transfer_np;
     pthread_mutex_trylock; pthread_mutex_unlock;
 
-    pthread_once;
-
     pthread_rwlock_destroy; pthread_rwlock_init; pthread_rwlock_rdlock;
     pthread_rwlock_timedrdlock; pthread_rwlock_timedwrlock;
     pthread_rwlock_tryrdlock; pthread_rwlock_trywrlock;
diff --git a/sysdeps/htl/libc-lockP.h b/sysdeps/htl/libc-lockP.h
index 5085570baa..092eb35831 100644
--- a/sysdeps/htl/libc-lockP.h
+++ b/sysdeps/htl/libc-lockP.h
@@ -114,6 +114,7 @@ libc_hidden_proto (__pthread_rwlock_unlock)
 
 extern int __pthread_once (pthread_once_t *__once_control,
 			   void (*__init_routine) (void));
+libc_hidden_proto (__pthread_once);
 
 extern int __pthread_atfork (void (*__prepare) (void),
 			     void (*__parent) (void),
@@ -128,7 +129,6 @@ libc_hidden_proto (__pthread_setcancelstate)
 weak_extern (__pthread_key_create)
 weak_extern (__pthread_setspecific)
 weak_extern (__pthread_getspecific)
-weak_extern (__pthread_once)
 weak_extern (__pthread_initialize)
 weak_extern (__pthread_atfork)
 weak_extern (__pthread_setcancelstate)
@@ -128,7 +129,6 @@ libc_hidden_proto (__pthread_setcancelstate)
 #  pragma weak __pthread_key_create
 #  pragma weak __pthread_setspecific
 #  pragma weak __pthread_getspecific
-#  pragma weak __pthread_once
 #  pragma weak __pthread_initialize
 #  pragma weak __pthread_atfork
 #  pragma weak __pthread_setcancelstate
diff --git a/sysdeps/htl/pt-once.c b/sysdeps/htl/pt-once.c
index 68fb2e1129..1f999ce492 100644
--- a/sysdeps/htl/pt-once.c
+++ b/sysdeps/htl/pt-once.c
@@ -20,6 +20,7 @@
 #include <atomic.h>
 
 #include <pt-internal.h>
+#include <shlib-compat.h>
 
 static void
 clear_once_control (void *arg)
@@ -53,4 +54,9 @@ __pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
 
   return 0;
 }
-weak_alias (__pthread_once, pthread_once);
+libc_hidden_def (__pthread_once)
+versioned_symbol (libc, __pthread_once, pthread_once, GLIBC_2_41);
+
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_41)
+compat_symbol (libpthread, __pthread_once, pthread_once, GLIBC_2_12);
+#endif
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index bf62539c57..461df01ffb 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -88,6 +88,7 @@ GLIBC_2.12 pthread_mutexattr_setprioceiling F
 GLIBC_2.12 pthread_mutexattr_setprotocol F
 GLIBC_2.12 pthread_mutexattr_setpshared F
 GLIBC_2.12 pthread_mutexattr_settype F
+GLIBC_2.12 pthread_once F
 GLIBC_2.12 pthread_self F
 GLIBC_2.12 pthread_setschedparam F
 GLIBC_2.12 pthread_sigmask F
@@ -2595,6 +2596,7 @@ GLIBC_2.42 pthread_mutex_consistent_np F
 GLIBC_2.41 pthread_mutexattr_setrobust F
 GLIBC_2.41 pthread_mutexattr_setrobust_np F
 GLIBC_2.41 pthread_mutexattr_settype F
+GLIBC_2.41 pthread_once F
 GLIBC_2.41 pthread_sigmask F
 GLIBC_2.5 __readlinkat_chk F
 GLIBC_2.5 inet6_opt_append F
diff --git a/sysdeps/mach/hurd/i386/libpthread.abilist b/sysdeps/mach/hurd/i386/libpthread.abilist
index d9c1a1790a..b067d377b3 100644
--- a/sysdeps/mach/hurd/i386/libpthread.abilist
+++ b/sysdeps/mach/hurd/i386/libpthread.abilist
@@ -35,7 +35,6 @@ GLIBC_2.12 pthread_key_create F
 GLIBC_2.12 pthread_mutex_transfer_np F
 GLIBC_2.12 pthread_mutex_trylock F
 GLIBC_2.12 pthread_mutex_unlock F
-GLIBC_2.12 pthread_once F
 GLIBC_2.12 pthread_rwlock_destroy F
 GLIBC_2.12 pthread_rwlock_init F
 GLIBC_2.12 pthread_rwlock_rdlock F
diff --git a/sysdeps/mach/hurd/x86_64/libc.abilist b/sysdeps/mach/hurd/x86_64/libc.abilist
index fb068ab45e..6f235d20ba 100644
--- a/sysdeps/mach/hurd/x86_64/libc.abilist
+++ b/sysdeps/mach/hurd/x86_64/libc.abilist
@@ -1579,6 +1579,7 @@ GLIBC_2.38 pthread_mutexattr_setpshared F
 GLIBC_2.38 pthread_mutexattr_setrobust F
 GLIBC_2.38 pthread_mutexattr_setrobust_np F
 GLIBC_2.38 pthread_mutexattr_settype F
+GLIBC_2.38 pthread_once F
 GLIBC_2.38 pthread_self F
 GLIBC_2.38 pthread_setcancelstate F
 GLIBC_2.38 pthread_setcanceltype F
@@ -2278,6 +2279,7 @@ GLIBC_2.42 pthread_mutex_consistent_np F
 GLIBC_2.41 pthread_mutexattr_setrobust F
 GLIBC_2.41 pthread_mutexattr_setrobust_np F
 GLIBC_2.41 pthread_mutexattr_settype F
+GLIBC_2.41 pthread_once F
 GLIBC_2.41 pthread_sigmask F
 HURD_CTHREADS_0.3 __cthread_getspecific F
 HURD_CTHREADS_0.3 __cthread_keycreate F
diff --git a/sysdeps/mach/hurd/x86_64/libpthread.abilist b/sysdeps/mach/hurd/x86_64/libpthread.abilist
index 71ce1d6288..6b8acec832 100644
--- a/sysdeps/mach/hurd/x86_64/libpthread.abilist
+++ b/sysdeps/mach/hurd/x86_64/libpthread.abilist
@@ -55,7 +55,6 @@ GLIBC_2.38 pthread_key_create F
 GLIBC_2.38 pthread_mutex_transfer_np F
 GLIBC_2.38 pthread_mutex_trylock F
 GLIBC_2.38 pthread_mutex_unlock F
-GLIBC_2.38 pthread_once F
 GLIBC_2.38 pthread_rwlock_clockrdlock F
 GLIBC_2.38 pthread_rwlock_clockwrlock F
 GLIBC_2.38 pthread_rwlock_destroy F

A gnu/packages/patches/glibc-hurd-2.41-pthread-sigmask.patch => gnu/packages/patches/glibc-hurd-2.41-pthread-sigmask.patch +22 -0
@@ 0,0 1,22 @@
Taken from:
https://salsa.debian.org/glibc-team/glibc/-/blob/6c823b5862bd91ca757eeb9c6f5326875bc8af01/debian/patches/hurd-i386/git-pthread_sigmask_nothread.diff

Upstream 2.42 has a much more involved cleanup fix which in the end
boils down to this.

Index: glibc-upstream/sysdeps/mach/hurd/htl/pt-sigstate.c
===================================================================
--- glibc-upstream.orig/sysdeps/mach/hurd/htl/pt-sigstate.c
+++ glibc-upstream/sysdeps/mach/hurd/htl/pt-sigstate.c
@@ -36,7 +36,10 @@ __pthread_sigstate (struct __pthread *th
   if (set != NULL)
     new = *set;
 
-  ss = _hurd_thread_sigstate (thread->kernel_thread);
+  if (thread == _pthread_self ())
+    ss = _hurd_self_sigstate ();
+  else
+    ss = _hurd_thread_sigstate (thread->kernel_thread);
   assert (ss);
 
   _hurd_sigstate_lock (ss);

A gnu/packages/patches/glibc-hurd-2.41-symlink.patch => gnu/packages/patches/glibc-hurd-2.41-symlink.patch +32 -0
@@ 0,0 1,32 @@
Taken from:
https://sourceware.org/git/?p=glibc.git;a=patch;h=39183b953c68a489cc0b9aefb8974711c834fb38

From 39183b953c68a489cc0b9aefb8974711c834fb38 Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Mon, 21 Apr 2025 22:21:17 +0200
Subject: [PATCH] hurd: Make symlink return EEXIST on existing target directory

8ef17919509e ("hurd: Fix EINVAL error on linking to a slash-trailing path
[BZ #32569]) made symlink return ENOTDIR, but the gnulib testsuite does
not recognize it for such a situation, and EEXIST is indeed more
comprehensible to users.
---
 sysdeps/mach/hurd/symlinkat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sysdeps/mach/hurd/symlinkat.c b/sysdeps/mach/hurd/symlinkat.c
index e7dfb673df..cb6250e6f0 100644
--- a/sysdeps/mach/hurd/symlinkat.c
+++ b/sysdeps/mach/hurd/symlinkat.c
@@ -47,7 +47,7 @@ __symlinkat (const char *from, int fd, const char *to)
 
   if (! *name)
     /* Can't link to the existing directory itself.  */
-    err = ENOTDIR;
+    err = EEXIST;
   else
     /* Create a new, unlinked node in the target directory.  */
     err = __dir_mkfile (dir, O_WRITE, 0777 & ~_hurd_umask, &node);
-- 
2.49.0