With the recent changes proposed for glibc I'm reasonably confident its
'free' will be fixed in 2.33, so I installed the attached further patch into
Gnulib. Doing the check with AC_COMPILE_IFELSE should improve the quality of
the guesses when cross-compiling. (If I'm wrong about 2.33 we can change it
to 2.34 later.)
>From 493c37a7ba0cb0f461ffbcd3b1d9a20e5e58f656 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 20 Dec 2020 13:29:04 -0800
Subject: [PATCH] free-posix: assume glibc 2.33 fixes this.
* m4/free.m4 (gl_FUNC_FREE): Assume glibc 2.33+ is fixed.
Use compile-time test rather than guessing for cross-builds.
---
ChangeLog | 6 ++++++
m4/free.m4 | 35 +++++++++++++++++------------------
2 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d21388a99..c281ec439 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-12-20 Paul Eggert <egg...@cs.ucla.edu>
+
+ free-posix: assume glibc 2.33 fixes this.
+ * m4/free.m4 (gl_FUNC_FREE): Assume glibc 2.33+ is fixed.
+ Use compile-time test rather than guessing for cross-builds.
+
2020-12-20 Bruno Haible <br...@clisp.org>
backupfile: Fix compilation error on native Windows (regr. 2018-10-23).
diff --git a/m4/free.m4 b/m4/free.m4
index 53df7439b..bf9fc31d9 100644
--- a/m4/free.m4
+++ b/m4/free.m4
@@ -1,4 +1,4 @@
-# free.m4 serial 4
+# free.m4 serial 5
# Copyright (C) 2003-2005, 2009-2020 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -9,12 +9,13 @@
AC_DEFUN([gl_FUNC_FREE],
[
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
- AC_REQUIRE([AC_CANONICAL_HOST])
dnl In the next release of POSIX, free must preserve errno.
dnl https://www.austingroupbugs.net/view.php?id=385
dnl https://sourceware.org/bugzilla/show_bug.cgi?id=17924
- dnl So far, we know of two platforms that do this:
+ dnl So far, we know of three platforms that do this:
+ dnl * glibc >= 2.33, thanks to the fix for this bug:
+ dnl <https://sourceware.org/bugzilla/show_bug.cgi?id=17924>
dnl * OpenBSD >= 4.5, thanks to this commit:
dnl <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdlib/malloc.c.diff?r1=1.100&r2=1.101&f=h>
dnl * Solaris, because its malloc() implementation is based on brk(),
@@ -23,21 +24,19 @@ AC_DEFUN([gl_FUNC_FREE],
dnl documentation, or by code inspection of the free() implementation in libc.
AC_CACHE_CHECK([whether free is known to preserve errno],
[gl_cv_func_free_preserves_errno],
- [case "$host_os" in
- # Say yes only if we know it.
- openbsd* | solaris*)
- gl_cv_func_free_preserves_errno=yes
- ;;
- # It's no on Linux, for implementations that call munmap(), due to
- # /proc/sys/vm/max_map_count.
- linux*)
- gl_cv_func_free_preserves_errno=no
- ;;
- # If we don't know, obey --enable-cross-guesses.
- *)
- gl_cv_func_free_preserves_errno="$gl_cross_guess_normal"
- ;;
- esac
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <stdlib.h>
+ ]],
+ [[#if 2 < __GLIBC__ + (33 <= __GLIBC_MINOR__)
+ #elif defined __OpenBSD__
+ #elif defined __sun
+ #else
+ #error "'free' is not known to preserve errno"
+ #endif
+ ]])],
+ [gl_cv_func_free_preserves_errno=yes],
+ [gl_cv_func_free_preserves_errno=no])
])
case $gl_cv_func_free_preserves_errno in
--
2.27.0