summary refs log tree commit diff
path: root/gnu
diff options
context:
space:
mode:
authorJosselin Poiret <dev@jpoiret.xyz>2023-05-22 11:42:26 +0200
committerJosselin Poiret <dev@jpoiret.xyz>2023-07-13 18:20:05 +0200
commit0dd293b4d9095137c9952e16ca951f887b7e7018 (patch)
treea2d45219218d10a0296bd8c9cba63ab01fb2aae0 /gnu
parent0613df90ddadce62b2c6e22048b216602bd9a230 (diff)
downloadguix-0dd293b4d9095137c9952e16ca951f887b7e7018.tar.gz
gnu: Add libc-for-target and glibc/hurd.
* gnu/packages/patches/glibc-2.37-hurd-clock_t_centiseconds.patch
* gnu/packages/patches/glibc-2.37-hurd-local-clock_gettime_MONOTONIC.patch
* gnu/packages/patches/glibc-2.37-versioned-locpath.patch: New patches.
* gnu/local.mk (dist_patch_DATA): Register them.

* gnu/packages/base.scm (glibc/hurd, libc-for-target): New variables.
(glibc/hurd-headers): Use glibc/hurd.
* gnu/packages/commencement.scm (glibc-final-with-bootstrap-bash)[outputs,
source, arguments]
(glibc-final)[source]: Use libc-for-target instead of glibc.
* gnu/packages/cross-base.scm (cross-libc/deprecated, cross-libc*): Use
libc-for-target.

This part fixes

    https://issues.guix.gnu.org/63641#25

* gnu/packages/commencement.scm (%final-inputs): Change to memoized lambda
taking "system".
* gnu/packages/commencement.scm (canonical-package): Likewise, and update
user, passing (%current-system).
(make-gcc-toolchain): Update user, passing (%current-system).
* gnu/packages/base.scm (%final-inputs): Likewise.
* guix/scripts/refresh.scm (options->update-specs): Likewise.
* guix/build-system/gnu.scm (standard-packages): Add optional "system"
parameter.
(lower): Update caller.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Co-authored-by: Janneke Nieuwenhuizen <janneke@gnu.org>
Diffstat (limited to 'gnu')
-rw-r--r--gnu/local.mk3
-rw-r--r--gnu/packages/base.scm39
-rw-r--r--gnu/packages/commencement.scm251
-rw-r--r--gnu/packages/cross-base.scm4
-rw-r--r--gnu/packages/patches/glibc-2.37-hurd-clock_t_centiseconds.patch61
-rw-r--r--gnu/packages/patches/glibc-2.37-hurd-local-clock_gettime_MONOTONIC.patch135
-rw-r--r--gnu/packages/patches/glibc-2.37-versioned-locpath.patch264
7 files changed, 629 insertions, 128 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index e9ce4ada54..3481659faa 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1260,6 +1260,9 @@ dist_patch_DATA =						\
   %D%/packages/patches/glibc-hidden-visibility-ldconfig.patch	\
   %D%/packages/patches/glibc-hurd-clock_gettime_monotonic.patch	\
   %D%/packages/patches/glibc-2.31-hurd-clock_gettime_monotonic.patch	\
+  %D%/packages/patches/glibc-2.37-hurd-clock_t_centiseconds.patch	\
+  %D%/packages/patches/glibc-2.37-hurd-local-clock_gettime_MONOTONIC.patch	\
+  %D%/packages/patches/glibc-2.37-versioned-locpath.patch	\
   %D%/packages/patches/glibc-hurd-clock_t_centiseconds.patch	\
   %D%/packages/patches/glibc-hurd-gettyent.patch		\
   %D%/packages/patches/glibc-hurd-mach-print.patch		\
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 38593e4ada..55fe70309c 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -76,6 +76,7 @@
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:export (glibc
+            libc-for-target
             make-ld-wrapper
             libiconv-if-needed))
 
@@ -1420,20 +1421,41 @@ variety of options.  It is an alternative to the shell \"type\" built-in
 command.")
     (license gpl3+))) ; some files are under GPLv2+
 
+(define-public glibc/hurd
+  (package/inherit glibc
+    (name "glibc-hurd")
+    (version "2.37")
+    (source (origin
+            (method url-fetch)
+            (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
+            (sha256
+             (base32
+              "0hqsp4dzrjx0iga6jv0magjw26dh82pxlmk8yis5v0d127qyymr2"))
+            (patches (search-patches "glibc-ldd-powerpc.patch"
+                                     "glibc-dl-cache.patch"
+                                     "glibc-2.37-versioned-locpath.patch"
+                                     "glibc-reinstate-prlimit64-fallback.patch"
+                                     "glibc-supported-locales.patch"
+                                     "glibc-2.37-hurd-clock_t_centiseconds.patch"
+                                     "glibc-2.37-hurd-local-clock_gettime_MONOTONIC.patch"
+                                     "glibc-hurd-mach-print.patch"
+                                     "glibc-hurd-gettyent.patch"))))
+    (supported-systems %hurd-systems)))
+
 (define-public glibc/hurd-headers
-  (package (inherit glibc)
+  (package/inherit glibc/hurd
     (name "glibc-hurd-headers")
     (outputs '("out"))
     (propagated-inputs (list gnumach-headers hurd-headers))
     (native-inputs
-     (modify-inputs (package-native-inputs glibc)
+     (modify-inputs (package-native-inputs glibc/hurd)
        (prepend (if (%current-target-system)
                     (let* ((cross-base (resolve-interface '(gnu packages cross-base)))
                            (cross-mig (module-ref cross-base 'cross-mig)))
                       (cross-mig (%current-target-system)))
                     mig))))
     (arguments
-     (substitute-keyword-arguments (package-arguments glibc)
+     (substitute-keyword-arguments (package-arguments glibc/hurd)
        ;; We just pass the flags really needed to build the headers.
        ((#:configure-flags flags)
         `(list "--enable-add-ons"
@@ -1454,6 +1476,15 @@ command.")
            (delete 'build)))))                  ; nothing to build
     (supported-systems %hurd-systems)))
 
+(define* (libc-for-target #:optional
+                          (target (or (%current-target-system)
+                                      (%current-system))))
+  (match target
+    ((? target-hurd?)
+     glibc/hurd)
+    (_
+     glibc)))
+
 (define-public tzdata
   (package
     (name "tzdata")
@@ -1602,6 +1633,6 @@ package needs iconv ,@(libiconv-if-needed) should be added."
   "Return the list of \"final inputs\"."
   ;; Avoid circular dependency by lazily resolving 'commencement'.
   (let ((iface (resolve-interface '(gnu packages commencement))))
-    (module-ref iface '%final-inputs)))
+    ((module-ref iface '%final-inputs) (%current-system))))
 
 ;;; base.scm ends here
diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index 669d54099d..9bd0c113c2 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -2822,64 +2822,65 @@ memoized as a function of '%current-system'."
     ("binutils-cross" ,binutils-boot0)
     ,@(alist-delete "binutils" (%boot0-inputs))))
 
-(define glibc-final-with-bootstrap-bash
+(define/system-dependent glibc-final-with-bootstrap-bash
   ;; The final libc, "cross-built".  If everything went well, the resulting
   ;; store path has no dependencies.  Actually, the really-final libc is
   ;; built just below; the only difference is that this one uses the
   ;; bootstrap Bash.
-  (package
-    (inherit glibc)
-    (name "glibc-intermediate")
-    (outputs (delete "debug" (package-outputs glibc)))
-    (source (bootstrap-origin (package-source glibc)))
-    (arguments
-     `(#:guile ,%bootstrap-guile
-       #:implicit-inputs? #f
-
-       ,@(substitute-keyword-arguments (package-arguments glibc)
-           ((#:configure-flags flags)
-            `(append (list ,(string-append "--host=" (boot-triplet))
-                           ,(string-append "--build="
-                                           (nix-system->gnu-triplet))
-                           ,(if (system-hurd?) "--disable-werror"
-                                ""))
-                     ,flags))
-           ((#:phases phases)
-            `(modify-phases ,phases
-               (add-before 'configure 'pre-configure
-                 (lambda* (#:key inputs #:allow-other-keys)
-                   ;; Don't clobber include paths with the bootstrap libc.
-                   (unsetenv "C_INCLUDE_PATH")
-                   (unsetenv "CPLUS_INCLUDE_PATH")
-
-                   ;; Tell 'libpthread' where to find 'libihash' on Hurd systems.
-                   ,@(if (system-hurd?)
-                       '((substitute* '("sysdeps/mach/Makefile"
-                                        "sysdeps/mach/hurd/Makefile")
-                           (("LDLIBS-pthread.so =.*")
-                            (string-append "LDLIBS-pthread.so = "
-                                           (assoc-ref %build-inputs "kernel-headers")
-                                           "/lib/libihash.a\n"))))
-                       '()))))))))
-    (propagated-inputs `(("kernel-headers" ,(kernel-headers-boot0))))
-    (native-inputs
-     `(("bison" ,bison-boot0)
-       ("texinfo" ,texinfo-boot0)
-       ("perl" ,perl-boot0)
-       ("python" ,python-boot0)))
-    (inputs
-     `( ;; The boot inputs.  That includes the bootstrap libc.  We don't want
-       ;; it in $CPATH, hence the 'pre-configure' phase above.
-       ,@(%boot1-inputs)
+  (let ((libc (libc-for-target)))
+    (package
+      (inherit libc)
+      (name "glibc-intermediate")
+      (outputs (delete "debug" (package-outputs libc)))
+      (source (bootstrap-origin (package-source libc)))
+      (arguments
+       `(#:guile ,%bootstrap-guile
+         #:implicit-inputs? #f
 
-       ;; A native MiG is needed to build Glibc on Hurd.
-       ,@(if (system-hurd?)
-             `(("mig" ,mig-boot0))
-             '())
+         ,@(substitute-keyword-arguments (package-arguments libc)
+             ((#:configure-flags flags)
+              `(append (list ,(string-append "--host=" (boot-triplet))
+                             ,(string-append "--build="
+                                             (nix-system->gnu-triplet))
+                             ,(if (system-hurd?) "--disable-werror"
+                                  ""))
+                       ,flags))
+             ((#:phases phases)
+              `(modify-phases ,phases
+                 (add-before 'configure 'pre-configure
+                   (lambda* (#:key inputs #:allow-other-keys)
+                     ;; Don't clobber include paths with the bootstrap libc.
+                     (unsetenv "C_INCLUDE_PATH")
+                     (unsetenv "CPLUS_INCLUDE_PATH")
+
+                     ;; Tell 'libpthread' where to find 'libihash' on Hurd systems.
+                     ,@(if (system-hurd?)
+                           '((substitute* '("sysdeps/mach/Makefile"
+                                            "sysdeps/mach/hurd/Makefile")
+                               (("LDLIBS-pthread.so =.*")
+                                (string-append "LDLIBS-pthread.so = "
+                                               (assoc-ref %build-inputs "kernel-headers")
+                                               "/lib/libihash.a\n"))))
+                           '()))))))))
+      (propagated-inputs `(("kernel-headers" ,(kernel-headers-boot0))))
+      (native-inputs
+       `(("bison" ,bison-boot0)
+         ("texinfo" ,texinfo-boot0)
+         ("perl" ,perl-boot0)
+         ("python" ,python-boot0)))
+      (inputs
+       `( ;; The boot inputs.  That includes the bootstrap libc.  We don't want
+         ;; it in $CPATH, hence the 'pre-configure' phase above.
+         ,@(%boot1-inputs)
+
+         ;; A native MiG is needed to build Glibc on Hurd.
+         ,@(if (system-hurd?)
+               `(("mig" ,mig-boot0))
+               '())
 
-       ;; Here, we use the bootstrap Bash, which is not satisfactory
-       ;; because we don't want to depend on bootstrap tools.
-       ("static-bash" ,@(assoc-ref (%boot0-inputs) "bash"))))))
+         ;; Here, we use the bootstrap Bash, which is not satisfactory
+         ;; because we don't want to depend on bootstrap tools.
+         ("static-bash" ,@(assoc-ref (%boot0-inputs) "bash")))))))
 
 (define (cross-gcc-wrapper gcc binutils glibc bash)
   "Return a wrapper for the pseudo-cross toolchain GCC/BINUTILS/GLIBC
@@ -2997,39 +2998,39 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
                         (("^PROGRAMS =.*$")
                          "PROGRAMS =\n")))))))))
 
-(define glibc-final
+(define/system-dependent glibc-final
   ;; The final glibc, which embeds the statically-linked Bash built above.
   ;; Use 'package/inherit' so we get the 'replacement' of 'glibc', if any.
-  (package/inherit
-   glibc
-   (name "glibc")
-   (source (bootstrap-origin (package-source glibc)))
-   (inputs `(("static-bash" ,static-bash-for-glibc)
-             ,@(alist-delete
-                "static-bash"
-                (package-inputs glibc-final-with-bootstrap-bash))))
-
-   ;; This time we need 'msgfmt' to install all the libc.mo files.
-   (native-inputs `(,@(package-native-inputs glibc-final-with-bootstrap-bash)
-                    ("gettext" ,gettext-boot0)))
-
-   (propagated-inputs
-    (package-propagated-inputs glibc-final-with-bootstrap-bash))
-
-   ;; The final libc only refers to itself, but the 'debug' output contains
-   ;; references to GCC-BOOT0 and to the Linux headers.  XXX: Would be great
-   ;; if 'allowed-references' were per-output.
-   (arguments
-    `(#:allowed-references
-      (,(gexp-input gcc-boot0 "lib")
-       ,(kernel-headers-boot0)
-       ,static-bash-for-glibc
-       ,@(if (system-hurd?)
-             `(,gnumach-headers-boot0
-               ,hurd-headers-boot0)
-             '())
-       ,@(package-outputs glibc-final-with-bootstrap-bash))
-      ,@(package-arguments glibc-final-with-bootstrap-bash)))))
+  (let ((libc (libc-for-target)))
+    (package/inherit libc
+      (name "glibc")
+      (source (bootstrap-origin (package-source libc)))
+      (inputs `(("static-bash" ,static-bash-for-glibc)
+                ,@(alist-delete
+                   "static-bash"
+                   (package-inputs glibc-final-with-bootstrap-bash))))
+
+      ;; This time we need 'msgfmt' to install all the libc.mo files.
+      (native-inputs `(,@(package-native-inputs glibc-final-with-bootstrap-bash)
+                       ("gettext" ,gettext-boot0)))
+
+      (propagated-inputs
+       (package-propagated-inputs glibc-final-with-bootstrap-bash))
+
+      ;; The final libc only refers to itself, but the 'debug' output contains
+      ;; references to GCC-BOOT0 and to the Linux headers.  XXX: Would be great
+      ;; if 'allowed-references' were per-output.
+      (arguments
+       `(#:allowed-references
+         (,(gexp-input gcc-boot0 "lib")
+          ,(kernel-headers-boot0)
+          ,static-bash-for-glibc
+          ,@(if (system-hurd?)
+                `(,gnumach-headers-boot0
+                  ,hurd-headers-boot0)
+                '())
+          ,@(package-outputs glibc-final-with-bootstrap-bash))
+         ,@(package-arguments glibc-final-with-bootstrap-bash))))))
 
 (define/system-dependent gcc-boot0-wrapped
   ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
@@ -3356,45 +3357,49 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
     (package/inherit sed (native-inputs `(("perl" ,perl-boot0))))))
 
 (define-public %final-inputs
-  ;; Final derivations used as implicit inputs by 'gnu-build-system'.  We
-  ;; still use 'package-with-bootstrap-guile' so that the bootstrap tools are
-  ;; used for origins that have patches, thereby avoiding circular
-  ;; dependencies.
-  (let ((finalize (compose with-boot6
-                           package-with-bootstrap-guile)))
-    `(,@(map (match-lambda
-               ((name package)
-                (list name (finalize package))))
-             `(("tar" ,tar)
-               ("gzip" ,gzip)
-               ("bzip2" ,bzip2)
-               ("file" ,file)
-               ("diffutils" ,diffutils)
-               ("patch" ,patch)
-               ("findutils" ,findutils)
-               ("gawk" ,gawk)))
-      ("sed" ,sed-final)
-      ("grep" ,grep-final)
-      ("xz" ,xz-final)
-      ("coreutils" ,coreutils-final)
-      ("make" ,gnu-make-final)
-      ("bash" ,bash-final)
-      ("ld-wrapper" ,ld-wrapper)
-      ("binutils" ,binutils-final)
-      ("gcc" ,gcc-final)
-      ("libc" ,glibc-final)
-      ("libc:static" ,glibc-final "static")
-      ("locales" ,glibc-utf8-locales-final))))
+  ;; The 'glibc-final' package is not the same depending on what system is
+  ;; targeted, so this whole list must be parameterized.
+  (mlambda (system)
+    ;; Final derivations used as implicit inputs by 'gnu-build-system'.  We
+    ;; still use 'package-with-bootstrap-guile' so that the bootstrap tools are
+    ;; used for origins that have patches, thereby avoiding circular
+    ;; dependencies.
+    (let ((finalize (compose with-boot6
+                             package-with-bootstrap-guile)))
+      `(,@(map (match-lambda
+                 ((name package)
+                  (list name (finalize package))))
+               `(("tar" ,tar)
+                 ("gzip" ,gzip)
+                 ("bzip2" ,bzip2)
+                 ("file" ,file)
+                 ("diffutils" ,diffutils)
+                 ("patch" ,patch)
+                 ("findutils" ,findutils)
+                 ("gawk" ,gawk)))
+        ("sed" ,sed-final)
+        ("grep" ,grep-final)
+        ("xz" ,xz-final)
+        ("coreutils" ,coreutils-final)
+        ("make" ,gnu-make-final)
+        ("bash" ,bash-final)
+        ("ld-wrapper" ,ld-wrapper)
+        ("binutils" ,binutils-final)
+        ("gcc" ,gcc-final)
+        ("libc" ,glibc-final)
+        ("libc:static" ,glibc-final "static")
+        ("locales" ,glibc-utf8-locales-final)))))
 
 (define-public canonical-package
-  (let ((name->package (fold (lambda (input result)
-                               (match input
-                                 ((_ package . outputs)
-                                  (vhash-cons (package-full-name package)
-                                              package result))))
-                             vlist-null
-                             `(("guile" ,guile-final)
-                               ,@%final-inputs))))
+  (let ((name->package (mlambda (system)
+                         (fold (lambda (input result)
+                                 (match input
+                                   ((_ package . outputs)
+                                    (vhash-cons (package-full-name package)
+                                                package result))))
+                               vlist-null
+                               `(("guile" ,guile-final)
+                                 ,@(%final-inputs system))))))
     (lambda (package)
       "Return the 'canonical' variant of PACKAGE---i.e., if PACKAGE is one of
 the implicit inputs of 'gnu-build-system', return that one, otherwise return
@@ -3404,7 +3409,8 @@ The goal is to avoid duplication in cases like GUILE-FINAL vs. GUILE-2.2,
 COREUTILS-FINAL vs. COREUTILS, etc."
       ;; XXX: This doesn't handle dependencies of the final inputs, such as
       ;; libunistring, GMP, etc.
-      (match (vhash-assoc (package-full-name package) name->package)
+      (match (vhash-assoc (package-full-name package)
+                          (name->package (%current-system)))
         ((_ . canon)
          ;; In general we want CANON, except if we're cross-compiling: CANON
          ;; uses explicit inputs, so it is "anchored" in the bootstrapped
@@ -3486,7 +3492,8 @@ is the GNU Compiler Collection.")
       ;; install everything that we need, and (2) to make sure ld-wrapper comes
       ;; before Binutils' ld in the user's profile.
       (inputs `(("gcc" ,gcc)
-                ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
+                ("ld-wrapper" ,(car (assoc-ref (%final-inputs (%current-system))
+                                               "ld-wrapper")))
                 ("binutils" ,binutils-final)
                 ("libc" ,libc)
                 ("libc-debug" ,libc "debug")
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index cdf642358d..21d7277e22 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -578,7 +578,7 @@ the base compiler.  Use XBINUTILS as the associated cross-Binutils."
 
 (define* (cross-libc/deprecated target
                                 #:optional
-                                (libc glibc)
+                                (libc (libc-for-target target))
                                 (xgcc (cross-gcc target))
                                 (xbinutils (cross-binutils target))
                                 (xheaders (cross-kernel-headers target)))
@@ -591,7 +591,7 @@ the base compiler.  Use XBINUTILS as the associated cross-Binutils."
 
 (define* (cross-libc* target
                       #:key
-                      (libc glibc)
+                      (libc (libc-for-target target))
                       (xgcc (cross-gcc target))
                       (xbinutils (cross-binutils target))
                       (xheaders (cross-kernel-headers target)))
diff --git a/gnu/packages/patches/glibc-2.37-hurd-clock_t_centiseconds.patch b/gnu/packages/patches/glibc-2.37-hurd-clock_t_centiseconds.patch
new file mode 100644
index 0000000000..944b2fe8df
--- /dev/null
+++ b/gnu/packages/patches/glibc-2.37-hurd-clock_t_centiseconds.patch
@@ -0,0 +1,61 @@
+Taken from: https://salsa.debian.org/glibc-team/glibc/-/blob/9ce19663f00176f30d6eab29fd14db3e7cd53dcf/debian/patches/hurd-i386/unsubmitted-clock_t_centiseconds.diff
+
+Some applications assume centisecond precision, or at most millisecond precision
+(e.g. guile).  This is a work-around for them.
+
+---
+ getclktck.c |    5 ++---
+ setitimer.c |    2 +-
+ times.c     |    2 +-
+ 4 files changed, 8 insertions(+), 9 deletions(-)
+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
+
+diff --git a/sysdeps/mach/hurd/getclktck.c b/sysdeps/mach/hurd/getclktck.c
+index 69be2cc..5f7d946 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 39b6b16..4992c89 100644
+--- a/sysdeps/mach/hurd/setitimer.c
++++ b/sysdeps/mach/hurd/setitimer.c
+@@ -42,7 +42,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 9e13a75..593c33a 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
diff --git a/gnu/packages/patches/glibc-2.37-hurd-local-clock_gettime_MONOTONIC.patch b/gnu/packages/patches/glibc-2.37-hurd-local-clock_gettime_MONOTONIC.patch
new file mode 100644
index 0000000000..63e06b8519
--- /dev/null
+++ b/gnu/packages/patches/glibc-2.37-hurd-local-clock_gettime_MONOTONIC.patch
@@ -0,0 +1,135 @@
+Taken from: https://salsa.debian.org/glibc-team/glibc/-/blob/9ce19663f00176f30d6eab29fd14db3e7cd53dcf/debian/patches/hurd-i386/local-clock_gettime_MONOTONIC.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.
+
+---
+ sysdeps/mach/hurd/bits/posix_opt.h |    2 +-
+ sysdeps/unix/clock_gettime.c       |    1 +
+ 2 files changed, 2 insertions(+), 1 deletion(-)
+Index: glibc-2.27/sysdeps/mach/clock_gettime.c
+===================================================================
+--- glibc-2.27.orig/sysdeps/mach/clock_gettime.c
++++ glibc-2.27/sysdeps/mach/clock_gettime.c
+@@ -31,6 +31,10 @@ __clock_gettime (clockid_t clock_id, str
+   switch (clock_id) {
+ 
+     case CLOCK_REALTIME:
++    case CLOCK_MONOTONIC:
++    case CLOCK_MONOTONIC_RAW:
++    case CLOCK_REALTIME_COARSE:
++    case CLOCK_MONOTONIC_COARSE:
+       {
+ 	/* __host_get_time can only fail if passed an invalid host_t.
+ 	   __mach_host_self could theoretically fail (producing an
+Index: glibc-2.27/rt/timer_create.c
+===================================================================
+--- glibc-2.27.orig/rt/timer_create.c
++++ glibc-2.27/rt/timer_create.c
+@@ -48,7 +48,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;
+Index: glibc-2.27/sysdeps/mach/hurd/bits/posix_opt.h
+===================================================================
+--- glibc-2.27.orig/sysdeps/mach/hurd/bits/posix_opt.h
++++ glibc-2.27/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
+Index: glibc-upstream/sysdeps/posix/clock_getres.c
+===================================================================
+--- glibc-upstream.orig/sysdeps/posix/clock_getres.c
++++ glibc-upstream/sysdeps/posix/clock_getres.c
+@@ -52,6 +52,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;
+ 
+--- ./sysdeps/mach/clock_nanosleep.c.original	2020-07-21 00:31:35.226113142 +0200
++++ ./sysdeps/mach/clock_nanosleep.c	2020-07-21 00:31:49.026185761 +0200
+@@ -62,7 +62,7 @@
+ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
+ 		   struct timespec *rem)
+ {
+-  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)
+       || !valid_nanoseconds (req->tv_nsec)
+       || (flags != 0 && flags != TIMER_ABSTIME))
+     return EINVAL;
+Index: glibc-2.32/hurd/hurdlock.c
+===================================================================
+--- glibc-2.32.orig/hurd/hurdlock.c
++++ glibc-2.32/hurd/hurdlock.c
+@@ -47,7 +47,7 @@ int
+ __lll_abstimed_wait (void *ptr, int val,
+   const struct timespec *tsp, int flags, int clk)
+ {
+-  if (clk != CLOCK_REALTIME)
++  if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC)
+     return EINVAL;
+ 
+   int mlsec = compute_reltime (tsp, clk);
+@@ -59,7 +59,7 @@ int
+ __lll_abstimed_wait_intr (void *ptr, int val,
+   const struct timespec *tsp, int flags, int clk)
+ {
+-  if (clk != CLOCK_REALTIME)
++  if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC)
+     return EINVAL;
+ 
+   int mlsec = compute_reltime (tsp, clk);
+@@ -79,7 +79,7 @@ int
+ __lll_abstimed_xwait (void *ptr, int lo, int hi,
+   const struct timespec *tsp, int flags, int clk)
+ {
+-  if (clk != CLOCK_REALTIME)
++  if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC)
+     return EINVAL;
+ 
+   int mlsec = compute_reltime (tsp, clk);
+@@ -91,7 +91,7 @@ int
+ __lll_abstimed_lock (void *ptr,
+   const struct timespec *tsp, int flags, int clk)
+ {
+-  if (clk != CLOCK_REALTIME)
++  if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC)
+     return EINVAL;
+ 
+   if (__lll_trylock (ptr) == 0)
+@@ -177,7 +177,7 @@ __lll_robust_abstimed_lock (void *ptr,
+   int wait_time = 25;
+   unsigned int val;
+ 
+-  if (clk != CLOCK_REALTIME)
++  if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC)
+     return EINVAL;
+ 
+   while (1)
diff --git a/gnu/packages/patches/glibc-2.37-versioned-locpath.patch b/gnu/packages/patches/glibc-2.37-versioned-locpath.patch
new file mode 100644
index 0000000000..0acaeb1e46
--- /dev/null
+++ b/gnu/packages/patches/glibc-2.37-versioned-locpath.patch
@@ -0,0 +1,264 @@
+From d73ba2caa10b8e9f51ff4239cc32eeb4e0de4279 Mon Sep 17 00:00:00 2001
+Message-Id: <d73ba2caa10b8e9f51ff4239cc32eeb4e0de4279.1683980025.git.dev@jpoiret.xyz>
+From: Josselin Poiret <dev@jpoiret.xyz>
+Date: Sat, 13 May 2023 14:10:43 +0200
+Subject: [PATCH] Add versioned locpath
+
+From: Josselin Poiret <dev@jpoiret.xyz>
+
+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.
+
+
+This patch is adapted from the 2.35 patch.
+
+---
+ locale/newlocale.c   | 15 ++--------
+ locale/setlocale.c   | 68 +++++++++++++++++++++++++++++++++++++-------
+ string/Makefile      |  1 +
+ string/argz-suffix.c | 56 ++++++++++++++++++++++++++++++++++++
+ string/argz.h        | 10 +++++++
+ 5 files changed, 127 insertions(+), 23 deletions(-)
+ create mode 100644 string/argz-suffix.c
+
+diff --git a/locale/newlocale.c b/locale/newlocale.c
+index 108d2428bf..6218e0fa77 100644
+--- a/locale/newlocale.c
++++ b/locale/newlocale.c
+@@ -29,6 +29,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							      \
+@@ -47,7 +48,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;
+ 
+@@ -101,17 +101,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 dd73fa4248..d8eb799384 100644
+--- a/locale/setlocale.c
++++ b/locale/setlocale.c
+@@ -213,12 +213,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.  */
+@@ -249,17 +302,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 3eced0d027..a7e68729ad 100644
+--- a/string/Makefile
++++ b/string/Makefile
+@@ -51,6 +51,7 @@ routines := \
+   argz-next \
+   argz-replace \
+   argz-stringify \
++  argz-suffix \
+   basename \
+   bcopy \
+   bzero \
+diff --git a/string/argz-suffix.c b/string/argz-suffix.c
+new file mode 100644
+index 0000000000..505b0f248c
+--- /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 cbc588a8e6..bc6e484c9d 100644
+--- a/string/argz.h
++++ b/string/argz.h
+@@ -108,6 +108,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
+-- 
+2.40.1
+