Hi, Alyssa Ross wrote: > • Use MUSL_LIBC macro
Thanks. I tested this patch on Alpine Linux 3.9 (musl libc < 1.2.3) and 3.22 (musl libc >= 1.2.3), through a testdir ./gnulib-tool --create-testdir --dir=testdir free-posix and in both cases the configure still reports checking whether free is known to preserve errno... no This is because the Autoconf macro that sets MUSL_LIBC is not invoked so far. I'm therefore committing this patch, that includes yours but also the MUSL_LIBC fix: 2026-05-18 Alyssa Ross <[email protected]> Bruno Haible <[email protected]> free-posix: Omit wrapper in musl libc >= 1.2.3. * m4/free.m4 (gl_FUNC_FREE): Require gl_MUSL_LIBC. Guess yes on musl libc versions that define SEEK_DATA. * modules/free-posix (Files): Add m4/musl.m4. diff --git a/m4/free.m4 b/m4/free.m4 index c7a134bab8..e9c9d8f35c 100644 --- a/m4/free.m4 +++ b/m4/free.m4 @@ -1,5 +1,5 @@ # free.m4 -# serial 6 +# serial 7 dnl Copyright (C) 2003-2005, 2009-2026 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -18,6 +18,9 @@ AC_DEFUN([gl_FUNC_FREE] 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/PR17924> + dnl * musl >= 1.2.3, thanks to these commits: + dnl <https://git.musl-libc.org/cgit/musl/commit/?id=9b77aaca86b53c367f23505c24dd3c02e240efad> + dnl <https://git.musl-libc.org/cgit/musl/commit/?id=2010df0d64570db4ce29cc7df0e31f81aa26ae4a> 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(), @@ -26,11 +29,14 @@ 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], - [AC_COMPILE_IFELSE( + [AC_REQUIRE([gl_MUSL_LIBC]) + AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[#include <stdlib.h> + #include <unistd.h> ]], [[#if 2 < __GLIBC__ + (33 <= __GLIBC_MINOR__) + #elif defined MUSL_LIBC && defined SEEK_DATA /* musl >= 1.2.3 */ #elif defined __OpenBSD__ #elif defined __sun #else diff --git a/modules/free-posix b/modules/free-posix index 15d3467572..317f48bafd 100644 --- a/modules/free-posix +++ b/modules/free-posix @@ -4,6 +4,7 @@ Work around systems where free clobbers errno. Files: lib/free.c m4/free.m4 +m4/musl.m4 Depends-on: stdlib-h
