From patchwork Thu May 18 09:38:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janneke Nieuwenhuizen X-Patchwork-Id: 50098 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id CE6F527BBE9; Thu, 18 May 2023 10:40:23 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 0EAF427BBEA for ; Thu, 18 May 2023 10:40:21 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pza7B-0002L0-K4; Thu, 18 May 2023 05:40:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pza79-0002JX-Ui for guix-patches@gnu.org; Thu, 18 May 2023 05:40:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pza79-0006bt-MT for guix-patches@gnu.org; Thu, 18 May 2023 05:40:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pza79-0004JM-Ij for guix-patches@gnu.org; Thu, 18 May 2023 05:40:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63527] [PATCH v4 1/8] gnu: glibc: Update time patches for the Hurd. Resent-From: Janneke Nieuwenhuizen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 18 May 2023 09:40:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63527 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63527@debbugs.gnu.org Received: via spool by 63527-submit@debbugs.gnu.org id=B63527.168440277416449 (code B ref 63527); Thu, 18 May 2023 09:40:03 +0000 Received: (at 63527) by debbugs.gnu.org; 18 May 2023 09:39:34 +0000 Received: from localhost ([127.0.0.1]:52074 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pza6f-0004H8-0J for submit@debbugs.gnu.org; Thu, 18 May 2023 05:39:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47192) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pza6X-0004Fq-IE for 63527@debbugs.gnu.org; Thu, 18 May 2023 05:39:27 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pza6S-0006Lg-8P; Thu, 18 May 2023 05:39:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=UyLneYz2641H4vD6LgVR1i4iE0THdcMQs13U/rzhrgc=; b=WGyF+se8w/M8BU5F5pKZ Wcq950Hug+bwIvrR5dJA17bqifQWPAiRwc7T42YPVXL9UBbcWowpEA3p+T+K+ky8vIQrrJIfzLAHU WMD6/+070/cAOOZmYkvhEK3ixH55ap7KevOAUfPrYqSWNDRL/IPPhSofI41gn9dxn7wLkurM7/dmX 31rLcl/fL2+ZL9ywxXkxrWkjhYrezszIEC2cAIUMqmciA1CJsak6zjOFkhlq5P2vSgSzPN3KQqFI5 OTZunQPGfLAkNSdCKUhJgtQ5J9RPHeGnmBqZWofVbT+7cUv6Qj8RNAm4Szx6yZuTSTUQVFJ+mLpCm BKQsYw3jSG2AgA==; Received: from [2a02:a462:da03:1:2701:7f81:a736:4607] (helo=drakenpad.fritz.box) by fencepost.gnu.org with esmtpa (Exim 4.90_1) (envelope-from ) id 1pza6R-0006zE-RK; Thu, 18 May 2023 05:39:20 -0400 From: Janneke Nieuwenhuizen Date: Thu, 18 May 2023 11:38:56 +0200 Message-Id: <23790bf9a3383c0adf74ec209eb9222c410f667b.1684402361.git.janneke@gnu.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches The previous set of time patches were adapted from the Debian Salsa glibc package git and were needed only to get Python to build. The rumpkernel needs the full versions of those patches, with the current set causes a rumpkernel panic. As discussed/suggested on IRC https://logs.guix.gnu.org/hurd/2023-05-17.log#150916 * gnu/packages/patches/glibc-2.35-hurd-clock_t_centiseconds.patch, gnu/packages/patches/glibc-2.35-hurd-clock_gettime_monotonic.patch: New files. * gnu/packages/cross-base.scm (cross-libc*)[native-inputs]: Add them, together with their incorrect/incomplete already applied versions. [arguments]: Use them in a new patch-libc/hurd phase: revert the incorrect ones and apply the new patches. --- gnu/local.mk | 2 + gnu/packages/cross-base.scm | 34 ++++- ...bc-2.35-hurd-clock_gettime_monotonic.patch | 137 ++++++++++++++++++ ...glibc-2.35-hurd-clock_t_centiseconds.patch | 63 ++++++++ 4 files changed, 233 insertions(+), 3 deletions(-) create mode 100644 gnu/packages/patches/glibc-2.35-hurd-clock_gettime_monotonic.patch create mode 100644 gnu/packages/patches/glibc-2.35-hurd-clock_t_centiseconds.patch diff --git a/gnu/local.mk b/gnu/local.mk index 42514ded8e..c5b3568742 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1233,6 +1233,8 @@ dist_patch_DATA = \ %D%/packages/patches/glib-appinfo-watch.patch \ %D%/packages/patches/glib-networking-gnutls-binding.patch \ %D%/packages/patches/glib-skip-failing-test.patch \ + %D%/packages/patches/glibc-2.35-hurd-clock_gettime_monotonic.patch \ + %D%/packages/patches/glibc-2.35-hurd-clock_t_centiseconds.patch \ %D%/packages/patches/glibc-CVE-2019-7309.patch \ %D%/packages/patches/glibc-CVE-2019-9169.patch \ %D%/packages/patches/glibc-CVE-2019-19126.patch \ diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index 8d0b41180b..c8d1aef814 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -1,7 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013-2018, 2020, 2023 Ludovic Courtès ;;; Copyright © 2014, 2015, 2018 Mark H Weaver -;;; Copyright © 2016, 2019 Jan (janneke) Nieuwenhuizen +;;; Copyright © 2016, 2019, 2023 Janneke Nieuwenhuizen ;;; Copyright © 2016 Manolis Fragkiskos Ragkousis ;;; Copyright © 2018 Tobias Geerinckx-Rice ;;; Copyright © 2019, 2020, 2021 Marius Bakke @@ -624,7 +624,22 @@ (define* (cross-libc* target (("/[^ ]+/lib/libc.so.0.3") (string-append out "/lib/libc.so.0.3" " libmachuser.so libhurduser.so")))) - #t))) + #t)) + ;; TODO: move to glibc in the next rebuild cycle + (add-after 'unpack 'patch-libc/hurd + (lambda* (#:key inputs #:allow-other-keys) + (for-each + (lambda (name) + (let ((patch (assoc-ref inputs name))) + (invoke "patch" "-p1" "--force" "-R" "-i" patch))) + '("hurd-monotonic.patch" + "hurd-centiseconds.patch")) + (for-each + (lambda (name) + (let ((patch (assoc-ref inputs name))) + (invoke "patch" "-p1" "--force" "-i" patch))) + '("2.35-hurd-centiseconds.patch" + "2.35-hurd-monotonic.patch"))))) '()))))) ;; Shadow the native "kernel-headers" because glibc's recipe expects the @@ -637,7 +652,20 @@ (define* (cross-libc* target `(("cross-mig" ,(cross-mig target #:xgcc xgcc - #:xbinutils xbinutils))) + #:xbinutils xbinutils)) + ;; TODO: move to glibc in the next rebuild cycle + ("hurd-monotonic.patch" + ,@(search-patches + "glibc-hurd-clock_gettime_monotonic.patch")) + ("hurd-centiseconds.patch" + ,@(search-patches + "glibc-hurd-clock_t_centiseconds.patch")) + ("2.35-hurd-monotonic.patch" + ,@(search-patches + "glibc-2.35-hurd-clock_gettime_monotonic.patch")) + ("2.35-hurd-centiseconds.patch" + ,@(search-patches + "glibc-2.35-hurd-clock_t_centiseconds.patch"))) '()) ,@(package-inputs libc) ;FIXME: static-bash ,@(package-native-inputs libc)))))) diff --git a/gnu/packages/patches/glibc-2.35-hurd-clock_gettime_monotonic.patch b/gnu/packages/patches/glibc-2.35-hurd-clock_gettime_monotonic.patch new file mode 100644 index 0000000000..05769d61b9 --- /dev/null +++ b/gnu/packages/patches/glibc-2.35-hurd-clock_gettime_monotonic.patch @@ -0,0 +1,137 @@ +Upstream status: taken from upstream: + + https://salsa.debian.org/glibc-team/glibc/-/blob/sid/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.35-hurd-clock_t_centiseconds.patch b/gnu/packages/patches/glibc-2.35-hurd-clock_t_centiseconds.patch new file mode 100644 index 0000000000..c4e9fd5105 --- /dev/null +++ b/gnu/packages/patches/glibc-2.35-hurd-clock_t_centiseconds.patch @@ -0,0 +1,63 @@ +Upstream status: taken from upstream: + + https://salsa.debian.org/glibc-team/glibc/-/blob/sid/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 +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 + +-/* 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