[PATCH 56/94] sys-libs/glibc: add extra Hurd patches

Sam James <[email protected]>
Newsgroups gmane.linux.gentoo.devel
Message-ID <d3ad7c446f57632bc23c019f9cf004bf36fe784c.1774994333.git.sam@gentoo.org>
* CLOCK_MONOTONIC fix for Python, as `multiprocessing` demands to know
  clock information, but clock_getres can't give such information
  for CLOCK_MONOTONIC on Hurd, so fake it.

* Enable ldconfig, otherwise /etd/ld.so.conf* machinery won't work.

Signed-off-by: Sam James <[email protected]>
---
 .../glibc-2.43-hurd-CLOCK_MONOTONIC.patch     | 74 +++++++++++++++++++
 .../files/glibc-2.43-hurd-ldconfig.patch      | 26 +++++++
 sys-libs/glibc/glibc-2.43.ebuild              |  8 +-
 sys-libs/glibc/glibc-9999.ebuild              |  6 ++
 4 files changed, 112 insertions(+), 2 deletions(-)
 create mode 100644 sys-libs/glibc/files/glibc-2.43-hurd-CLOCK_MONOTONIC.patch
 create mode 100644 sys-libs/glibc/files/glibc-2.43-hurd-ldconfig.patch

diff --git a/sys-libs/glibc/files/glibc-2.43-hurd-CLOCK_MONOTONIC.patch b/sys-libs/glibc/files/glibc-2.43-hurd-CLOCK_MONOTONIC.patch
new file mode 100644
index 0000000000000..c31cdccdc55c2
--- /dev/null
+++ b/sys-libs/glibc/files/glibc-2.43-hurd-CLOCK_MONOTONIC.patch
@@ -0,0 +1,74 @@
+https://salsa.debian.org/glibc-team/glibc/-/blob/c2bff774aba6fc93eb9c3baef4746db56a2be24c/debian/patches/hurd-i386/local-clock_gettime_MONOTONIC.diff
+
+Use the normal clocks for the raw & coarse clock for now.
+
+vlc 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.
+
+--- a/sysdeps/mach/clock_gettime.c
++++ b/sysdeps/mach/clock_gettime.c
+@@ -33,6 +33,8 @@ __clock_gettime (clockid_t clock_id, str
+   switch (clock_id) {
+ 
+     case CLOCK_MONOTONIC:
++    case CLOCK_MONOTONIC_RAW:
++    case CLOCK_MONOTONIC_COARSE:
+       /* If HAVE_HOST_GET_UPTIME64 is not defined or not available,
+          CLOCK_MONOTONIC will be equivalent to CLOCK_REALTIME.  */
+ #ifdef HAVE_HOST_GET_UPTIME64
+@@ -56,6 +58,7 @@ __clock_gettime (clockid_t clock_id, str
+       /* FALLTHROUGH */
+ 
+     case CLOCK_REALTIME:
++    case CLOCK_REALTIME_COARSE:
+       {
+ 	/* __host_get_time can only fail if passed an invalid host_t.
+ 	   __mach_host_self could theoretically fail (producing an
+--- a/rt/timer_create.c
++++ b/rt/timer_create.c
+@@ -47,7 +47,7 @@ timer_create (clockid_t clock_id, struct
+       return -1;
+     }
+ 
+-  if (clock_id != CLOCK_REALTIME)
++  if (clock_id != CLOCK_REALTIME && clock_id != CLOCK_MONOTONIC && clock_id != CLOCK_MONOTONIC_RAW && clock_id != CLOCK_REALTIME_COARSE && clock_id != CLOCK_MONOTONIC_COARSE)
+     {
+       __set_errno (EINVAL);
+       return -1;
+--- a/sysdeps/mach/hurd/bits/posix_opt.h
++++ b/sysdeps/mach/hurd/bits/posix_opt.h
+@@ -165,8 +165,8 @@
+ /* The monotonic clock might be available.  */
+ #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
+--- a/sysdeps/posix/clock_getres.c
++++ b/sysdeps/posix/clock_getres.c
+@@ -55,6 +55,10 @@ __clock_getres (clockid_t clock_id, stru
+   switch (clock_id)
+     {
+     case CLOCK_REALTIME:
++    case CLOCK_MONOTONIC:
++    case CLOCK_MONOTONIC_RAW:
++    case CLOCK_REALTIME_COARSE:
++    case CLOCK_MONOTONIC_COARSE:
+       retval = realtime_getres (res);
+       break;
+ 
+--- a/sysdeps/mach/clock_nanosleep.c
++++ b/sysdeps/mach/clock_nanosleep.c
+@@ -67,7 +67,7 @@ int
+ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
+ 		   struct timespec *rem)
+ {
+-  if ((clock_id != CLOCK_REALTIME && clock_id != CLOCK_MONOTONIC)
++  if ((clock_id != CLOCK_REALTIME && clock_id != CLOCK_MONOTONIC && clock_id != CLOCK_MONOTONIC_RAW && clock_id != CLOCK_REALTIME_COARSE && clock_id != CLOCK_MONOTONIC_COARSE)
+       || req->tv_sec < 0
+       || !valid_nanoseconds (req->tv_nsec)
+       || (flags != 0 && flags != TIMER_ABSTIME))
diff --git a/sys-libs/glibc/files/glibc-2.43-hurd-ldconfig.patch b/sys-libs/glibc/files/glibc-2.43-hurd-ldconfig.patch
new file mode 100644
index 0000000000000..1dd77155ef8fe
--- /dev/null
+++ b/sys-libs/glibc/files/glibc-2.43-hurd-ldconfig.patch
@@ -0,0 +1,26 @@
+https://salsa.debian.org/glibc-team/glibc/-/blob/93d5069240943c4dcc950f6255028f7d1fcc2df0/debian/patches/hurd-i386/local-enable-ldconfig.diff
+
+# DP: Description: Enable ldconfig and such on hurd-i386
+# DP: Author: Jeff Bailey <[email protected]>
+# DP: Related Bugs: #309489
+# DP: Upstream status: Not submitted
+# DP: Status Details: Upstream disagrees with this patch, but I'm
+# DP: putting it in so that we have expected Debian behaviour on the
+# DP: Hurd.  We should review this when the ELF standard supports runpath.
+# DP: Date: 08 Apr 2003
+  
+--- a/sysdeps/mach/hurd/configure
++++ b/sysdeps/mach/hurd/configure
+@@ -52,3 +52,4 @@
+ # Hurd has libpthread as a separate library.
+ pthread_in_libc=no
+ 
++use_ldconfig=yes
+--- a/sysdeps/mach/hurd/configure.ac
++++ b/sysdeps/mach/hurd/configure.ac
+@@ -29,3 +29,5 @@
+ 
+ # Hurd has libpthread as a separate library.
+ pthread_in_libc=no
++
++use_ldconfig=yes
diff --git a/sys-libs/glibc/glibc-2.43.ebuild b/sys-libs/glibc/glibc-2.43.ebuild
index 7c72868843ed1..db83ed326cc90 100644
--- a/sys-libs/glibc/glibc-2.43.ebuild
+++ b/sys-libs/glibc/glibc-2.43.ebuild
@@ -1020,8 +1020,12 @@ src_prepare() {
 		eapply "${WORKDIR}"/patches
 		einfo "Done."
 
-		# TODO: Put into our patchset
-		eapply "${FILESDIR}"/glibc-2.43-hurd-link-helpers.patch
+		# Patches we should apply only for Hurd to be conservative
+		if is_hurd ; then
+			eapply "${FILESDIR}"/glibc-2.43-hurd-link-helpers.patch
+			eapply "${FILESDIR}"/glibc-2.43-hurd-CLOCK_MONOTONIC.patch
+			eapply "${FILESDIR}"/glibc-2.43-hurd-ldconfig.patch
+		fi
 	fi
 
 	case ${CTARGET} in
diff --git a/sys-libs/glibc/glibc-9999.ebuild b/sys-libs/glibc/glibc-9999.ebuild
index a8d541f0c0189..05b4742ec7756 100644
--- a/sys-libs/glibc/glibc-9999.ebuild
+++ b/sys-libs/glibc/glibc-9999.ebuild
@@ -1019,6 +1019,12 @@ src_prepare() {
 		einfo "Applying Gentoo Glibc patchset ${patchsetname}"
 		eapply "${WORKDIR}"/patches
 		einfo "Done."
+
+		# Patches we should apply only for Hurd to be conservative
+		if is_hurd ; then
+			eapply "${FILESDIR}"/glibc-2.43-hurd-CLOCK_MONOTONIC.patch
+			eapply "${FILESDIR}"/glibc-2.43-hurd-ldconfig.patch
+		fi
 	fi
 
 	case ${CTARGET} in
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.