unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46965: 28.0.50; unexec does not build (or work)
@ 2021-03-06 14:01 Pip Cet
  2021-03-06 19:07 ` Pip Cet
  2022-06-20  1:27 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: Pip Cet @ 2021-03-06 14:01 UTC (permalink / raw)
  To: 46965

On this Debian-based x86_64-pc-linux-gnu system, configuring with
--with-dumping=unexec results in various errors:

1. a compilation error in pdumper.c. Easy to fix, my fault, but then there's ...
2. a segfault when running the dumped image. The problem is we can't
use glibc's malloc when running a dumped image, so we need to force
use of hybrid malloc. But then...
3. gnulib no longer builds with hybrid malloc. To do so requires some
massaging of the gnulib files, but then...
4. gnulib redirects free() to always point to the glibc free(), even
when Emacs wants to override it for hybrid malloc. To fix this, we
need to rerun gnulib-tool.

(1) tells me it's very unlikely anyone but me has tried to build
unexec Emacs lately. The other bugs tell me that it's getting rapidly
more difficult to support unexec build.

But unexec does provide performance advantages over pdumper, and even
over undumped builds.

So, do we want to keep it as an option? RMS said so in

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=36649;msg=77

So I'm opening this bug for discussion, and to post the patches I need
to make unexec work again.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#46965: 28.0.50; unexec does not build (or work)
  2021-03-06 14:01 bug#46965: 28.0.50; unexec does not build (or work) Pip Cet
@ 2021-03-06 19:07 ` Pip Cet
  2021-03-06 20:04   ` Eli Zaretskii
  2022-06-20  1:27 ` Lars Ingebrigtsen
  1 sibling, 1 reply; 5+ messages in thread
From: Pip Cet @ 2021-03-06 19:07 UTC (permalink / raw)
  To: 46965

[-- Attachment #1: Type: text/plain, Size: 393 bytes --]

On Sat, Mar 6, 2021 at 2:03 PM Pip Cet <pipcet@gmail.com> wrote:
> But unexec does provide performance advantages over pdumper, and even
> over undumped builds.

That, by the way, is because of pure space.

Here's the patch to make unexec build. Note that this patch removes
the free() wrapper from lib/, so if your libc's free() is broken and
sets errno, that bug will be once again exposed.

[-- Attachment #2: 0001-fix-build-with-dumping-unexec.patch --]
[-- Type: text/x-patch, Size: 38365 bytes --]

From fac8c273a0b12790e6202f6ddaf91167685ec699 Mon Sep 17 00:00:00 2001
From: Pip Cet <pipcet@gmail.com>
Date: Fri, 5 Mar 2021 19:30:40 +0000
Subject: [PATCH] fix build with --dumping=unexec

---
 configure.ac                |   2 +-
 lib/Makefile.in             |   2 +-
 lib/gl_openssl.h            | 116 +++++++++++++++
 lib/gnulib.mk.in            |   4 +-
 lisp/emacs-lisp/bytecomp.el |   2 +-
 m4/fcntl-o.m4               | 140 ++++++++++++++++++
 m4/gl-openssl.m4            |  66 +++++++++
 m4/gnulib-cache.m4          | 282 ++++++++++++++++++++++++++++++++++++
 m4/gnulib-comp.m4           |  23 ++-
 m4/gnulib-tool.m4           |  57 ++++++++
 m4/manywarnings-c++.m4      | 243 +++++++++++++++++++++++++++++++
 m4/warn-on-use.m4           |  49 +++++++
 m4/wint_t.m4                |  57 ++++++++
 src/pdumper.c               |   6 +-
 14 files changed, 1037 insertions(+), 12 deletions(-)
 create mode 100644 lib/gl_openssl.h
 create mode 100644 m4/fcntl-o.m4
 create mode 100644 m4/gl-openssl.m4
 create mode 100644 m4/gnulib-cache.m4
 create mode 100644 m4/gnulib-tool.m4
 create mode 100644 m4/manywarnings-c++.m4
 create mode 100644 m4/warn-on-use.m4
 create mode 100644 m4/wint_t.m4

diff --git a/configure.ac b/configure.ac
index 11a06a39bee3f..835307ac477dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2288,7 +2288,7 @@ AC_DEFUN
 case "$opsys" in
   ## darwin ld insists on the use of malloc routines in the System framework.
   darwin | mingw32 | nacl | solaris) ;;
-  cygwin | qnxnto | freebsd)
+  cygwin | qnxnto | freebsd | gnu-linux )
 	  hybrid_malloc=yes
           system_malloc= ;;
   *) test "$ac_cv_func_sbrk" = yes && system_malloc=$emacs_cv_sanitize_address;;
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 91a6b5ff3f16e..a3021150aec1b 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -87,7 +87,7 @@ not_emacs_OBJECTS =
 libgnu_a_OBJECTS = fingerprint.o $(gl_LIBOBJS) \
   $(patsubst %.c,%.o,$(filter %.c,$(libgnu_a_SOURCES)))
 for_emacs_OBJECTS = $(filter-out $(not_emacs_OBJECTS),$(libgnu_a_OBJECTS))
-libegnu_a_OBJECTS = $(patsubst %.o,e-%.o,$(for_emacs_OBJECTS))
+libegnu_a_OBJECTS = $(patsubst e-malloc/%,malloc/e-%,$(patsubst %.o,e-%.o,$(for_emacs_OBJECTS)))
 
 $(libegnu_a_OBJECTS) $(libgnu_a_OBJECTS): $(BUILT_SOURCES)
 
diff --git a/lib/gl_openssl.h b/lib/gl_openssl.h
new file mode 100644
index 0000000000000..6c9b70a587777
--- /dev/null
+++ b/lib/gl_openssl.h
@@ -0,0 +1,116 @@
+/* Wrap openssl crypto hash routines in gnulib interface.  -*- coding: utf-8 -*-
+
+   Copyright (C) 2013-2021 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program 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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Pádraig Brady */
+
+#ifndef GL_OPENSSL_NAME
+# error "Please define GL_OPENSSL_NAME to 1,5,256 etc."
+#endif
+
+#ifndef _GL_INLINE_HEADER_BEGIN
+# error "Please include config.h first."
+#endif
+_GL_INLINE_HEADER_BEGIN
+#ifndef GL_OPENSSL_INLINE
+# define GL_OPENSSL_INLINE _GL_INLINE
+#endif
+
+/* Concatenate two preprocessor tokens.  */
+#define _GLCRYPTO_CONCAT_(prefix, suffix) prefix##suffix
+#define _GLCRYPTO_CONCAT(prefix, suffix) _GLCRYPTO_CONCAT_ (prefix, suffix)
+
+#if GL_OPENSSL_NAME == 5
+# define OPENSSL_ALG md5
+#else
+# define OPENSSL_ALG _GLCRYPTO_CONCAT (sha, GL_OPENSSL_NAME)
+#endif
+
+/* Context type mappings.  */
+#if BASE_OPENSSL_TYPE != GL_OPENSSL_NAME
+# undef BASE_OPENSSL_TYPE
+# if GL_OPENSSL_NAME == 224
+#  define BASE_OPENSSL_TYPE 256
+# elif GL_OPENSSL_NAME == 384
+#  define BASE_OPENSSL_TYPE 512
+# endif
+# define md5_CTX MD5_CTX
+# define sha1_CTX SHA_CTX
+# define sha224_CTX SHA256_CTX
+# define sha224_ctx sha256_ctx
+# define sha256_CTX SHA256_CTX
+# define sha384_CTX SHA512_CTX
+# define sha384_ctx sha512_ctx
+# define sha512_CTX SHA512_CTX
+# undef _gl_CTX
+# undef _gl_ctx
+# define _gl_CTX _GLCRYPTO_CONCAT (OPENSSL_ALG, _CTX) /* openssl type.  */
+# define _gl_ctx _GLCRYPTO_CONCAT (OPENSSL_ALG, _ctx) /* gnulib type.  */
+
+struct _gl_ctx { _gl_CTX CTX; };
+#endif
+
+/* Function name mappings.  */
+#define md5_prefix MD5
+#define sha1_prefix SHA1
+#define sha224_prefix SHA224
+#define sha256_prefix SHA256
+#define sha384_prefix SHA384
+#define sha512_prefix SHA512
+#define _GLCRYPTO_PREFIX _GLCRYPTO_CONCAT (OPENSSL_ALG, _prefix)
+#define OPENSSL_FN(suffix) _GLCRYPTO_CONCAT (_GLCRYPTO_PREFIX, suffix)
+#define GL_CRYPTO_FN(suffix) _GLCRYPTO_CONCAT (OPENSSL_ALG, suffix)
+
+GL_OPENSSL_INLINE void
+GL_CRYPTO_FN (_init_ctx) (struct _gl_ctx *ctx)
+{ (void) OPENSSL_FN (_Init) ((_gl_CTX *) ctx); }
+
+/* These were never exposed by gnulib.  */
+#if ! (GL_OPENSSL_NAME == 224 || GL_OPENSSL_NAME == 384)
+GL_OPENSSL_INLINE void
+GL_CRYPTO_FN (_process_bytes) (const void *buf, size_t len, struct _gl_ctx *ctx)
+{ OPENSSL_FN (_Update) ((_gl_CTX *) ctx, buf, len); }
+
+GL_OPENSSL_INLINE void
+GL_CRYPTO_FN (_process_block) (const void *buf, size_t len, struct _gl_ctx *ctx)
+{ GL_CRYPTO_FN (_process_bytes) (buf, len, ctx); }
+#endif
+
+GL_OPENSSL_INLINE void *
+GL_CRYPTO_FN (_finish_ctx) (struct _gl_ctx *ctx, void *restrict res)
+{ OPENSSL_FN (_Final) ((unsigned char *) res, (_gl_CTX *) ctx); return res; }
+
+GL_OPENSSL_INLINE void *
+GL_CRYPTO_FN (_buffer) (const char *buf, size_t len, void *restrict res)
+{ return OPENSSL_FN () ((const unsigned char *) buf, len, (unsigned char *) res); }
+
+GL_OPENSSL_INLINE void *
+GL_CRYPTO_FN (_read_ctx) (const struct _gl_ctx *ctx, void *restrict res)
+{
+  /* Assume any unprocessed bytes in ctx are not to be ignored.  */
+  _gl_CTX tmp_ctx = *(_gl_CTX *) ctx;
+  OPENSSL_FN (_Final) ((unsigned char *) res, &tmp_ctx);
+  return res;
+}
+
+/* Undef so we can include multiple times.  */
+#undef GL_CRYPTO_FN
+#undef OPENSSL_FN
+#undef _GLCRYPTO_PREFIX
+#undef OPENSSL_ALG
+#undef GL_OPENSSL_NAME
+
+_GL_INLINE_HEADER_END
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 07736f9b8bc55..2b66dd47daa2a 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -103,7 +103,6 @@
 #  filevercmp \
 #  flexmember \
 #  fpieee \
-#  free-posix \
 #  fstatat \
 #  fsusage \
 #  fsync \
@@ -1221,6 +1220,7 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -1840,7 +1840,9 @@ endif
 ## begin gnulib module free-posix
 ifeq (,$(OMIT_GNULIB_MODULE_free-posix))
 
+ifneq (,$(gl_GNULIB_ENABLED_ef07dc4b3077c11ea9cef586db4e5955))
 
+endif
 EXTRA_DIST += free.c
 
 EXTRA_libgnu_a_SOURCES += free.c
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 4e00fe6121e82..a73bce61d248e 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -5225,7 +5225,7 @@ byte-compile-refresh-preloaded
   "Reload any Lisp file that was changed since Emacs was dumped.
 Use with caution."
   (let* ((argv0 (car command-line-args))
-         (emacs-file (or (cdr (nth 2 (pdumper-stats)))
+         (emacs-file (or (ignore-errors (cdr (nth 2 (pdumper-stats))))
                          (executable-find argv0))))
     (if (not (and emacs-file (file-exists-p emacs-file)))
         (message "Can't find %s to refresh preloaded Lisp files" argv0)
diff --git a/m4/fcntl-o.m4 b/m4/fcntl-o.m4
new file mode 100644
index 0000000000000..7c459ad13a708
--- /dev/null
+++ b/m4/fcntl-o.m4
@@ -0,0 +1,140 @@
+# fcntl-o.m4 serial 7
+dnl Copyright (C) 2006, 2009-2021 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Written by Paul Eggert.
+
+AC_PREREQ([2.60])
+
+# Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
+# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
+# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
+AC_DEFUN([gl_FCNTL_O_FLAGS],
+[
+  dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CHECK_HEADERS_ONCE([unistd.h])
+  AC_CHECK_FUNCS_ONCE([symlink])
+  AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
+    [AC_RUN_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <sys/types.h>
+           #include <sys/stat.h>
+           #if HAVE_UNISTD_H
+           # include <unistd.h>
+           #else /* on Windows with MSVC */
+           # include <io.h>
+           # include <stdlib.h>
+           # defined sleep(n) _sleep ((n) * 1000)
+           #endif
+           #include <fcntl.h>
+           ]GL_MDA_DEFINES[
+           #ifndef O_NOATIME
+            #define O_NOATIME 0
+           #endif
+           #ifndef O_NOFOLLOW
+            #define O_NOFOLLOW 0
+           #endif
+           static int const constants[] =
+            {
+              O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
+              O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
+            };
+          ]],
+          [[
+            int result = !constants;
+            #if HAVE_SYMLINK
+            {
+              static char const sym[] = "conftest.sym";
+              if (symlink ("/dev/null", sym) != 0)
+                result |= 2;
+              else
+                {
+                  int fd = open (sym, O_WRONLY | O_NOFOLLOW | O_CREAT, 0);
+                  if (fd >= 0)
+                    {
+                      close (fd);
+                      result |= 4;
+                    }
+                }
+              if (unlink (sym) != 0 || symlink (".", sym) != 0)
+                result |= 2;
+              else
+                {
+                  int fd = open (sym, O_RDONLY | O_NOFOLLOW);
+                  if (fd >= 0)
+                    {
+                      close (fd);
+                      result |= 4;
+                    }
+                }
+              unlink (sym);
+            }
+            #endif
+            {
+              static char const file[] = "confdefs.h";
+              int fd = open (file, O_RDONLY | O_NOATIME);
+              if (fd < 0)
+                result |= 8;
+              else
+                {
+                  struct stat st0;
+                  if (fstat (fd, &st0) != 0)
+                    result |= 16;
+                  else
+                    {
+                      char c;
+                      sleep (1);
+                      if (read (fd, &c, 1) != 1)
+                        result |= 24;
+                      else
+                        {
+                          if (close (fd) != 0)
+                            result |= 32;
+                          else
+                            {
+                              struct stat st1;
+                              if (stat (file, &st1) != 0)
+                                result |= 40;
+                              else
+                                if (st0.st_atime != st1.st_atime)
+                                  result |= 64;
+                            }
+                        }
+                    }
+                }
+            }
+            return result;]])],
+       [gl_cv_header_working_fcntl_h=yes],
+       [case $? in #(
+        4) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
+        64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
+        68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
+         *) gl_cv_header_working_fcntl_h='no';;
+        esac],
+       [case "$host_os" in
+                  # Guess 'no' on native Windows.
+          mingw*) gl_cv_header_working_fcntl_h='no' ;;
+          *)      gl_cv_header_working_fcntl_h=cross-compiling ;;
+        esac
+       ])
+    ])
+
+  case $gl_cv_header_working_fcntl_h in #(
+  *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
+  *) ac_val=1;;
+  esac
+  AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
+    [Define to 1 if O_NOATIME works.])
+
+  case $gl_cv_header_working_fcntl_h in #(
+  *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
+  *) ac_val=1;;
+  esac
+  AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
+    [Define to 1 if O_NOFOLLOW works.])
+])
diff --git a/m4/gl-openssl.m4 b/m4/gl-openssl.m4
new file mode 100644
index 0000000000000..96a7268a27966
--- /dev/null
+++ b/m4/gl-openssl.m4
@@ -0,0 +1,66 @@
+# gl-openssl.m4 serial 5
+dnl Copyright (C) 2013-2021 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_SET_CRYPTO_CHECK_DEFAULT],
+[
+  m4_define([gl_CRYPTO_CHECK_DEFAULT], [$1])
+])
+gl_SET_CRYPTO_CHECK_DEFAULT([no])
+
+AC_DEFUN([gl_CRYPTO_CHECK],
+[
+  dnl gnulib users set this before gl_INIT with gl_SET_CRYPTO_CHECK_DEFAULT()
+  m4_divert_once([DEFAULTS], [with_openssl_default='gl_CRYPTO_CHECK_DEFAULT'])
+
+  dnl Only clear once, so crypto routines can be checked for individually
+  m4_divert_once([DEFAULTS], [LIB_CRYPTO=])
+
+  AC_ARG_WITH([openssl],
+    [AS_HELP_STRING([--with-openssl],
+      [use libcrypto hash routines. Valid ARGs are:
+       'yes', 'no',
+       'auto' => use if any version available,
+       'auto-gpl-compat' => use if gpl compatible version available,
+       'optional' => use if available and warn if not available;
+       default is ']gl_CRYPTO_CHECK_DEFAULT['.
+       Note also --with-linux-crypto, which will enable
+       use of kernel crypto routines, which have precedence])],
+    [],
+    [with_openssl=$with_openssl_default])
+
+  AC_SUBST([LIB_CRYPTO])
+  if test "x$with_openssl" != xno; then
+    if test "x$with_openssl" = xauto-gpl-compat; then
+      AC_CACHE_CHECK([whether openssl is GPL compatible],
+                     [gl_cv_openssl_gpl_compat],
+        [AC_COMPILE_IFELSE(
+           [AC_LANG_PROGRAM([[
+                #include <openssl/opensslv.h>
+                #if OPENSSL_VERSION_MAJOR < 3
+                  #error "openssl >= version 3 not found"
+                #endif
+              ]])],
+           [gl_cv_openssl_gpl_compat=yes],
+           [gl_cv_openssl_gpl_compat=no])])
+    fi
+    if test "x$with_openssl" != xauto-gpl-compat ||
+       test "x$gl_cv_openssl_gpl_compat" = xyes; then
+      AC_CHECK_LIB([crypto], [$1],
+        [AC_CHECK_HEADERS(
+           m4_if([$1], [MD5], [openssl/md5.h], [openssl/sha.h]),
+           [LIB_CRYPTO=-lcrypto
+            AC_DEFINE([HAVE_OPENSSL_$1], [1],
+              [Define to 1 if libcrypto is used for $1.])])])
+    fi
+    if test "x$LIB_CRYPTO" = x; then
+      if test "x$with_openssl" = xyes; then
+        AC_MSG_ERROR([openssl development library not found for $1])
+      elif test "x$with_openssl" = xoptional; then
+        AC_MSG_WARN([openssl development library not found for $1])
+      fi
+    fi
+  fi
+])
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
new file mode 100644
index 0000000000000..7375cae006b2a
--- /dev/null
+++ b/m4/gnulib-cache.m4
@@ -0,0 +1,282 @@
+# Copyright (C) 2002-2021 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <https://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License,
+# this file may be distributed as part of a program that
+# contains a configuration script generated by Autoconf, under
+# the same distribution terms as the rest of that program.
+#
+# Generated by gnulib-tool.
+#
+# This file represents the specification of how gnulib-tool is used.
+# It acts as a cache: It is written and read by gnulib-tool.
+# In projects that use version control, this file is meant to be put under
+# version control, like the configure.ac and various Makefile.am files.
+
+
+# Specification in the form of a command-line invocation:
+# gnulib-tool --import \
+#  --lib=libgnu \
+#  --source-base=lib \
+#  --m4-base=m4 \
+#  --doc-base=doc \
+#  --tests-base=tests \
+#  --aux-dir=build-aux \
+#  --gnu-make \
+#  --makefile-name=gnulib.mk.in \
+#  --conditional-dependencies \
+#  --no-libtool \
+#  --macro-prefix=gl \
+#  --no-vc-files \
+#  --avoid=btowc \
+#  --avoid=close \
+#  --avoid=dup \
+#  --avoid=fchdir \
+#  --avoid=fstat \
+#  --avoid=langinfo \
+#  --avoid=lock \
+#  --avoid=malloc-posix \
+#  --avoid=mbrtowc \
+#  --avoid=mbsinit \
+#  --avoid=memchr \
+#  --avoid=mkdir \
+#  --avoid=msvc-inval \
+#  --avoid=msvc-nothrow \
+#  --avoid=nl_langinfo \
+#  --avoid=openat-die \
+#  --avoid=opendir \
+#  --avoid=pthread-h \
+#  --avoid=raise \
+#  --avoid=save-cwd \
+#  --avoid=select \
+#  --avoid=setenv \
+#  --avoid=sigprocmask \
+#  --avoid=stat \
+#  --avoid=stdarg \
+#  --avoid=stdbool \
+#  --avoid=threadlib \
+#  --avoid=tzset \
+#  --avoid=unsetenv \
+#  --avoid=utime \
+#  --avoid=utime-h \
+#  --avoid=wchar \
+#  --avoid=wcrtomb \
+#  --avoid=wctype-h \
+#  alloca-opt \
+#  binary-io \
+#  byteswap \
+#  c-ctype \
+#  c-strcase \
+#  canonicalize-lgpl \
+#  careadlinkat \
+#  close-stream \
+#  copy-file-range \
+#  count-leading-zeros \
+#  count-one-bits \
+#  count-trailing-zeros \
+#  crypto/md5-buffer \
+#  crypto/sha1-buffer \
+#  crypto/sha256-buffer \
+#  crypto/sha512-buffer \
+#  d-type \
+#  diffseq \
+#  double-slash-root \
+#  dtoastr \
+#  dtotimespec \
+#  dup2 \
+#  environ \
+#  execinfo \
+#  explicit_bzero \
+#  faccessat \
+#  fchmodat \
+#  fcntl \
+#  fcntl-h \
+#  fdopendir \
+#  filemode \
+#  filename \
+#  filevercmp \
+#  flexmember \
+#  fpieee \
+#  fstatat \
+#  fsusage \
+#  fsync \
+#  futimens \
+#  getloadavg \
+#  getopt-gnu \
+#  getrandom \
+#  gettime \
+#  gettimeofday \
+#  gitlog-to-changelog \
+#  ieee754-h \
+#  ignore-value \
+#  intprops \
+#  largefile \
+#  libgmp \
+#  lstat \
+#  manywarnings \
+#  memmem-simple \
+#  mempcpy \
+#  memrchr \
+#  minmax \
+#  mkostemp \
+#  mktime \
+#  nstrftime \
+#  pathmax \
+#  pipe2 \
+#  pselect \
+#  pthread_sigmask \
+#  qcopy-acl \
+#  readlink \
+#  readlinkat \
+#  regex \
+#  sig2str \
+#  sigdescr_np \
+#  socklen \
+#  stat-time \
+#  std-gnu11 \
+#  stdalign \
+#  stddef \
+#  stdio \
+#  stpcpy \
+#  strnlen \
+#  strtoimax \
+#  symlink \
+#  sys_stat \
+#  sys_time \
+#  tempname \
+#  time \
+#  time_r \
+#  time_rz \
+#  timegm \
+#  timer-time \
+#  timespec-add \
+#  timespec-sub \
+#  unlocked-io \
+#  update-copyright \
+#  utimensat \
+#  vla \
+#  warnings
+
+# Specification in the form of a few gnulib-tool.m4 macro invocations:
+gl_LOCAL_DIR([])
+gl_MODULES([
+  alloca-opt
+  binary-io
+  byteswap
+  c-ctype
+  c-strcase
+  canonicalize-lgpl
+  careadlinkat
+  close-stream
+  copy-file-range
+  count-leading-zeros
+  count-one-bits
+  count-trailing-zeros
+  crypto/md5-buffer
+  crypto/sha1-buffer
+  crypto/sha256-buffer
+  crypto/sha512-buffer
+  d-type
+  diffseq
+  double-slash-root
+  dtoastr
+  dtotimespec
+  dup2
+  environ
+  execinfo
+  explicit_bzero
+  faccessat
+  fchmodat
+  fcntl
+  fcntl-h
+  fdopendir
+  filemode
+  filename
+  filevercmp
+  flexmember
+  fpieee
+  fstatat
+  fsusage
+  fsync
+  futimens
+  getloadavg
+  getopt-gnu
+  getrandom
+  gettime
+  gettimeofday
+  gitlog-to-changelog
+  ieee754-h
+  ignore-value
+  intprops
+  largefile
+  libgmp
+  lstat
+  manywarnings
+  memmem-simple
+  mempcpy
+  memrchr
+  minmax
+  mkostemp
+  mktime
+  nstrftime
+  pathmax
+  pipe2
+  pselect
+  pthread_sigmask
+  qcopy-acl
+  readlink
+  readlinkat
+  regex
+  sig2str
+  sigdescr_np
+  socklen
+  stat-time
+  std-gnu11
+  stdalign
+  stddef
+  stdio
+  stpcpy
+  strnlen
+  strtoimax
+  symlink
+  sys_stat
+  sys_time
+  tempname
+  time
+  time_r
+  time_rz
+  timegm
+  timer-time
+  timespec-add
+  timespec-sub
+  unlocked-io
+  update-copyright
+  utimensat
+  vla
+  warnings
+])
+gl_AVOID([ btowc close dup fchdir fstat langinfo lock malloc-posix mbrtowc mbsinit memchr mkdir msvc-inval msvc-nothrow nl_langinfo openat-die opendir pthread-h raise save-cwd select setenv sigprocmask stat stdarg stdbool threadlib tzset unsetenv utime utime-h wchar wcrtomb wctype-h])
+gl_SOURCE_BASE([lib])
+gl_M4_BASE([m4])
+gl_PO_BASE([])
+gl_DOC_BASE([doc])
+gl_TESTS_BASE([tests])
+gl_LIB([libgnu])
+gl_MAKEFILE_NAME([gnulib.mk.in])
+gl_CONDITIONAL_DEPENDENCIES
+gl_MACRO_PREFIX([gl])
+gl_PO_DOMAIN([])
+gl_WITNESS_C_MACRO([])
+gl_VC_FILES([false])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index cd6f7b4bbdfab..70f138cc3301c 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -293,12 +293,6 @@ AC_DEFUN
   if test $gl_cv_func___fpending = no; then
     AC_LIBOBJ([fpending])
   fi
-  gl_FUNC_FREE
-  if test $REPLACE_FREE = 1; then
-    AC_LIBOBJ([free])
-    gl_PREREQ_FREE
-  fi
-  gl_STDLIB_MODULE_INDICATOR([free-posix])
   gl_FUNC_FSTATAT
   if test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1; then
     AC_LIBOBJ([fstatat])
@@ -521,6 +515,7 @@ AC_DEFUN
   gl_gnulib_enabled_dynarray=false
   gl_gnulib_enabled_925677f0343de64b89a9f0c790b4104c=false
   gl_gnulib_enabled_euidaccess=false
+  gl_gnulib_enabled_ef07dc4b3077c11ea9cef586db4e5955=false
   gl_gnulib_enabled_getdtablesize=false
   gl_gnulib_enabled_getgroups=false
   gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false
@@ -594,6 +589,18 @@ AC_DEFUN
       func_gl_gnulib_m4code_6099e9737f757db36c47fa9d9f02e88c
     fi
   }
+  func_gl_gnulib_m4code_ef07dc4b3077c11ea9cef586db4e5955 ()
+  {
+    if ! $gl_gnulib_enabled_ef07dc4b3077c11ea9cef586db4e5955; then
+      gl_FUNC_FREE
+      if test $REPLACE_FREE = 1; then
+        AC_LIBOBJ([free])
+        gl_PREREQ_FREE
+      fi
+      gl_STDLIB_MODULE_INDICATOR([free-posix])
+      gl_gnulib_enabled_ef07dc4b3077c11ea9cef586db4e5955=true
+    fi
+  }
   func_gl_gnulib_m4code_getdtablesize ()
   {
     if ! $gl_gnulib_enabled_getdtablesize; then
@@ -745,6 +752,9 @@ AC_DEFUN
   if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then
     func_gl_gnulib_m4code_925677f0343de64b89a9f0c790b4104c
   fi
+  if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then
+    func_gl_gnulib_m4code_ef07dc4b3077c11ea9cef586db4e5955
+  fi
   if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then
     func_gl_gnulib_m4code_idx
   fi
@@ -833,6 +843,7 @@ AC_DEFUN
   AM_CONDITIONAL([gl_GNULIB_ENABLED_dynarray], [$gl_gnulib_enabled_dynarray])
   AM_CONDITIONAL([gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c], [$gl_gnulib_enabled_925677f0343de64b89a9f0c790b4104c])
   AM_CONDITIONAL([gl_GNULIB_ENABLED_euidaccess], [$gl_gnulib_enabled_euidaccess])
+  AM_CONDITIONAL([gl_GNULIB_ENABLED_ef07dc4b3077c11ea9cef586db4e5955], [$gl_gnulib_enabled_ef07dc4b3077c11ea9cef586db4e5955])
   AM_CONDITIONAL([gl_GNULIB_ENABLED_getdtablesize], [$gl_gnulib_enabled_getdtablesize])
   AM_CONDITIONAL([gl_GNULIB_ENABLED_getgroups], [$gl_gnulib_enabled_getgroups])
   AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36])
diff --git a/m4/gnulib-tool.m4 b/m4/gnulib-tool.m4
new file mode 100644
index 0000000000000..3d56d83f128db
--- /dev/null
+++ b/m4/gnulib-tool.m4
@@ -0,0 +1,57 @@
+# gnulib-tool.m4 serial 2
+dnl Copyright (C) 2004-2005, 2009-2021 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl The following macros need not be invoked explicitly.
+dnl Invoking them does nothing except to declare default arguments
+dnl for "gnulib-tool --import".
+
+dnl Usage: gl_LOCAL_DIR([DIR])
+AC_DEFUN([gl_LOCAL_DIR], [])
+
+dnl Usage: gl_MODULES([module1 module2 ...])
+AC_DEFUN([gl_MODULES], [])
+
+dnl Usage: gl_AVOID([module1 module2 ...])
+AC_DEFUN([gl_AVOID], [])
+
+dnl Usage: gl_SOURCE_BASE([DIR])
+AC_DEFUN([gl_SOURCE_BASE], [])
+
+dnl Usage: gl_M4_BASE([DIR])
+AC_DEFUN([gl_M4_BASE], [])
+
+dnl Usage: gl_PO_BASE([DIR])
+AC_DEFUN([gl_PO_BASE], [])
+
+dnl Usage: gl_DOC_BASE([DIR])
+AC_DEFUN([gl_DOC_BASE], [])
+
+dnl Usage: gl_TESTS_BASE([DIR])
+AC_DEFUN([gl_TESTS_BASE], [])
+
+dnl Usage: gl_WITH_TESTS
+AC_DEFUN([gl_WITH_TESTS], [])
+
+dnl Usage: gl_LIB([LIBNAME])
+AC_DEFUN([gl_LIB], [])
+
+dnl Usage: gl_LGPL or gl_LGPL([VERSION])
+AC_DEFUN([gl_LGPL], [])
+
+dnl Usage: gl_MAKEFILE_NAME([FILENAME])
+AC_DEFUN([gl_MAKEFILE_NAME], [])
+
+dnl Usage: gl_LIBTOOL
+AC_DEFUN([gl_LIBTOOL], [])
+
+dnl Usage: gl_MACRO_PREFIX([PREFIX])
+AC_DEFUN([gl_MACRO_PREFIX], [])
+
+dnl Usage: gl_PO_DOMAIN([DOMAIN])
+AC_DEFUN([gl_PO_DOMAIN], [])
+
+dnl Usage: gl_VC_FILES([BOOLEAN])
+AC_DEFUN([gl_VC_FILES], [])
diff --git a/m4/manywarnings-c++.m4 b/m4/manywarnings-c++.m4
new file mode 100644
index 0000000000000..fbb8f77f8beb7
--- /dev/null
+++ b/m4/manywarnings-c++.m4
@@ -0,0 +1,243 @@
+# manywarnings-c++.m4 serial 3
+dnl Copyright (C) 2008-2021 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# Implementation of the specialization of gl_MANYWARN_ALL_GCC
+# for _AC_LANG = C++.
+AC_DEFUN([gl_MANYWARN_ALL_GCC_CXX_IMPL],
+[
+  AC_LANG_PUSH([C++])
+
+  dnl First, check for some issues that only occur when combining multiple
+  dnl gcc warning categories.
+  AC_REQUIRE([AC_PROG_CXX])
+  if test -n "$GXX"; then
+
+    dnl Check if -W -Werror -Wno-missing-field-initializers is supported
+    dnl with the current $CXX $CXXFLAGS $CPPFLAGS.
+    AC_CACHE_CHECK([whether -Wno-missing-field-initializers is supported],
+      [gl_cv_cxx_nomfi_supported],
+      [gl_save_CXXFLAGS="$CXXFLAGS"
+       CXXFLAGS="$CXXFLAGS -W -Werror -Wno-missing-field-initializers"
+       AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM([[]], [[]])],
+         [gl_cv_cxx_nomfi_supported=yes],
+         [gl_cv_cxx_nomfi_supported=no])
+       CXXFLAGS="$gl_save_CXXFLAGS"
+      ])
+
+    if test "$gl_cv_cxx_nomfi_supported" = yes; then
+      dnl Now check whether -Wno-missing-field-initializers is needed
+      dnl for the { 0, } construct.
+      AC_CACHE_CHECK([whether -Wno-missing-field-initializers is needed],
+        [gl_cv_cxx_nomfi_needed],
+        [gl_save_CXXFLAGS="$CXXFLAGS"
+         CXXFLAGS="$CXXFLAGS -W -Werror"
+         AC_COMPILE_IFELSE(
+           [AC_LANG_PROGRAM(
+              [[int f (void)
+                {
+                  typedef struct { int a; int b; } s_t;
+                  s_t s1 = { 0, };
+                  return s1.b;
+                }
+              ]],
+              [[]])],
+           [gl_cv_cxx_nomfi_needed=no],
+           [gl_cv_cxx_nomfi_needed=yes])
+         CXXFLAGS="$gl_save_CXXFLAGS"
+        ])
+    fi
+
+    dnl Next, check if -Werror -Wuninitialized is useful with the
+    dnl user's choice of $CXXFLAGS; some versions of gcc warn that it
+    dnl has no effect if -O is not also used
+    AC_CACHE_CHECK([whether -Wuninitialized is supported],
+      [gl_cv_cxx_uninitialized_supported],
+      [gl_save_CXXFLAGS="$CXXFLAGS"
+       CXXFLAGS="$CXXFLAGS -Werror -Wuninitialized"
+       AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM([[]], [[]])],
+         [gl_cv_cxx_uninitialized_supported=yes],
+         [gl_cv_cxx_uninitialized_supported=no])
+       CXXFLAGS="$gl_save_CXXFLAGS"
+      ])
+
+  fi
+
+  # List all gcc warning categories.
+  # To compare this list to your installed GCC's, run this Bash command:
+  #
+  # comm -3 \
+  #  <(sed -n 's/^  *\(-[^ ]*\) .*/\1/p' manywarnings-c++.m4 | sort) \
+  #  <(gcc --help=warnings | sed -n 's/^  \(-[^ ]*\) .*/\1/p' | sort |
+  #      grep -v -x -f <(
+  #         awk '/^[^#]/ {print $1}' ../build-aux/g++-warning.spec))
+
+  gl_manywarn_set=
+  for gl_manywarn_item in \
+    -W \
+    -Wabi-tag \
+    -Waddress \
+    -Waggressive-loop-optimizations \
+    -Wall \
+    -Wattributes \
+    -Wbool-compare \
+    -Wbuiltin-macro-redefined \
+    -Wcast-align \
+    -Wchar-subscripts \
+    -Wclobbered \
+    -Wcomment \
+    -Wcomments \
+    -Wconditionally-supported \
+    -Wconversion-null \
+    -Wcoverage-mismatch \
+    -Wcpp \
+    -Wctor-dtor-privacy \
+    -Wdate-time \
+    -Wdelete-incomplete \
+    -Wdelete-non-virtual-dtor \
+    -Wdeprecated \
+    -Wdeprecated-declarations \
+    -Wdisabled-optimization \
+    -Wdiv-by-zero \
+    -Wdouble-promotion \
+    -Weffc++ \
+    -Wempty-body \
+    -Wendif-labels \
+    -Wenum-compare \
+    -Wextra \
+    -Wformat-contains-nul \
+    -Wformat-extra-args \
+    -Wformat-nonliteral \
+    -Wformat-security \
+    -Wformat-signedness \
+    -Wformat-y2k \
+    -Wformat-zero-length \
+    -Wfree-nonheap-object \
+    -Wignored-qualifiers \
+    -Winherited-variadic-ctor \
+    -Winit-self \
+    -Winline \
+    -Wint-to-pointer-cast \
+    -Winvalid-memory-model \
+    -Winvalid-offsetof \
+    -Winvalid-pch \
+    -Wliteral-suffix \
+    -Wlogical-not-parentheses \
+    -Wlogical-op \
+    -Wmain \
+    -Wmaybe-uninitialized \
+    -Wmemset-transposed-args \
+    -Wmissing-braces \
+    -Wmissing-declarations \
+    -Wmissing-field-initializers \
+    -Wmissing-include-dirs \
+    -Wmultichar \
+    -Wnarrowing \
+    -Wnoexcept \
+    -Wnon-template-friend \
+    -Wnon-virtual-dtor \
+    -Wnonnull \
+    -Wodr \
+    -Wold-style-cast \
+    -Wopenmp-simd \
+    -Woverflow \
+    -Woverlength-strings \
+    -Woverloaded-virtual \
+    -Wpacked \
+    -Wpacked-bitfield-compat \
+    -Wparentheses \
+    -Wpmf-conversions \
+    -Wpointer-arith \
+    -Wpragmas \
+    -Wreorder \
+    -Wreturn-local-addr \
+    -Wreturn-type \
+    -Wsequence-point \
+    -Wshadow \
+    -Wshift-count-negative \
+    -Wshift-count-overflow \
+    -Wsign-promo \
+    -Wsized-deallocation \
+    -Wsizeof-array-argument \
+    -Wsizeof-pointer-memaccess \
+    -Wstack-protector \
+    -Wstrict-aliasing \
+    -Wstrict-null-sentinel \
+    -Wstrict-overflow \
+    -Wsuggest-attribute=const \
+    -Wsuggest-attribute=format \
+    -Wsuggest-attribute=noreturn \
+    -Wsuggest-attribute=pure \
+    -Wsuggest-final-methods \
+    -Wsuggest-final-types \
+    -Wsuggest-override \
+    -Wswitch \
+    -Wswitch-bool \
+    -Wsync-nand \
+    -Wsystem-headers \
+    -Wtrampolines \
+    -Wtrigraphs \
+    -Wtype-limits \
+    -Wuninitialized \
+    -Wunknown-pragmas \
+    -Wunsafe-loop-optimizations \
+    -Wunused \
+    -Wunused-but-set-parameter \
+    -Wunused-but-set-variable \
+    -Wunused-function \
+    -Wunused-label \
+    -Wunused-local-typedefs \
+    -Wunused-macros \
+    -Wunused-parameter \
+    -Wunused-result \
+    -Wunused-value \
+    -Wunused-variable \
+    -Wuseless-cast \
+    -Wvarargs \
+    -Wvariadic-macros \
+    -Wvector-operation-performance \
+    -Wvirtual-move-assign \
+    -Wvla \
+    -Wvolatile-register-var \
+    -Wwrite-strings \
+    -Wzero-as-null-pointer-constant \
+    \
+    ; do
+    gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
+  done
+
+  # gcc --help=warnings outputs an unusual form for these options; list
+  # them here so that the above 'comm' command doesn't report a false match.
+  gl_manywarn_set="$gl_manywarn_set -Warray-bounds=2"
+  gl_manywarn_set="$gl_manywarn_set -Wnormalized=nfc"
+  gl_manywarn_set="$gl_manywarn_set -Wshift-overflow=2"
+  gl_manywarn_set="$gl_manywarn_set -Wunused-const-variable=2"
+
+  # These are needed for older GCC versions.
+  if test -n "$GXX"; then
+    case `($CXX --version) 2>/dev/null` in
+      'g++ (GCC) '[[0-3]].* | \
+      'g++ (GCC) '4.[[0-7]].*)
+        gl_manywarn_set="$gl_manywarn_set -fdiagnostics-show-option"
+        gl_manywarn_set="$gl_manywarn_set -funit-at-a-time"
+          ;;
+    esac
+  fi
+
+  # Disable specific options as needed.
+  if test "$gl_cv_cxx_nomfi_needed" = yes; then
+    gl_manywarn_set="$gl_manywarn_set -Wno-missing-field-initializers"
+  fi
+
+  if test "$gl_cv_cxx_uninitialized_supported" = no; then
+    gl_manywarn_set="$gl_manywarn_set -Wno-uninitialized"
+  fi
+
+  $1=$gl_manywarn_set
+
+  AC_LANG_POP([C++])
+])
diff --git a/m4/warn-on-use.m4 b/m4/warn-on-use.m4
new file mode 100644
index 0000000000000..04edfe85d4997
--- /dev/null
+++ b/m4/warn-on-use.m4
@@ -0,0 +1,49 @@
+# warn-on-use.m4 serial 9
+dnl Copyright (C) 2010-2021 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES)
+# ---------------------------------------
+# If the module 'posixcheck' is in use:
+#
+# For each whitespace-separated element in the list of NAMES, define
+# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES
+# even after being undefined as a macro.
+#
+# See warn-on-use.h for some hints on how to poison function names, as
+# well as ideas on poisoning global variables and macros.  NAMES may
+# include global variables, but remember that only functions work with
+# _GL_WARN_ON_USE.  Typically, INCLUDES only needs to list a single
+# header, but if the replacement header pulls in other headers because
+# some systems declare functions in the wrong header, then INCLUDES
+# should do likewise.
+#
+# It is generally safe to assume declarations for functions declared
+# in the intersection of C89 and C11 (such as printf) without
+# needing gl_WARN_ON_USE_PREPARE.
+AC_DEFUN([gl_WARN_ON_USE_PREPARE],
+[
+  m4_ifdef([gl_POSIXCHECK],
+    [m4_foreach_w([gl_decl], [$2],
+       [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
+         [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
+          undefining macros.])])dnl
+     for gl_func in m4_flatten([$2]); do
+       AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
+       AC_CACHE_CHECK([whether $gl_func is declared without a macro],
+         [gl_Symbol],
+         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
+[[#undef $gl_func
+  (void) $gl_func;]])],
+           [AS_VAR_SET([gl_Symbol], [yes])], [AS_VAR_SET([gl_Symbol], [no])])])
+       AS_VAR_IF([gl_Symbol], [yes],
+         [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
+          dnl shortcut - if the raw declaration exists, then set a cache
+          dnl variable to allow skipping any later AC_CHECK_DECL efforts
+          eval ac_cv_have_decl_$gl_func=yes])
+       AS_VAR_POPDEF([gl_Symbol])dnl
+     done
+    ])
+])
diff --git a/m4/wint_t.m4 b/m4/wint_t.m4
new file mode 100644
index 0000000000000..2fc7467f4228d
--- /dev/null
+++ b/m4/wint_t.m4
@@ -0,0 +1,57 @@
+# wint_t.m4 serial 10
+dnl Copyright (C) 2003, 2007-2021 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+dnl Test whether <wchar.h> has the 'wint_t' type and whether gnulib's
+dnl <wchar.h> or <wctype.h> would, if present, override 'wint_t'.
+dnl Prerequisite: AC_PROG_CC
+
+AC_DEFUN([gt_TYPE_WINT_T],
+[
+  AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <wchar.h>
+            wint_t foo = (wchar_t)'\0';]],
+          [[]])],
+       [gt_cv_c_wint_t=yes],
+       [gt_cv_c_wint_t=no])])
+  if test $gt_cv_c_wint_t = yes; then
+    AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.])
+
+    dnl Determine whether gnulib's <wchar.h> or <wctype.h> would, if present,
+    dnl override 'wint_t'.
+    AC_CACHE_CHECK([whether wint_t is large enough],
+      [gl_cv_type_wint_t_large_enough],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[#include <wchar.h>
+              int verify[sizeof (wint_t) < sizeof (int) ? -1 : 1];
+            ]])],
+         [gl_cv_type_wint_t_large_enough=yes],
+         [gl_cv_type_wint_t_large_enough=no])])
+    if test $gl_cv_type_wint_t_large_enough = no; then
+      GNULIB_OVERRIDES_WINT_T=1
+    else
+      GNULIB_OVERRIDES_WINT_T=0
+    fi
+  else
+    GNULIB_OVERRIDES_WINT_T=0
+  fi
+  AC_SUBST([GNULIB_OVERRIDES_WINT_T])
+])
+
+dnl Prerequisites of the 'wint_t' override.
+AC_DEFUN([gl_TYPE_WINT_T_PREREQ],
+[
+  AC_CHECK_HEADERS_ONCE([crtdefs.h])
+  if test $ac_cv_header_crtdefs_h = yes; then
+    HAVE_CRTDEFS_H=1
+  else
+    HAVE_CRTDEFS_H=0
+  fi
+  AC_SUBST([HAVE_CRTDEFS_H])
+])
diff --git a/src/pdumper.c b/src/pdumper.c
index 337742fda4ade..8939057217ef8 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -5467,8 +5467,6 @@ DEFUN ("pdumper-stats", Fpdumper_stats, Spdumper_stats, 0, 0, 0,
 		Fcons (Qdump_file_name, dump_fn));
 }
 
-#endif /* HAVE_PDUMPER */
-
 \f
 static void
 thaw_hash_tables (void)
@@ -5478,10 +5476,14 @@ thaw_hash_tables (void)
     hash_table_thaw (AREF (hash_tables, i));
 }
 
+#endif /* HAVE_PDUMPER */
+
 void
 init_pdumper_once (void)
 {
+#ifdef HAVE_PDUMPER
   pdumper_do_now_and_after_load (thaw_hash_tables);
+#endif /* HAVE_PDUMPER */
 }
 
 void
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#46965: 28.0.50; unexec does not build (or work)
  2021-03-06 19:07 ` Pip Cet
@ 2021-03-06 20:04   ` Eli Zaretskii
  2021-03-06 20:19     ` Pip Cet
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2021-03-06 20:04 UTC (permalink / raw)
  To: Pip Cet; +Cc: 46965

> From: Pip Cet <pipcet@gmail.com>
> Date: Sat, 6 Mar 2021 19:07:02 +0000
> 
> Here's the patch to make unexec build. Note that this patch removes
> the free() wrapper from lib/, so if your libc's free() is broken and
> sets errno, that bug will be once again exposed.

Hmm... why do we need to add so much stuff from Gnulib?





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#46965: 28.0.50; unexec does not build (or work)
  2021-03-06 20:04   ` Eli Zaretskii
@ 2021-03-06 20:19     ` Pip Cet
  0 siblings, 0 replies; 5+ messages in thread
From: Pip Cet @ 2021-03-06 20:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 46965

On Sat, Mar 6, 2021 at 8:04 PM Eli Zaretskii <eliz@gnu.org> wrote:
> > From: Pip Cet <pipcet@gmail.com>
> > Date: Sat, 6 Mar 2021 19:07:02 +0000
> > Here's the patch to make unexec build. Note that this patch removes
> > the free() wrapper from lib/, so if your libc's free() is broken and
> > sets errno, that bug will be once again exposed.
>
> Hmm... why do we need to add so much stuff from Gnulib?

We don't, I hope, but I don't know how to properly regenerate the
gnulib dependencies :-)





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#46965: 28.0.50; unexec does not build (or work)
  2021-03-06 14:01 bug#46965: 28.0.50; unexec does not build (or work) Pip Cet
  2021-03-06 19:07 ` Pip Cet
@ 2022-06-20  1:27 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-20  1:27 UTC (permalink / raw)
  To: Pip Cet; +Cc: 46965

Pip Cet <pipcet@gmail.com> writes:

> On this Debian-based x86_64-pc-linux-gnu system, configuring with
> --with-dumping=unexec results in various errors:
>
> 1. a compilation error in pdumper.c. Easy to fix, my fault, but then there's ...
> 2. a segfault when running the dumped image. The problem is we can't
> use glibc's malloc when running a dumped image, so we need to force
> use of hybrid malloc. But then...

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

It looks like this was fixed in:

commit 44ed8f6555288f00b982f21e68ac5a51372279de
Author:     Eli Zaretskii <eliz@gnu.org>
AuthorDate: Sun Apr 4 10:10:00 2021 +0300

And the unexec build seems to work OK for me still, so I'm closing this
bug report.  (If there's more to be done here, please respond to the
debbugs address and we'll reopen.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-20  1:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-06 14:01 bug#46965: 28.0.50; unexec does not build (or work) Pip Cet
2021-03-06 19:07 ` Pip Cet
2021-03-06 20:04   ` Eli Zaretskii
2021-03-06 20:19     ` Pip Cet
2022-06-20  1:27 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).