diff mbox series

[bug#54832] update glibc to 2.35

Message ID 935236349.13698.1649553391613@privateemail.com
State Accepted
Headers show
Series [bug#54832] update glibc to 2.35 | expand

Commit Message

zamfofex April 10, 2022, 1:16 a.m. UTC
Hello! I have decided I wanted to work on updating glibc. I tested the updated glibc with the packages ‘hello’, ‘coreutils’, ‘grep’, ‘sed’ and ‘guile’, and they all built successfully!

I have attached the generated ‘git diff’ to this message, and I hope that is fine. If there are any issues, please feel free to let me know!

Comments

M April 10, 2022, 10:16 a.m. UTC | #1
zamfofex schreef op za 09-04-2022 om 22:16 [-0300]:
+                     (define empty-static-libraries '("libpthread.a"
"libdl.a" "libutil.a" "libanl.a"))
+                     (define (empty-static-library? file)
+                       (any (lambda (s) (string=? file s)) empty-
static-libraries))
+
                      (define (static-library? file)
                        ;; Return true if FILE is a static library. 
The
                        ;; "_nonshared.a" files are referred to by
libc.so,
                        ;; libpthread.so, etc., which are in fact
linker
                        ;; scripts.
                        (and (string-suffix? ".a" file)
-                            (not (string-contains file
"_nonshared"))))
+                            (not (string-contains file
"_nonshared"))
+                            (not (empty-static-library? file))))

Why are empty static libraries skipped?  Would "gcc -static -lpthread main.c" (*)
(in an environment that includes glibc:static) still work, or does it now fail?

Greetings,
Maxime.
M April 10, 2022, 10:17 a.m. UTC | #2
zamfofex schreef op za 09-04-2022 om 22:16 [-0300]:
> --- /dev/null
> +++ b/gnu/packages/patches/m4-failing-test-bug.patch
> @@ -0,0 +1,7 @@
> +--- a/tests/test-execute.sh
> ++++ b/tests/test-execute.sh
> +@@ -0,1 +0,3 @@
> +-for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ;
> do
> ++# Test case 5 is disabled because of a bug in Guix whereby
> ++# raising 'SIGINT' does not work as expected.
> ++for i in 0 1 2 3 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ; do
> diff --git a/gnu/packages/patches/m4-shell.patch
> b/gnu/packages/patches/m4-shell.patch
> new file mode 100644
> index 0000000..f10e99f

An explanation and a link to an upstream report is mising.
(apparently upstream=Guix here?).

Greetings,
Maxime.
M April 10, 2022, 10:18 a.m. UTC | #3
zamfofex schreef op za 09-04-2022 om 22:16 [-0300]:
> diff --git a/gnu/packages/patches/m4-shell.patch
> b/gnu/packages/patches/m4-shell.patch
> new file mode 100644
> index 0000000..f10e99f
> --- /dev/null
> +++ b/gnu/packages/patches/m4-shell.patch
> @@ -0,0 +1,16 @@
> +--- a/lib/config.hin
> ++++ b/lib/config.hin
> +@@ -0,12 +0,1 @@
> +-/* File name of the Bourne shell.  */
> +-#if (defined _WIN32 && !defined __CYGWIN__) || defined __CYGWIN__
> || defined __ANDROID__
> +-/* Omit the directory part because
> +-   - For native Windows programs in a Cygwin environment, the
> Cygwin mounts
> +-     are not visible.
> +-   - For 32-bit Cygwin programs in a 64-bit Cygwin environment, the
> Cygwin
> +-     mounts are not visible.
> +-   - On Android, /bin/sh does not exist. It's /system/bin/sh
> instead.  */
> +-# define BOURNE_SHELL "sh"
> +-#else
> +-# define BOURNE_SHELL "/bin/sh"
> +-#endif
> ++# define BOURNE_SHELL "sh"

What's the reason for this patch?

Greetings,
Maxime.
zamfofex April 24, 2022, 2:19 p.m. UTC | #4
> Why are empty static libraries skipped?  Would "gcc -static -lpthread main.c" (*)
> (in an environment that includes glibc:static) still work, or does it now fail?

They are skipped from being moved, but then should be copied in the loop immediately below it.

> An explanation and a link to an upstream report is mising.
> (apparently upstream=Guix here?).

I’m not sure if there is a report yet. There is a conversation in IRC, however. See:

- <https://logs.guix.gnu.org/guix/2022-04-09.log#081848>
- <https://logs.guix.gnu.org/guix/2022-04-09.log#082442>
- <https://logs.guix.gnu.org/guix/2022-04-09.log#171259>
- <https://logs.guix.gnu.org/guix/2022-04-09.log#174339>

> What's the reason for this patch?

‘/bin/sh’ doesn’t seem available in the build environment, so tests were failing. From what I was able to see, that macro is only used in tests, so I didn’t think it would be worthwhile to make it refer to ‘/gnu/store/.../bash’.

- - - - - - -

Apologies to Maxime for the repeated messages, and to others for taking so long to reply. Apparently I hadn’t replied to the debbugs address, so my initial messages were sent only to Maxime.

I hope this can be looked into soon enough!
Ludovic Courtès May 15, 2022, 9:31 p.m. UTC | #5
Hello!

zamfofex <zamfofex@twdb.moe> skribis:

> Hello! I have decided I wanted to work on updating glibc. I tested the updated glibc with the packages ‘hello’, ‘coreutils’, ‘grep’, ‘sed’ and ‘guile’, and they all built successfully!

Yay!

>               (base32
> -              "1zvp0qdfbdyqrzydz18d9zg3n5ygy8ps7cmny1bvsp8h1q05c99f"))
> -            (patches (search-patches "glibc-ldd-powerpc.patch"
> -                                     "glibc-ldd-x86_64.patch"
> -                                     "glibc-dl-cache.patch"

Could you confirm that these patches are no longer needed?

> +                     (define empty-static-libraries '("libpthread.a" "libdl.a" "libutil.a" "libanl.a"))
> +                     (define (empty-static-library? file)
> +                       (any (lambda (s) (string=? file s)) empty-static-libraries))

[...]

>                              (files  (scandir lib static-library?))
> +                            (files2 (scandir lib empty-static-library?))
>                              (static (assoc-ref outputs "static"))
>                              (slib   (string-append static "/lib")))
>                         (mkdir-p slib)
> @@ -876,6 +883,10 @@ (define (linker-script? file)
>                                     (rename-file (string-append lib "/" base)
>                                                  (string-append slib "/" base)))
>                                   files)
> +                       (for-each (lambda (base)
> +                                   (copy-file (string-append lib "/" base)
> +                                              (string-append slib "/" base)))
> +                                 files2)

Like Maxime wrote, this needs comments in the code.

Could you explain why the empty .a files need special treatment?  In the
end, it seems we’re copying them to the “static” output anyway, so why
not let them in ‘files’?

>  (define-public m4
>    (package
>     (name "m4")
> -   (version "1.4.18")
> +   (version "1.4.19")

This should be done in a separate patch.

> +++ b/gnu/packages/patches/m4-failing-test-bug.patch
> @@ -0,0 +1,7 @@
> +--- a/tests/test-execute.sh
> ++++ b/tests/test-execute.sh

Like Maxime wrote, please start the patch with a short comment
explaining what it does, and with a link to the upstream commit or bug
report.

One last thing: could you use ‘git format-patch’ and (optionally) ‘git
send-email’ to send a revised patch?

  https://guix.gnu.org/manual/devel/en/html_node/Submitting-Patches.html

Thanks in advance, and apologies for the delay!

Ludo’.
zamfofex June 6, 2022, 12:06 p.m. UTC | #6
> Could you confirm that these patches are no longer needed?

I don’t remember exactly what my thought process was for removing the ‘glibc-dl-cache’ patch except that it wasn’t applicable anymore. At any rate, I don’t fully understand what the patch is actually doing, so it’s a bit difficult to assess whether it’s still necessary to me. (Help would be appreciated!)

Other than that, I did verify the other two patches, and it seems the regexes they were patching have already been fixed upstream!

> Could you explain why the empty .a files need special treatment?  In the end, it seems we’re copying them to the “static” output anyway, so why not let them in ‘files’?

Those files need to be present in both the ‘static’ and ‘out’ outputs, whereas without considering them specially, they would be moved to the ‘static’ output (with ‘rename-file’ as opposed to ‘copy-file’). Is a comment worthwhile? What should I write? I could explain the change in glibc that made those into empty ‘.a’ files and link to the changelog. Is that enough?

> This should be done in a separate patch.

That is fine. Though I will note that the previous version of m4 did not work with the updated glibc, so I think it would make sense to updated it *before* updating glibc in the commit history. Do I need to verify whether the newer version works with the previous glibc too?

> Like Maxime wrote, please start the patch with a short comment explaining what it does, and with a link to the upstream commit or bug report.

I’m still confused about what I should link to. I can write a comment explaining the issues and link to the IRC conversation we held, or maybe even to this thread. But I don’t think there actually is “an upstream commit or bug report” that I could link to.

> One last thing: could you use ‘git format-patch’ and (optionally) ‘git send-email’ to send a revised patch?

I definitely don’t mind investigating using those tools more carefully! I think I can prepare and send another patch once my questions are clarified.

- - -

Apologies to Maxime and Ludovic for the repeated messages once again and to others for taking so long to respond. I’m still getting familiar with sending emails properly!

At any rate, thank you for looking into it!
Ludovic Courtès July 17, 2022, 10:06 a.m. UTC | #7
Hi!

Sorry for the long delay.

zamfofex <zamfofex@twdb.moe> skribis:

>> Could you confirm that these patches are no longer needed?
>
> I don’t remember exactly what my thought process was for removing the ‘glibc-dl-cache’ patch except that it wasn’t applicable anymore. At any rate, I don’t fully understand what the patch is actually doing, so it’s a bit difficult to assess whether it’s still necessary to me. (Help would be appreciated!)

There’s a comment at the top of ‘glibc-dl-cache.patch’ that explains
what it does, but see
<https://guix.gnu.org/en/blog/2021/taming-the-stat-storm-with-a-loader-cache/>
for details.  I can take a look and update it.

> Other than that, I did verify the other two patches, and it seems the regexes they were patching have already been fixed upstream!

Great.

>> Could you explain why the empty .a files need special treatment?  In the end, it seems we’re copying them to the “static” output anyway, so why not let them in ‘files’?
>
> Those files need to be present in both the ‘static’ and ‘out’ outputs,

Why?

> whereas without considering them specially, they would be moved to the
> ‘static’ output (with ‘rename-file’ as opposed to ‘copy-file’). Is a
> comment worthwhile? What should I write? I could explain the change in
> glibc that made those into empty ‘.a’ files and link to the
> changelog. Is that enough?

We’d need a comment like “Keep empty .a files in OUT in addition to
STATIC because …”.

>> This should be done in a separate patch.
>
> That is fine. Though I will note that the previous version of m4 did not work with the updated glibc, so I think it would make sense to updated it *before* updating glibc in the commit history. Do I need to verify whether the newer version works with the previous glibc too?

Ideally yes.

>> Like Maxime wrote, please start the patch with a short comment explaining what it does, and with a link to the upstream commit or bug report.
>
> I’m still confused about what I should link to. I can write a comment explaining the issues and link to the IRC conversation we held, or maybe even to this thread. But I don’t think there actually is “an upstream commit or bug report” that I could link to.

When applying a patch to a package, we seek to document the reason why
we’re doing it, to ease maintenance; usually, patches come from a bug
report or from a change upstream, so we would like to it.

>> One last thing: could you use ‘git format-patch’ and (optionally) ‘git send-email’ to send a revised patch?
>
> I definitely don’t mind investigating using those tools more carefully! I think I can prepare and send another patch once my questions are clarified.

Perfect.  I realize upgrading glibc is a rather tricky task, so thanks
for giving it a try!  Surely we can team up to get it past the finish
line.

Thanks!

Ludo’.
diff mbox series

Patch

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 72329db..f2a0814 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -20,6 +20,7 @@ 
 ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2022 zamfofex <zamfofex@twdb.moe>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -694,16 +695,14 @@  (define-public glibc
   ;; version 2.28, GNU/Hurd used a different glibc branch.
   (package
    (name "glibc")
-   (version "2.33")
+   (version "2.35")
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
             (sha256
              (base32
-              "1zvp0qdfbdyqrzydz18d9zg3n5ygy8ps7cmny1bvsp8h1q05c99f"))
-            (patches (search-patches "glibc-ldd-powerpc.patch"
-                                     "glibc-ldd-x86_64.patch"
-                                     "glibc-dl-cache.patch"
+              "0bpm1kfi09dxl4c6aanc5c9951fmf6ckkzay60cx7k37dcpp68si"))
+            (patches (search-patches "glibc-dl-cache.patch"
                                      "glibc-versioned-locpath.patch"
                                      "glibc-allow-kernel-2.6.32.patch"
                                      "glibc-reinstate-prlimit64-fallback.patch"
@@ -738,6 +737,7 @@  (define-public glibc
       #:validate-runpath? #f
 
       #:modules ((ice-9 ftw)
+                 (srfi srfi-1)
                  (srfi srfi-26)
                  (guix build utils)
                  (guix build gnu-build-system))
@@ -852,13 +852,19 @@  (define-public glibc
                  (add-after 'install 'move-static-libs
                    (lambda* (#:key outputs #:allow-other-keys)
                      ;; Move static libraries to the "static" output.
+
+                     (define empty-static-libraries '("libpthread.a" "libdl.a" "libutil.a" "libanl.a"))
+                     (define (empty-static-library? file)
+                       (any (lambda (s) (string=? file s)) empty-static-libraries))
+
                      (define (static-library? file)
                        ;; Return true if FILE is a static library.  The
                        ;; "_nonshared.a" files are referred to by libc.so,
                        ;; libpthread.so, etc., which are in fact linker
                        ;; scripts.
                        (and (string-suffix? ".a" file)
-                            (not (string-contains file "_nonshared"))))
+                            (not (string-contains file "_nonshared"))
+                            (not (empty-static-library? file))))
 
                      (define (linker-script? file)
                        ;; Guess whether FILE, a ".a" file, is actually a
@@ -869,6 +875,7 @@  (define (linker-script? file)
                      (let* ((out    (assoc-ref outputs "out"))
                             (lib    (string-append out "/lib"))
                             (files  (scandir lib static-library?))
+                            (files2 (scandir lib empty-static-library?))
                             (static (assoc-ref outputs "static"))
                             (slib   (string-append static "/lib")))
                        (mkdir-p slib)
@@ -876,6 +883,10 @@  (define (linker-script? file)
                                    (rename-file (string-append lib "/" base)
                                                 (string-append slib "/" base)))
                                  files)
+                       (for-each (lambda (base)
+                                   (copy-file (string-append lib "/" base)
+                                              (string-append slib "/" base)))
+                                 files2)
 
                        ;; Usually libm.a is a linker script so we need to
                        ;; change the file names in there to refer to STATIC
diff --git a/gnu/packages/m4.scm b/gnu/packages/m4.scm
index 090f557..e209494 100644
--- a/gnu/packages/m4.scm
+++ b/gnu/packages/m4.scm
@@ -1,6 +1,7 @@ 
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2022 zamfofex <zamfofex@twdb.moe>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -27,15 +28,17 @@  (define-module (gnu packages m4)
 (define-public m4
   (package
    (name "m4")
-   (version "1.4.18")
+   (version "1.4.19")
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://gnu/m4/m4-"
                                 version ".tar.xz"))
-            (patches (search-patches "m4-gnulib-libio.patch"))
+            (patches (search-patches
+                      "m4-shell.patch"
+                      "m4-failing-test-bug.patch"))
             (sha256
              (base32
-              "01sfjd5a4waqw83bibvmn522g69qfqvwig9i2qlgy154l1nfihgj"))))
+              "15mghcksh11saylpm86h1zkz4in0rbi0pk8i6nqxkdikdmfdxbk3"))))
    (build-system gnu-build-system)
    (arguments
     `(;; Explicitly disable tests when cross-compiling, otherwise 'make check'
diff --git a/gnu/packages/patches/glibc-hurd-clock_gettime_monotonic.patch b/gnu/packages/patches/glibc-hurd-clock_gettime_monotonic.patch
index e31f99a..b022155 100644
--- a/gnu/packages/patches/glibc-hurd-clock_gettime_monotonic.patch
+++ b/gnu/packages/patches/glibc-hurd-clock_gettime_monotonic.patch
@@ -67,8 +67,8 @@  index fcd79fd554..1dd02aa449 100644
  
 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
+--- a/rt/timer_create.c
++++ b/rt/timer_create.c
 @@ -48,7 +48,7 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid)
        return -1;
      }
diff --git a/gnu/packages/patches/m4-failing-test-bug.patch b/gnu/packages/patches/m4-failing-test-bug.patch
new file mode 100644
index 0000000..39f11c1
--- /dev/null
+++ b/gnu/packages/patches/m4-failing-test-bug.patch
@@ -0,0 +1,7 @@ 
+--- a/tests/test-execute.sh
++++ b/tests/test-execute.sh
+@@ -0,1 +0,3 @@
+-for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ; do
++# Test case 5 is disabled because of a bug in Guix whereby
++# raising 'SIGINT' does not work as expected.
++for i in 0 1 2 3 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ; do
diff --git a/gnu/packages/patches/m4-shell.patch b/gnu/packages/patches/m4-shell.patch
new file mode 100644
index 0000000..f10e99f
--- /dev/null
+++ b/gnu/packages/patches/m4-shell.patch
@@ -0,0 +1,16 @@ 
+--- a/lib/config.hin
++++ b/lib/config.hin
+@@ -0,12 +0,1 @@
+-/* File name of the Bourne shell.  */
+-#if (defined _WIN32 && !defined __CYGWIN__) || defined __CYGWIN__ || defined __ANDROID__
+-/* Omit the directory part because
+-   - For native Windows programs in a Cygwin environment, the Cygwin mounts
+-     are not visible.
+-   - For 32-bit Cygwin programs in a 64-bit Cygwin environment, the Cygwin
+-     mounts are not visible.
+-   - On Android, /bin/sh does not exist. It's /system/bin/sh instead.  */
+-# define BOURNE_SHELL "sh"
+-#else
+-# define BOURNE_SHELL "/bin/sh"
+-#endif
++# define BOURNE_SHELL "sh"