Subject: bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy

From: Paul Eggert <[email-masked]>
Date: Mon, 28 Feb 2022 13:47:03 -0800

On 2/28/22 00:59, Lars Ingebrigtsen wrote:
> /usr/bin/ld: gnutls.o: in function `gnutls_try_handshake':
> /home/larsi/src/emacs/trunk/src/gnutls.c:634: undefined reference to `rpl_nanosleep'

Evidently my recent workarounds in Emacs to handle running gnulib-tool 
from a bare checkout were not sufficient. I installed the attached patch 
to up the ante; please give it a try.

It is unfortunate that emacs/admin/merge-gnulib now runs gnulib-tool 
twice from a bare checkout, as gnulib-tool is quite slow.

I think gnulib-tool needs to run twice because it builds 
emacs/lib/gnulib.mk.in before it builds emacs/m4/gnulib-comp.m4, and so 
doesn't use the newly-added emacs/m4/nanosleep.m4 to figure out the new 
X=@X@ lines that needed to be added to emacs/lib/gnulib.mk.in. I suspect 
that this is related to Emacs's using Gnu Make rather than Automake. 
However, I haven't debugged this out.

From d150eb438baa62ef3965ef4dc1f9f342ed839a18 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Mon, 28 Feb 2022 13:16:44 -0800
Subject: [PATCH] Work around merge-gnulib glitch from fresh checkout

* admin/merge-gnulib: In a fresh checkout, run gnulib-tool
twice, instead of merely running autogen.sh twice.
---
 admin/merge-gnulib | 54 +++++++++++++++++++++++++++-------------------
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index fec469c017..7219fadd47 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -102,34 +102,44 @@ gnulib_srcdir=
   exit 1
 }
 
-# gnulib-tool has problems with a bare checkout (Bug#32452#65).
-test -f configure || ./autogen.sh || exit
-
 # Old caches can confuse autoconf when some Gnulib-related changes take effect.
 rm -fr autom4te.cache || exit
 
+# gnulib-tool has problems with a bare checkout (Bug#32452#91).
+if test -f configure; then
+  passes='1'
+else
+  passes='1 2'
+fi
+
 avoided_flags=
 for module in $AVOIDED_MODULES; do
   avoided_flags="$avoided_flags --avoid=$module"
 done
 
-"$gnulib_srcdir"/gnulib-tool --dir="$src" $GNULIB_TOOL_FLAGS \
+for pass in $passes; do
+  case $pass in
+    2) echo 'Running gnulib-tool again to work around Bug#32452#91.' >&2
+  esac
+
+  "$gnulib_srcdir"/gnulib-tool --dir="$src" $GNULIB_TOOL_FLAGS \
 	$avoided_flags $GNULIB_MODULES &&
-rm -- "$src"lib/gl_openssl.h \
-      "$src"lib/stdio-read.c "$src"lib/stdio-write.c \
-      "$src"m4/fcntl-o.m4 \
-      "$src"m4/gl-openssl.m4 \
-      "$src"m4/gnulib-cache.m4 "$src"m4/gnulib-tool.m4 \
-      "$src"m4/manywarnings-c++.m4 \
-      "$src"m4/warn-on-use.m4 "$src"m4/wint_t.m4 &&
-cp -- "$gnulib_srcdir"/build-aux/texinfo.tex "$src"doc/misc &&
-cp -- "$gnulib_srcdir"/build-aux/config.guess \
-      "$gnulib_srcdir"/build-aux/config.sub \
-      "$gnulib_srcdir"/build-aux/install-sh \
-      "$gnulib_srcdir"/build-aux/move-if-change \
-   "$src"build-aux &&
-cp -- "$gnulib_srcdir"/lib/af_alg.h \
-      "$gnulib_srcdir"/lib/save-cwd.h \
-   "$src"lib &&
-{ test -z "$src" || cd "$src"; } &&
-./autogen.sh
+  rm -- "$src"lib/gl_openssl.h \
+	"$src"lib/stdio-read.c "$src"lib/stdio-write.c \
+	"$src"m4/fcntl-o.m4 \
+	"$src"m4/gl-openssl.m4 \
+	"$src"m4/gnulib-cache.m4 "$src"m4/gnulib-tool.m4 \
+	"$src"m4/manywarnings-c++.m4 \
+	"$src"m4/warn-on-use.m4 "$src"m4/wint_t.m4 &&
+  cp -- "$gnulib_srcdir"/build-aux/texinfo.tex "$src"doc/misc &&
+  cp -- "$gnulib_srcdir"/build-aux/config.guess \
+	"$gnulib_srcdir"/build-aux/config.sub \
+	"$gnulib_srcdir"/build-aux/install-sh \
+	"$gnulib_srcdir"/build-aux/move-if-change \
+     "$src"build-aux &&
+  cp -- "$gnulib_srcdir"/lib/af_alg.h \
+	"$gnulib_srcdir"/lib/save-cwd.h \
+     "$src"lib &&
+  { test -z "$src" || cd "$src"; } &&
+  ./autogen.sh || exit
+done
-- 
2.32.0