* [PATCH] Fix libiberty.h inclusion on non-glibc hosts tree-wide
@ 2026-11-18 0:49 Nick Alcock
2026-11-18 7:24 ` Jan Beulich
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Nick Alcock @ 2026-11-18 0:49 UTC (permalink / raw)
To: binutils; +Cc: gdb-patches, iain
In 2025, Iain Sandoe added memrchr support to libiberty.h. This requires
a new AC_CHECK_FUNCS of memrchr in every project that transitively
includes it, or builds on non-glibc, non-Linux hosts will fail (observed
on FreeBSD 15).
Fix trivial, but a tad invasive, since a lot of projects include
libiberty.h, and it shows up a few places that don't include config.h at
all (including some that include ansidecl.h, which requires config.h for
proper operation).
All relevant configury regenerated.
Also touches GDB machinery, so gdb-patches is Cc:ed.
Iain Sandoe Cc:ed: Iain, if you disagree with my rather nasty approach
here, I'd be interested in anything better. (The need to use %top in
binutils/arlex.l is slightly worrying. It's not in POSIX, but
we need something like it or we can't include config.h before the
system headers it must precede. (Including config.h in libiberty.h
won't work for the same reason.)
But if you don't do this, you can't compile binutils/arlex.c on
FreeBSD any more (or any non-Linux, non-glibc system).
bfd/
* configure.ac: Check for memrchr.
* config.in: Regenerate.
* configure: Likewise.
binutils/
* configure.ac: Check for memrchr.
* demanguse.c: Include config.h.
* arlex.l: Likewise.
* config.in: Regenerate.
* configure: Likewise.
gas/
* configure.ac: Check for memrchr.
* config.in: Regenerate.
* configure: Likewise.
gdbsupport/
* libiberty.m4: Check for memrchr.
* config.in: Regenerate.
* configure: Likewise.
sim/
* config.h.in: Regenerate.
* configure: Likewise.
gdb/
* config.in: Regenerate.
* configure: Likewise.
gdbserver/
* config.in: Regenerate.
* configure: Likewise.
gprofng/
* configure.ac: Check for memrchr.
* common/config.h.in: Regenerate.
* configure: Likewise.
gold/
* configure.ac: Check for memrchr.
* config.in: Regenerate.
* configure: Likewise.
ld/
* configure.ac: Check for memrchr.
* config.in: Regenerate.
* configure: Likewise.
libctf/
* configure.ac: Check for memrchr.
* config.h.in: Regenerate.
* configure: Likewise.
opcodes/
* configure.ac: Check for memrchr.
* config.in: Regenerate.
* configure: Likewise.
---
bfd/config.in | 3 +++
bfd/configure | 2 +-
bfd/configure.ac | 2 +-
binutils/arlex.l | 4 ++++
binutils/config.in | 3 +++
binutils/configure | 2 +-
binutils/configure.ac | 2 +-
binutils/demanguse.c | 1 +
gas/config.in | 3 +++
gas/configure | 9 +++++----
gas/configure.ac | 2 +-
gdb/config.in | 3 +++
gdb/configure | 11 +++++++++++
gdbserver/config.in | 3 +++
gdbserver/configure | 11 +++++++++++
gdbsupport/config.in | 3 +++
gdbsupport/configure | 11 +++++++++++
gdbsupport/libiberty.m4 | 1 +
gold/config.in | 3 +++
gold/configure | 2 +-
gold/configure.ac | 2 +-
gprofng/common/config.h.in | 3 +++
gprofng/configure | 2 +-
gprofng/configure.ac | 2 +-
ld/config.in | 3 +++
ld/configure | 2 +-
ld/configure.ac | 2 +-
libctf/config.h.in | 3 +++
libctf/configure | 9 +++++----
libctf/configure.ac | 2 +-
opcodes/config.in | 3 +++
opcodes/configure | 11 +++++++++++
opcodes/configure.ac | 1 +
sim/config.h.in | 3 +++
sim/configure | 11 +++++++++++
35 files changed, 120 insertions(+), 20 deletions(-)
diff --git a/bfd/config.in b/bfd/config.in
index 3efd3dc3ce1..0443944891f 100644
--- a/bfd/config.in
+++ b/bfd/config.in
@@ -165,6 +165,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have the `memrchr' function. */
+#undef HAVE_MEMRCHR
+
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
diff --git a/bfd/configure b/bfd/configure
index d010a3f9aa6..30331907315 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -15129,7 +15129,7 @@ done
for ac_func in fcntl fdopen fileno fls getgid getpagesize getrlimit getuid \
- sysconf
+ sysconf memrchr
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/bfd/configure.ac b/bfd/configure.ac
index 0630973a11d..d3f761fb158 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -220,7 +220,7 @@ AC_CHECK_HEADERS(fcntl.h sys/file.h sys/resource.h sys/stat.h sys/types.h \
unistd.h)
AC_CHECK_FUNCS(fcntl fdopen fileno fls getgid getpagesize getrlimit getuid \
- sysconf)
+ sysconf memrchr)
AC_CHECK_DECLS([basename, ffs, stpcpy, asprintf, vasprintf, strnlen, strtoull])
AC_CHECK_DECLS([___lc_codepage_func], [], [], [[#include <locale.h>]])
diff --git a/binutils/arlex.l b/binutils/arlex.l
index 1005aabfced..e8b43e90673 100644
--- a/binutils/arlex.l
+++ b/binutils/arlex.l
@@ -39,6 +39,10 @@ extern int yylex (void);
int linenumber;
%}
+%top{
+#include "config.h"
+}
+
%a 10000
%o 25000
diff --git a/binutils/config.in b/binutils/config.in
index 3c3b547e320..c8c7af66bd1 100644
--- a/binutils/config.in
+++ b/binutils/config.in
@@ -117,6 +117,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have the `memrchr' function. */
+#undef HAVE_MEMRCHR
+
/* Define to 1 if you have the `mkdtemp' function. */
#undef HAVE_MKDTEMP
diff --git a/binutils/configure b/binutils/configure
index c455cb4c0d9..81e0037e8a2 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -15516,7 +15516,7 @@ rm -f conftest.mmap conftest.txt
ASAN_OPTIONS="$save_ASAN_OPTIONS"
-for ac_func in fseeko fseeko64 getc_unlocked mkdtemp mkstemp utimensat utimes
+for ac_func in fseeko fseeko64 getc_unlocked mkdtemp mkstemp utimensat utimes memrchr
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/binutils/configure.ac b/binutils/configure.ac
index e9fda4f42bb..e2e6f416670 100644
--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -198,7 +198,7 @@ AC_CHECK_HEADERS(fcntl.h inttypes.h stdint.h sys/file.h \
sys/stat.h sys/time.h sys/types.h unistd.h)
AC_HEADER_SYS_WAIT
GCC_AC_FUNC_MMAP
-AC_CHECK_FUNCS(fseeko fseeko64 getc_unlocked mkdtemp mkstemp utimensat utimes)
+AC_CHECK_FUNCS(fseeko fseeko64 getc_unlocked mkdtemp mkstemp utimensat utimes memrchr)
AC_MSG_CHECKING([for mbstate_t])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <wchar.h>]],
diff --git a/binutils/demanguse.c b/binutils/demanguse.c
index f5cfefdaf9f..07156d9e29a 100644
--- a/binutils/demanguse.c
+++ b/binutils/demanguse.c
@@ -18,6 +18,7 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA. */
+#include "config.h"
#include <stdio.h>
#include <string.h>
#include "demangle.h"
diff --git a/gas/config.in b/gas/config.in
index 33482aa73dc..54fc965a676 100644
--- a/gas/config.in
+++ b/gas/config.in
@@ -122,6 +122,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have the `memrchr' function. */
+#undef HAVE_MEMRCHR
+
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
diff --git a/gas/configure b/gas/configure
index bf3ccf3006d..dd2a89f976a 100755
--- a/gas/configure
+++ b/gas/configure
@@ -15659,12 +15659,13 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_gas" >&5
$as_echo "$cross_gas" >&6; }
-for ac_func in strsignal
+for ac_func in strsignal memrchr
do :
- ac_fn_c_check_func "$LINENO" "strsignal" "ac_cv_func_strsignal"
-if test "x$ac_cv_func_strsignal" = xyes; then :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
-#define HAVE_STRSIGNAL 1
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
diff --git a/gas/configure.ac b/gas/configure.ac
index 09089b395c5..caecef436c5 100644
--- a/gas/configure.ac
+++ b/gas/configure.ac
@@ -977,7 +977,7 @@ else
fi
AC_MSG_RESULT($cross_gas)
-AC_CHECK_FUNCS(strsignal)
+AC_CHECK_FUNCS([strsignal memrchr])
AM_LC_MESSAGES
diff --git a/gdb/config.in b/gdb/config.in
index 2e42440d4cc..e86bcce7966 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -316,6 +316,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have the `memrchr' function. */
+#undef HAVE_MEMRCHR
+
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
diff --git a/gdb/configure b/gdb/configure
index e747ffce49f..62fc7c0d962 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -29676,6 +29676,17 @@ _ACEOF
+ for ac_func in memrchr
+do :
+ ac_fn_c_check_func "$LINENO" "memrchr" "ac_cv_func_memrchr"
+if test "x$ac_cv_func_memrchr" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_MEMRCHR 1
+_ACEOF
+
+fi
+done
+
diff --git a/gdbserver/config.in b/gdbserver/config.in
index cf6ebe0a4f2..dd18566aa00 100644
--- a/gdbserver/config.in
+++ b/gdbserver/config.in
@@ -168,6 +168,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have the `memrchr' function. */
+#undef HAVE_MEMRCHR
+
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
diff --git a/gdbserver/configure b/gdbserver/configure
index e00e1e1c1c5..712e417e9fe 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -13249,6 +13249,17 @@ _ACEOF
+ for ac_func in memrchr
+do :
+ ac_fn_c_check_func "$LINENO" "memrchr" "ac_cv_func_memrchr"
+if test "x$ac_cv_func_memrchr" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_MEMRCHR 1
+_ACEOF
+
+fi
+done
+
ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include <sys/types.h>
diff --git a/gdbsupport/config.in b/gdbsupport/config.in
index ff84ab0d600..00f281f6a65 100644
--- a/gdbsupport/config.in
+++ b/gdbsupport/config.in
@@ -147,6 +147,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have the `memrchr' function. */
+#undef HAVE_MEMRCHR
+
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
diff --git a/gdbsupport/configure b/gdbsupport/configure
index 7ed4e259ffe..aeb0246bf98 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -10587,6 +10587,17 @@ _ACEOF
+ for ac_func in memrchr
+do :
+ ac_fn_c_check_func "$LINENO" "memrchr" "ac_cv_func_memrchr"
+if test "x$ac_cv_func_memrchr" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_MEMRCHR 1
+_ACEOF
+
+fi
+done
+
ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
if test "x$ac_cv_type_size_t" = xyes; then :
diff --git a/gdbsupport/libiberty.m4 b/gdbsupport/libiberty.m4
index 6c4a83c59a3..4ba571a6d19 100644
--- a/gdbsupport/libiberty.m4
+++ b/gdbsupport/libiberty.m4
@@ -28,4 +28,5 @@ AC_DEFUN([libiberty_INIT],
AC_CHECK_DECLS_ONCE([ffs, asprintf, vasprintf, snprintf, vsnprintf])
AC_CHECK_DECLS_ONCE([strtol, strtoul, strtoll, strtoull])
AC_CHECK_DECLS_ONCE([strverscmp])
+ AC_CHECK_FUNCS([memrchr])
])
diff --git a/gold/config.in b/gold/config.in
index 3dcb30da9f4..52920b606a2 100644
--- a/gold/config.in
+++ b/gold/config.in
@@ -154,6 +154,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have the `memrchr' function. */
+#undef HAVE_MEMRCHR
+
/* Define to 1 if you have the `mkdtemp' function. */
#undef HAVE_MKDTEMP
diff --git a/gold/configure b/gold/configure
index 36fb3a0085c..c524494279f 100755
--- a/gold/configure
+++ b/gold/configure
@@ -9764,7 +9764,7 @@ fi
done
-for ac_func in chsize mmap link
+for ac_func in chsize mmap link memrchr
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/gold/configure.ac b/gold/configure.ac
index 89348b660be..7159034928c 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -547,7 +547,7 @@ LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
AC_SUBST(LFS_CFLAGS)
AC_CHECK_HEADERS(sys/mman.h)
-AC_CHECK_FUNCS(chsize mmap link)
+AC_CHECK_FUNCS(chsize mmap link memrchr)
AC_REPLACE_FUNCS(pread ftruncate ffsll)
AC_CACHE_CHECK([mremap with MREMAP_MAYMOVE], [gold_cv_lib_mremap_maymove],
diff --git a/gprofng/common/config.h.in b/gprofng/common/config.h.in
index 5f2c1278c95..9a2f42a830d 100644
--- a/gprofng/common/config.h.in
+++ b/gprofng/common/config.h.in
@@ -28,6 +28,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have the `memrchr' function. */
+#undef HAVE_MEMRCHR
+
/* Define if you have POSIX threads libraries and header files. */
#undef HAVE_PTHREAD
diff --git a/gprofng/configure b/gprofng/configure
index 0888933579b..6fe67f23ee6 100755
--- a/gprofng/configure
+++ b/gprofng/configure
@@ -17614,7 +17614,7 @@ cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_BASENAME $ac_have_decl
_ACEOF
-for ac_func in clock_gettime strsignal
+for ac_func in clock_gettime strsignal memrchr
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/gprofng/configure.ac b/gprofng/configure.ac
index 3a2eb0265dd..2cb4b9a4c7f 100644
--- a/gprofng/configure.ac
+++ b/gprofng/configure.ac
@@ -246,7 +246,7 @@ AC_SUBST(GPROFNG_CPPFLAGS, [${gprofng_cppflags}])
AC_SUBST(NOLTO_CFLAGS, [${nolto_cflags}])
AC_CHECK_DECLS([basename])
-AC_CHECK_FUNCS(clock_gettime strsignal)
+AC_CHECK_FUNCS([clock_gettime strsignal memrchr])
# For riscv builds inside incomplete environments such as during intermediate
# steps of cross toolchain building, or with outdated Linux headers.
diff --git a/ld/config.in b/ld/config.in
index 1353370340d..4dd2cb1ad49 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -173,6 +173,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have the `memrchr' function. */
+#undef HAVE_MEMRCHR
+
/* Define to 1 if you have the `mkstemp' function. */
#undef HAVE_MKSTEMP
diff --git a/ld/configure b/ld/configure
index cbf80648e1b..f7778869520 100755
--- a/ld/configure
+++ b/ld/configure
@@ -18690,7 +18690,7 @@ fi
done
-for ac_func in close getrusage glob lseek mkstemp open realpath waitpid mallinfo mallinfo2
+for ac_func in close getrusage glob lseek mkstemp open realpath waitpid mallinfo mallinfo2 memrchr
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/ld/configure.ac b/ld/configure.ac
index 8c5e9606ac0..bf7976e202b 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -447,7 +447,7 @@ AC_SUBST(NATIVE_LIB_DIRS)
AC_CHECK_HEADERS(fcntl.h elf-hints.h limits.h inttypes.h stdint.h \
sys/file.h sys/mman.h sys/param.h sys/stat.h sys/time.h \
sys/types.h unistd.h)
-AC_CHECK_FUNCS(close getrusage glob lseek mkstemp open realpath waitpid mallinfo mallinfo2)
+AC_CHECK_FUNCS(close getrusage glob lseek mkstemp open realpath waitpid mallinfo mallinfo2 memrchr)
BFD_BINARY_FOPEN
diff --git a/libctf/config.h.in b/libctf/config.h.in
index 359f1f5ae1d..f213e4d60c7 100644
--- a/libctf/config.h.in
+++ b/libctf/config.h.in
@@ -73,6 +73,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have the `memrchr' function. */
+#undef HAVE_MEMRCHR
+
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
diff --git a/libctf/configure b/libctf/configure
index 8ccc9ac4ee1..584ce040694 100755
--- a/libctf/configure
+++ b/libctf/configure
@@ -16949,12 +16949,13 @@ fi
done
-for ac_func in pread
+for ac_func in pread memrchr
do :
- ac_fn_c_check_func "$LINENO" "pread" "ac_cv_func_pread"
-if test "x$ac_cv_func_pread" = xyes; then :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
-#define HAVE_PREAD 1
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
diff --git a/libctf/configure.ac b/libctf/configure.ac
index 1e1b429c98e..31b73f66cae 100644
--- a/libctf/configure.ac
+++ b/libctf/configure.ac
@@ -118,7 +118,7 @@ fi
AC_C_BIGENDIAN
AC_CHECK_HEADERS(byteswap.h endian.h valgrind/valgrind.h)
-AC_CHECK_FUNCS(pread)
+AC_CHECK_FUNCS([pread memrchr])
dnl Check for bswap_{16,32,64}
AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64], [], [], [[#include <byteswap.h>]])
diff --git a/opcodes/config.in b/opcodes/config.in
index 36e654292b2..d69ae43f675 100644
--- a/opcodes/config.in
+++ b/opcodes/config.in
@@ -65,6 +65,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have the `memrchr' function. */
+#undef HAVE_MEMRCHR
+
/* Define if sigsetjmp is available. */
#undef HAVE_SIGSETJMP
diff --git a/opcodes/configure b/opcodes/configure
index 2ae65d00cbd..1d630c79ccf 100755
--- a/opcodes/configure
+++ b/opcodes/configure
@@ -14032,6 +14032,17 @@ cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_VSNPRINTF $ac_have_decl
_ACEOF
+for ac_func in memrchr
+do :
+ ac_fn_c_check_func "$LINENO" "memrchr" "ac_cv_func_memrchr"
+if test "x$ac_cv_func_memrchr" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_MEMRCHR 1
+_ACEOF
+
+fi
+done
+
# Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't do
# since sigsetjmp might only be defined as a macro.
diff --git a/opcodes/configure.ac b/opcodes/configure.ac
index c6d8972aa0a..71d236516ea 100644
--- a/opcodes/configure.ac
+++ b/opcodes/configure.ac
@@ -97,6 +97,7 @@ AC_SUBST(HDEFINES)
AC_PROG_INSTALL
AC_CHECK_DECLS([asprintf, basename, snprintf, stpcpy, strtoull, vsnprintf])
+AC_CHECK_FUNCS([memrchr])
# Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't do
# since sigsetjmp might only be defined as a macro.
diff --git a/sim/config.h.in b/sim/config.h.in
index 44ff51580c7..8a850202fef 100644
--- a/sim/config.h.in
+++ b/sim/config.h.in
@@ -187,6 +187,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have the `memrchr' function. */
+#undef HAVE_MEMRCHR
+
/* Define to 1 if you have the `mkdir' function. */
#undef HAVE_MKDIR
diff --git a/sim/configure b/sim/configure
index da4caa57aa1..490d725aaed 100755
--- a/sim/configure
+++ b/sim/configure
@@ -14444,6 +14444,17 @@ _ACEOF
+ for ac_func in memrchr
+do :
+ ac_fn_c_check_func "$LINENO" "memrchr" "ac_cv_func_memrchr"
+if test "x$ac_cv_func_memrchr" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_MEMRCHR 1
+_ACEOF
+
+fi
+done
+
base-commit: 5678a7bfceb3a6ea18bcde1ae68f7e96c43c998b
prerequisite-patch-id: 6bb7a1f3d29820aec4c1fe7c2b30a99b1c33b604
--
2.56.1.291.g6a80de6356
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Fix libiberty.h inclusion on non-glibc hosts tree-wide
2026-11-18 0:49 [PATCH] Fix libiberty.h inclusion on non-glibc hosts tree-wide Nick Alcock
@ 2026-11-18 7:24 ` Jan Beulich
2026-11-18 7:41 ` Iain Sandoe
2026-11-18 8:39 ` Sam James
2026-11-19 20:35 ` Tom Tromey
2 siblings, 1 reply; 10+ messages in thread
From: Jan Beulich @ 2026-11-18 7:24 UTC (permalink / raw)
To: Nick Alcock; +Cc: gdb-patches, iain, binutils
On 18.11.2026 01:49, Nick Alcock wrote:
> In 2025, Iain Sandoe added memrchr support to libiberty.h. This requires
> a new AC_CHECK_FUNCS of memrchr in every project that transitively
> includes it, or builds on non-glibc, non-Linux hosts will fail (observed
> on FreeBSD 15).
>
> Fix trivial, but a tad invasive, since a lot of projects include
> libiberty.h, and it shows up a few places that don't include config.h at
> all (including some that include ansidecl.h, which requires config.h for
> proper operation).
>
> All relevant configury regenerated.
>
> Also touches GDB machinery, so gdb-patches is Cc:ed.
>
> Iain Sandoe Cc:ed: Iain, if you disagree with my rather nasty approach
> here, I'd be interested in anything better. (The need to use %top in
> binutils/arlex.l is slightly worrying. It's not in POSIX, but
> we need something like it or we can't include config.h before the
> system headers it must precede. (Including config.h in libiberty.h
> won't work for the same reason.)
What does this mean compatibility-wise? I.e. when did relevant tools (no
idea which one it would be on the BSDs) start supporting %top?
Jan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Fix libiberty.h inclusion on non-glibc hosts tree-wide
2026-11-18 7:24 ` Jan Beulich
@ 2026-11-18 7:41 ` Iain Sandoe
2026-11-18 11:50 ` Nick Alcock
0 siblings, 1 reply; 10+ messages in thread
From: Iain Sandoe @ 2026-11-18 7:41 UTC (permalink / raw)
To: Nick Alcock; +Cc: GDB Patches, GCC Binutils, Jan Beulich, sam, pietro
@sam, @pietro … any ideas most welcome.
> On 18 Nov 2026, at 12:24, Jan Beulich <jbeulich@suse.com> wrote:
>
> On 18.11.2026 01:49, Nick Alcock wrote:
>> In 2025, Iain Sandoe added memrchr support to libiberty.h. This requires
>> a new AC_CHECK_FUNCS of memrchr in every project that transitively
>> includes it, or builds on non-glibc, non-Linux hosts will fail (observed
>> on FreeBSD 15).
In a way, it’s a nit surprising to find a *BSD having an issue (since it was a
BSD derivative that prompted adding this)…but that’s life :)
>> Fix trivial, but a tad invasive, since a lot of projects include
>> libiberty.h, and it shows up a few places that don't include config.h at
>> all (including some that include ansidecl.h, which requires config.h for
>> proper operation).
>>
>> All relevant configury regenerated.
>>
>> Also touches GDB machinery, so gdb-patches is Cc:ed.
>>
>> Iain Sandoe Cc:ed: Iain, if you disagree with my rather nasty approach
>> here, I'd be interested in anything better. (The need to use %top in
>> binutils/arlex.l is slightly worrying. It's not in POSIX, but
>> we need something like it or we can't include config.h before the
>> system headers it must precede. (Including config.h in libiberty.h
>> won't work for the same reason.)
>
> What does this mean compatibility-wise? I.e. when did relevant tools (no
> idea which one it would be on the BSDs) start supporting %top?
I have no better idea - unless there’s a way to down-scope the addition to
GCC-local.
Adding folks who are currently working on updating GCC’s configury…
Iain
>
> Jan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Fix libiberty.h inclusion on non-glibc hosts tree-wide
2026-11-18 0:49 [PATCH] Fix libiberty.h inclusion on non-glibc hosts tree-wide Nick Alcock
2026-11-18 7:24 ` Jan Beulich
@ 2026-11-18 8:39 ` Sam James
2026-11-18 12:00 ` Nick Alcock
2026-11-19 20:35 ` Tom Tromey
2 siblings, 1 reply; 10+ messages in thread
From: Sam James @ 2026-11-18 8:39 UTC (permalink / raw)
To: Nick Alcock; +Cc: binutils, gdb-patches, iain
[-- Attachment #1: Type: text/plain, Size: 1945 bytes --]
Nick Alcock <nix@esperi.org.uk> writes:
> In 2025, Iain Sandoe added memrchr support to libiberty.h. This requires
> a new AC_CHECK_FUNCS of memrchr in every project that transitively
> includes it, or builds on non-glibc, non-Linux hosts will fail (observed
> on FreeBSD 15).
That doesn't sound right to me as stated: it would mean nobody has reported or
tested that in over a year, even for say musl? Or do you mean 'non-glibc
and non-Linux'? (I guess you do based on the condition in libiberty.h
now I look).
Anyway, does it really require that?
include/libiberty.h has:
/* Make memrchr available on systems that do not have it. */
#if !defined (__GNU_LIBRARY__ ) && !defined (__linux__) && \
!defined (HAVE_MEMRCHR)
extern void *memrchr(const void *, int, size_t);
#endif
so on say, FreeBSD, I would expect this to be used. Then you get the
link-time definition from libiberty?
Can you show me what the failure is please?
>
> Fix trivial, but a tad invasive, since a lot of projects include
> libiberty.h, and it shows up a few places that don't include config.h at
> all (including some that include ansidecl.h, which requires config.h for
> proper operation).
>
> All relevant configury regenerated.
>
> Also touches GDB machinery, so gdb-patches is Cc:ed.
>
> Iain Sandoe Cc:ed: Iain, if you disagree with my rather nasty approach
> here, I'd be interested in anything better. (The need to use %top in
> binutils/arlex.l is slightly worrying. It's not in POSIX, but
> we need something like it or we can't include config.h before the
> system headers it must precede. (Including config.h in libiberty.h
> won't work for the same reason.)
>
> But if you don't do this, you can't compile binutils/arlex.c on
> FreeBSD any more (or any non-Linux, non-glibc system).
>
Sorry if I'm missing something obvious here, it's a busy fortnight
for me but I wanted to reply before we do something that may be the
wrong direction.
sam
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 418 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Fix libiberty.h inclusion on non-glibc hosts tree-wide
2026-11-18 7:41 ` Iain Sandoe
@ 2026-11-18 11:50 ` Nick Alcock
0 siblings, 0 replies; 10+ messages in thread
From: Nick Alcock @ 2026-11-18 11:50 UTC (permalink / raw)
To: Iain Sandoe; +Cc: GDB Patches, GCC Binutils, Jan Beulich, sam, pietro
On 18 Nov 2026, Iain Sandoe spake thusly:
> @sam, @pietro … any ideas most welcome.
>
>> On 18 Nov 2026, at 12:24, Jan Beulich <jbeulich@suse.com> wrote:
>>
>> On 18.11.2026 01:49, Nick Alcock wrote:
>>> In 2025, Iain Sandoe added memrchr support to libiberty.h. This requires
>>> a new AC_CHECK_FUNCS of memrchr in every project that transitively
>>> includes it, or builds on non-glibc, non-Linux hosts will fail (observed
>>> on FreeBSD 15).
>
> In a way, it’s a nit surprising to find a *BSD having an issue (since it was a
> BSD derivative that prompted adding this)…but that’s life :)
I'm only surprised it took so long to uncover. Surely I can't be the
only person testing on FreeBSD...
>>> Iain Sandoe Cc:ed: Iain, if you disagree with my rather nasty approach
>>> here, I'd be interested in anything better. (The need to use %top in
>>> binutils/arlex.l is slightly worrying. It's not in POSIX, but
>>> we need something like it or we can't include config.h before the
>>> system headers it must precede. (Including config.h in libiberty.h
>>> won't work for the same reason.)
>>
>> What does this mean compatibility-wise? I.e. when did relevant tools (no
>> idea which one it would be on the BSDs) start supporting %top?
>
> I have no better idea - unless there’s a way to down-scope the addition to
> GCC-local.
Or at least move the prototype there, or put it behind some sort of
guard (it's a shame there isn't a CHECKED_* to go with HAVE_* for things
like this, so you could skip the prototype unless the configure check
was done: if it wasn't done, odds are that subproject won't call the
function anyway.)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Fix libiberty.h inclusion on non-glibc hosts tree-wide
2026-11-18 8:39 ` Sam James
@ 2026-11-18 12:00 ` Nick Alcock
2026-11-18 12:12 ` Sam James
0 siblings, 1 reply; 10+ messages in thread
From: Nick Alcock @ 2026-11-18 12:00 UTC (permalink / raw)
To: Sam James; +Cc: binutils, gdb-patches, iain
On 18 Nov 2026, Sam James stated:
> Nick Alcock <nix@esperi.org.uk> writes:
>
>> In 2025, Iain Sandoe added memrchr support to libiberty.h. This requires
>> a new AC_CHECK_FUNCS of memrchr in every project that transitively
>> includes it, or builds on non-glibc, non-Linux hosts will fail (observed
>> on FreeBSD 15).
>
> That doesn't sound right to me as stated: it would mean nobody has reported or
> tested that in over a year, even for say musl? Or do you mean 'non-glibc
> and non-Linux'? (I guess you do based on the condition in libiberty.h
> now I look).
>
> Anyway, does it really require that?
>
> include/libiberty.h has:
>
> /* Make memrchr available on systems that do not have it. */
> #if !defined (__GNU_LIBRARY__ ) && !defined (__linux__) && \
> !defined (HAVE_MEMRCHR)
> extern void *memrchr(const void *, int, size_t);
> #endif
>
> so on say, FreeBSD, I would expect this to be used. Then you get the
> link-time definition from libiberty?
Like glibc, FreeBSD these days defines memrchr but uses extra macro
magic which disagrees with a redefinition of the prototype unless the
prototype is in scope. So if you don't check for it in the subproject's
configury, all those tests fail and we hit the prototype and then
explode.
Maybe the right fix is to also add a #ifndef memrchr outside all the
others, on the grounds that if the system already defines memrchr as a
macro we are certain to not need to redefine it? The same might be worth
doing to the declarations of the other POSIX-specified things in
libiberty.h (of which there are a quite a few, and quite a few
AC_CHECK_FUNCS of them in projects that don't use them just to stop
things breaking at #include time).
> Can you show me what the failure is please?
CC targets.lo
In file included from /usr/include/stdio.h:38,
from ../../bfd/sysdep.h:30,
from ../../bfd/targets.c:22:
../../bfd/../include/libiberty.h:226:14: error: expected identifier or '(' before '_Generic'
226 | extern void *memrchr(const void *, int, size_t);
| ^~~~~~~
gmake[3]: *** [Makefile:2329: targets.lo] Error 1
gmake[3]: *** Waiting for unfinished jobs....
(and so on for every other affected file.)
... because on FreeBSD, memrchr is a macro:
#define memrchr(b, c, n) __qualsel((b), \
(const void *)(memrchr)((b), (c), (n)), (memrchr)((b), (c), (n)))
(where __qualsel is a _Generic usage.)
>> Fix trivial, but a tad invasive, since a lot of projects include
>> libiberty.h, and it shows up a few places that don't include config.h at
>> all (including some that include ansidecl.h, which requires config.h for
>> proper operation).
>>
>> All relevant configury regenerated.
>>
>> Also touches GDB machinery, so gdb-patches is Cc:ed.
>>
>> Iain Sandoe Cc:ed: Iain, if you disagree with my rather nasty approach
>> here, I'd be interested in anything better. (The need to use %top in
>> binutils/arlex.l is slightly worrying. It's not in POSIX, but
>> we need something like it or we can't include config.h before the
>> system headers it must precede. (Including config.h in libiberty.h
>> won't work for the same reason.)
>>
>> But if you don't do this, you can't compile binutils/arlex.c on
>> FreeBSD any more (or any non-Linux, non-glibc system).
>
> Sorry if I'm missing something obvious here, it's a busy fortnight
> for me but I wanted to reply before we do something that may be the
> wrong direction.
I spent the entire time I was working on this commit thinking I was
missing something obvious. Hence the need for review :)
--
NULL && (void)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Fix libiberty.h inclusion on non-glibc hosts tree-wide
2026-11-18 12:00 ` Nick Alcock
@ 2026-11-18 12:12 ` Sam James
2026-11-18 17:18 ` Nix
0 siblings, 1 reply; 10+ messages in thread
From: Sam James @ 2026-11-18 12:12 UTC (permalink / raw)
To: Nick Alcock; +Cc: binutils, gdb-patches, iain
[-- Attachment #1: Type: text/plain, Size: 3949 bytes --]
Nick Alcock <nix@esperi.org.uk> writes:
> On 18 Nov 2026, Sam James stated:
>
>> Nick Alcock <nix@esperi.org.uk> writes:
>>
>>> In 2025, Iain Sandoe added memrchr support to libiberty.h. This requires
>>> a new AC_CHECK_FUNCS of memrchr in every project that transitively
>>> includes it, or builds on non-glibc, non-Linux hosts will fail (observed
>>> on FreeBSD 15).
>>
>> That doesn't sound right to me as stated: it would mean nobody has reported or
>> tested that in over a year, even for say musl? Or do you mean 'non-glibc
>> and non-Linux'? (I guess you do based on the condition in libiberty.h
>> now I look).
>>
>> Anyway, does it really require that?
>>
>> include/libiberty.h has:
>>
>> /* Make memrchr available on systems that do not have it. */
>> #if !defined (__GNU_LIBRARY__ ) && !defined (__linux__) && \
>> !defined (HAVE_MEMRCHR)
>> extern void *memrchr(const void *, int, size_t);
>> #endif
>>
>> so on say, FreeBSD, I would expect this to be used. Then you get the
>> link-time definition from libiberty?
>
> Like glibc, FreeBSD these days defines memrchr but uses extra macro
> magic which disagrees with a redefinition of the prototype unless the
> prototype is in scope. So if you don't check for it in the subproject's
> configury, all those tests fail and we hit the prototype and then
> explode.
>
> Maybe the right fix is to also add a #ifndef memrchr outside all the
> others, on the grounds that if the system already defines memrchr as a
> macro we are certain to not need to redefine it? The same might be worth
> doing to the declarations of the other POSIX-specified things in
> libiberty.h (of which there are a quite a few, and quite a few
> AC_CHECK_FUNCS of them in projects that don't use them just to stop
> things breaking at #include time).
This is what I was going to suggest, but...
>
>> Can you show me what the failure is please?
>
> CC targets.lo
> In file included from /usr/include/stdio.h:38,
> from ../../bfd/sysdep.h:30,
> from ../../bfd/targets.c:22:
> ../../bfd/../include/libiberty.h:226:14: error: expected identifier or '(' before '_Generic'
> 226 | extern void *memrchr(const void *, int, size_t);
> | ^~~~~~~
> gmake[3]: *** [Makefile:2329: targets.lo] Error 1
> gmake[3]: *** Waiting for unfinished jobs....
>
> (and so on for every other affected file.)
>
> ... because on FreeBSD, memrchr is a macro:
>
> #define memrchr(b, c, n) __qualsel((b), \
> (const void *)(memrchr)((b), (c), (n)), (memrchr)((b), (c), (n)))
>
> (where __qualsel is a _Generic usage.)
.. now you show this, I realise why it sounded familiar:
https://gcc.gnu.org/PR127914.
That is, we should just do (memrchr) instead.
>
>>> Fix trivial, but a tad invasive, since a lot of projects include
>>> libiberty.h, and it shows up a few places that don't include config.h at
>>> all (including some that include ansidecl.h, which requires config.h for
>>> proper operation).
>>>
>>> All relevant configury regenerated.
>>>
>>> Also touches GDB machinery, so gdb-patches is Cc:ed.
>>>
>>> Iain Sandoe Cc:ed: Iain, if you disagree with my rather nasty approach
>>> here, I'd be interested in anything better. (The need to use %top in
>>> binutils/arlex.l is slightly worrying. It's not in POSIX, but
>>> we need something like it or we can't include config.h before the
>>> system headers it must precede. (Including config.h in libiberty.h
>>> won't work for the same reason.)
>>>
>>> But if you don't do this, you can't compile binutils/arlex.c on
>>> FreeBSD any more (or any non-Linux, non-glibc system).
>>
>> Sorry if I'm missing something obvious here, it's a busy fortnight
>> for me but I wanted to reply before we do something that may be the
>> wrong direction.
>
> I spent the entire time I was working on this commit thinking I was
> missing something obvious. Hence the need for review :)
:)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 418 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Fix libiberty.h inclusion on non-glibc hosts tree-wide
2026-11-18 12:12 ` Sam James
@ 2026-11-18 17:18 ` Nix
0 siblings, 0 replies; 10+ messages in thread
From: Nix @ 2026-11-18 17:18 UTC (permalink / raw)
To: Sam James; +Cc: binutils, gdb-patches, iain
On 18 Nov 2026, Sam James uttered the following:
> Nick Alcock <nix@esperi.org.uk> writes:
>
>> On 18 Nov 2026, Sam James stated:
>>
>>> Nick Alcock <nix@esperi.org.uk> writes:
>>>
>>>> In 2025, Iain Sandoe added memrchr support to libiberty.h. This requires
>>>> a new AC_CHECK_FUNCS of memrchr in every project that transitively
>>>> includes it, or builds on non-glibc, non-Linux hosts will fail (observed
>>>> on FreeBSD 15).
>>>
>>> That doesn't sound right to me as stated: it would mean nobody has reported or
>>> tested that in over a year, even for say musl? Or do you mean 'non-glibc
>>> and non-Linux'? (I guess you do based on the condition in libiberty.h
>>> now I look).
>>>
>>> Anyway, does it really require that?
>>>
>>> include/libiberty.h has:
>>>
>>> /* Make memrchr available on systems that do not have it. */
>>> #if !defined (__GNU_LIBRARY__ ) && !defined (__linux__) && \
>>> !defined (HAVE_MEMRCHR)
>>> extern void *memrchr(const void *, int, size_t);
>>> #endif
>>>
>>> so on say, FreeBSD, I would expect this to be used. Then you get the
>>> link-time definition from libiberty?
>>
>> Like glibc, FreeBSD these days defines memrchr but uses extra macro
>> magic which disagrees with a redefinition of the prototype unless the
>> prototype is in scope. So if you don't check for it in the subproject's
>> configury, all those tests fail and we hit the prototype and then
>> explode.
>>
>> Maybe the right fix is to also add a #ifndef memrchr outside all the
>> others, on the grounds that if the system already defines memrchr as a
>> macro we are certain to not need to redefine it? The same might be worth
>> doing to the declarations of the other POSIX-specified things in
>> libiberty.h (of which there are a quite a few, and quite a few
>> AC_CHECK_FUNCS of them in projects that don't use them just to stop
>> things breaking at #include time).
>
> This is what I was going to suggest, but...
I've implemented this, including fixing up missing and superfluous
AC_CHECK_DECLs, but...
>>> Can you show me what the failure is please?
>>
>> CC targets.lo
>> In file included from /usr/include/stdio.h:38,
>> from ../../bfd/sysdep.h:30,
>> from ../../bfd/targets.c:22:
>> ../../bfd/../include/libiberty.h:226:14: error: expected identifier or '(' before '_Generic'
>> 226 | extern void *memrchr(const void *, int, size_t);
>> | ^~~~~~~
>> gmake[3]: *** [Makefile:2329: targets.lo] Error 1
>> gmake[3]: *** Waiting for unfinished jobs....
>>
>> (and so on for every other affected file.)
>>
>> ... because on FreeBSD, memrchr is a macro:
>>
>> #define memrchr(b, c, n) __qualsel((b), \
>> (const void *)(memrchr)((b), (c), (n)), (memrchr)((b), (c), (n)))
>>
>> (where __qualsel is a _Generic usage.)
>
> .. now you show this, I realise why it sounded familiar:
> https://gcc.gnu.org/PR127914.
>
> That is, we should just do (memrchr) instead.
... I'll adjust my libiberty.h changes to prototype that way rather than
checking for a macro (and submit patches to GCC's copy in parallel).
--
NULL && (void)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Fix libiberty.h inclusion on non-glibc hosts tree-wide
2026-11-18 0:49 [PATCH] Fix libiberty.h inclusion on non-glibc hosts tree-wide Nick Alcock
2026-11-18 7:24 ` Jan Beulich
2026-11-18 8:39 ` Sam James
@ 2026-11-19 20:35 ` Tom Tromey
2026-11-20 15:25 ` [PATCH v2] Support libiberty functions as macros; fix up AC_CHECK_DECL tree-wide Nick Alcock
2 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2026-11-19 20:35 UTC (permalink / raw)
To: Nick Alcock; +Cc: binutils, gdb-patches, iain
>>>>> "Nick" == Nick Alcock <nix@esperi.org.uk> writes:
Nick> In 2025, Iain Sandoe added memrchr support to libiberty.h. This requires
Nick> a new AC_CHECK_FUNCS of memrchr in every project that transitively
Nick> includes it, or builds on non-glibc, non-Linux hosts will fail (observed
Nick> on FreeBSD 15).
Not really your issue but this would all be a lot simpler if libiberty
made a config.h-style header with its own namespaced names, and then
included this and checked these names from the include/ headers.
That way changes to libiberty wouldn't have to propagate through all the
possible users.
gdb kinds of works around this deficiency with libiberty.m4 but really
that's a failure of encapsulation.
Nick> Iain Sandoe Cc:ed: Iain, if you disagree with my rather nasty approach
Nick> here, I'd be interested in anything better. (The need to use %top in
Nick> binutils/arlex.l is slightly worrying. It's not in POSIX, but
Nick> we need something like it or we can't include config.h before the
Nick> system headers it must precede. (Including config.h in libiberty.h
Nick> won't work for the same reason.)
In gdb we switched to pre-including the "defs.h" file from the compiler
command line, which I guess avoids stuff like this. Though at the same
time I don't think we had this precise problem so I wonder what's up
with that.
The gdb and sim bits here are fine but it sounds like this patch is
going to be handled a different way in libiberty?
thanks,
Tom
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2] Support libiberty functions as macros; fix up AC_CHECK_DECL tree-wide
2026-11-19 20:35 ` Tom Tromey
@ 2026-11-20 15:25 ` Nick Alcock
0 siblings, 0 replies; 10+ messages in thread
From: Nick Alcock @ 2026-11-20 15:25 UTC (permalink / raw)
To: Tom Tromey; +Cc: binutils, gdb-patches, iain
On 19 Nov 2026, Tom Tromey outgrape:
>>>>>> "Nick" == Nick Alcock <nix@esperi.org.uk> writes:
>
> Nick> In 2025, Iain Sandoe added memrchr support to libiberty.h. This requires
> Nick> a new AC_CHECK_FUNCS of memrchr in every project that transitively
> Nick> includes it, or builds on non-glibc, non-Linux hosts will fail (observed
> Nick> on FreeBSD 15).
>
> Not really your issue but this would all be a lot simpler if libiberty
> made a config.h-style header with its own namespaced names, and then
> included this and checked these names from the include/ headers.
It would.
I might work on that after this.
> That way changes to libiberty wouldn't have to propagate through all the
> possible users.
>
> gdb kinds of works around this deficiency with libiberty.m4 but really
> that's a failure of encapsulation.
I'll say.
> Nick> Iain Sandoe Cc:ed: Iain, if you disagree with my rather nasty approach
> Nick> here, I'd be interested in anything better. (The need to use %top in
> Nick> binutils/arlex.l is slightly worrying. It's not in POSIX, but
> Nick> we need something like it or we can't include config.h before the
> Nick> system headers it must precede. (Including config.h in libiberty.h
> Nick> won't work for the same reason.)
>
> In gdb we switched to pre-including the "defs.h" file from the compiler
> command line, which I guess avoids stuff like this. Though at the same
> time I don't think we had this precise problem so I wonder what's up
> with that.
>
>
> The gdb and sim bits here are fine but it sounds like this patch is
> going to be handled a different way in libiberty?
Yeah, I have a slightly different approach now, thuogh the gdb etc bits
are very similar:
(local test matrix finished OK: trybots running and so far seem happy.)
8<----------------------------------->8
From aa01fab60111b4554c5db05b3faf442f7f15f845 Mon Sep 17 00:00:00 2001
From: Nick Alcock <nix@esperi.org.uk>
Date: Mon, 16 Nov 2026 18:25:03 +0000
Subject: [PATCH v2] Support libiberty functions as macros; fix up
AC_CHECK_DECL tree-wide
libiberty.h includes redeclarations of a bunch of possibly-system-
provided functions (mkstemps, etc); but it doesn't properly handle the
case where the system defines these as macros, and has already defined
them when libiberty.h is #included. This has a tendency to cause build
faulures on such systems (glibc is usually explicitly ruled out, which
is a bit of a code smell in itself).
Redeclare in parentheses, avoiding any macro definition. This lets us
avoid AC_CHECK_DECLing for these functions unnecessarily in subprojects
that don't use them, since the redeclarations will no longer fail: audit
the tree for unnecessary and missing AC_CHECK_DECLs of the functions
that libiberty.h checks for, and missing ones that are nonetheless used.
(Alas, there are more missing ones than redundant ones.)
All relevant configury regenerated.
Also touches GDB machinery, so gdb-patches is Cc:ed.
include/
* libiberty.h: Wrap POSIX-specified function redeclarations in
parens to protect against prior declaration as macros.
bfd/
* configure.ac: Add missing decls; remove unnecessary ones.
* config.in: Regenerate.
* configure: Likewise.
binutils/
* configure.ac: Add missing decls.
* config.in: Regenerate.
* configure: Likewise.
gas/
* configure.ac: Add missing decls.
* config.in: Regenerate.
* configure: Likewise.
gdbsupport/
* libiberty.m4: Add missing decls.
* config.in: Regenerate.
* configure: Likewise.
sim/
* config.h.in: Regenerate.
* configure: Likewise.
gdb/
* config.in: Regenerate.
* configure: Likewise.
gdbserver/
* config.in: Regenerate.
* configure: Likewise.
gprof/
* configure.ac: Add missing decls.
* gconfig.in: Regenerate.
* configure: Likewise.
gprofng/
* configure.ac: Add missing decls.
* common/config.h.in: Regenerate.
* configure: Likewise.
gold/
* configure.ac: Add missing decls; remove unnecessary ones.
* config.in: Regenerate.
* configure: Likewise.
ld/
* configure.ac: Add missing decls.
* config.in: Regenerate.
* configure: Likewise.
libctf/
* configure.ac: Add missing decls.
* config.h.in: Regenerate.
* configure: Likewise.
opcodes/
* configure.ac: Add missing decls; remove unnecessary ones.
* config.in: Regenerate.
* configure: Likewise.
---
bfd/config.in | 24 +++++--
bfd/configure | 60 +++++++++++++++---
bfd/configure.ac | 2 +-
binutils/config.in | 16 +++++
binutils/configure | 40 ++++++++++++
binutils/configure.ac | 2 +-
gas/config.in | 23 +++++++
gas/configure | 60 ++++++++++++++++++
gas/configure.ac | 2 +-
gdb/config.in | 8 +++
gdb/configure | 22 +++++++
gdbserver/config.in | 8 +++
gdbserver/configure | 22 +++++++
gdbsupport/config.in | 8 +++
gdbsupport/configure | 22 +++++++
gdbsupport/libiberty.m4 | 4 +-
gold/config.in | 19 +++---
gold/configure | 126 +++++++++++++++++++++----------------
gold/configure.ac | 4 +-
gprof/configure | 61 +++++++++++++++++-
gprof/configure.ac | 1 +
gprof/gconfig.in | 4 ++
gprofng/common/config.h.in | 24 +++++++
gprofng/configure | 70 +++++++++++++++++++++
gprofng/configure.ac | 2 +-
include/libiberty.h | 54 ++++++++--------
ld/config.in | 16 +++++
ld/configure | 50 +++++++++++++++
ld/configure.ac | 2 +-
libctf/config.h.in | 4 ++
libctf/configure | 10 +++
libctf/configure.ac | 2 +-
opcodes/config.in | 20 ++++--
opcodes/configure | 36 ++++++++++-
opcodes/configure.ac | 2 +-
sim/config.h.in | 8 +++
sim/configure | 22 +++++++
37 files changed, 737 insertions(+), 123 deletions(-)
diff --git a/bfd/config.in b/bfd/config.in
index 3efd3dc3ce1..302e0b2040c 100644
--- a/bfd/config.in
+++ b/bfd/config.in
@@ -40,10 +40,6 @@
don't. */
#undef HAVE_DECL_ASPRINTF
-/* Define to 1 if you have the declaration of `basename', and to 0 if you
- don't. */
-#undef HAVE_DECL_BASENAME
-
/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
#undef HAVE_DECL_FFS
@@ -67,6 +63,10 @@
don't. */
#undef HAVE_DECL_FTELLO64
+/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
+ don't. */
+#undef HAVE_DECL_SNPRINTF
+
/* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't.
*/
#undef HAVE_DECL_STPCPY
@@ -75,6 +75,18 @@
don't. */
#undef HAVE_DECL_STRNLEN
+/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
+ */
+#undef HAVE_DECL_STRTOL
+
+/* Define to 1 if you have the declaration of `strtoll', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRTOLL
+
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRTOUL
+
/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
don't. */
#undef HAVE_DECL_STRTOULL
@@ -83,6 +95,10 @@
don't. */
#undef HAVE_DECL_VASPRINTF
+/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
+ don't. */
+#undef HAVE_DECL_VSNPRINTF
+
/* Define to 1 if you have the declaration of `___lc_codepage_func', and to 0
if you don't. */
#undef HAVE_DECL____LC_CODEPAGE_FUNC
diff --git a/bfd/configure b/bfd/configure
index d010a3f9aa6..e631ac2a892 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -15142,16 +15142,6 @@ fi
done
-ac_fn_c_check_decl "$LINENO" "basename" "ac_cv_have_decl_basename" "$ac_includes_default"
-if test "x$ac_cv_have_decl_basename" = xyes; then :
- ac_have_decl=1
-else
- ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_BASENAME $ac_have_decl
-_ACEOF
ac_fn_c_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" "$ac_includes_default"
if test "x$ac_cv_have_decl_ffs" = xyes; then :
ac_have_decl=1
@@ -15192,6 +15182,26 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_VASPRINTF $ac_have_decl
_ACEOF
+ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_snprintf" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "vsnprintf" "ac_cv_have_decl_vsnprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_vsnprintf" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_VSNPRINTF $ac_have_decl
+_ACEOF
ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
if test "x$ac_cv_have_decl_strnlen" = xyes; then :
ac_have_decl=1
@@ -15202,6 +15212,36 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STRNLEN $ac_have_decl
_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoll" "ac_cv_have_decl_strtoll" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoll" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOLL $ac_have_decl
+_ACEOF
ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
if test "x$ac_cv_have_decl_strtoull" = xyes; then :
ac_have_decl=1
diff --git a/bfd/configure.ac b/bfd/configure.ac
index 0630973a11d..d0f077f15ff 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -222,7 +222,7 @@ AC_CHECK_HEADERS(fcntl.h sys/file.h sys/resource.h sys/stat.h sys/types.h \
AC_CHECK_FUNCS(fcntl fdopen fileno fls getgid getpagesize getrlimit getuid \
sysconf)
-AC_CHECK_DECLS([basename, ffs, stpcpy, asprintf, vasprintf, strnlen, strtoull])
+AC_CHECK_DECLS([ffs, stpcpy, asprintf, vasprintf, snprintf, vsnprintf, strnlen, strtol, strtoul, strtoll, strtoull])
AC_CHECK_DECLS([___lc_codepage_func], [], [], [[#include <locale.h>]])
BFD_BINARY_FOPEN
diff --git a/binutils/config.in b/binutils/config.in
index 3c3b547e320..60d8d9bf025 100644
--- a/binutils/config.in
+++ b/binutils/config.in
@@ -61,6 +61,10 @@
/* Is the prototype for getopt in <unistd.h> in the expected format? */
#undef HAVE_DECL_GETOPT
+/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
+ don't. */
+#undef HAVE_DECL_SNPRINTF
+
/* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't.
*/
#undef HAVE_DECL_STPCPY
@@ -69,6 +73,18 @@
don't. */
#undef HAVE_DECL_STRNLEN
+/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
+ */
+#undef HAVE_DECL_STRTOL
+
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRTOUL
+
+/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
+ don't. */
+#undef HAVE_DECL_VSNPRINTF
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
diff --git a/binutils/configure b/binutils/configure
index c455cb4c0d9..5f54319c721 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -15852,6 +15852,46 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STRNLEN $ac_have_decl
_ACEOF
+ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_snprintf" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "vsnprintf" "ac_cv_have_decl_vsnprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_vsnprintf" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_VSNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
# Link in zlib/zstd if we can. This allows us to read compressed debug
diff --git a/binutils/configure.ac b/binutils/configure.ac
index e9fda4f42bb..abfaf7eb76e 100644
--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -278,7 +278,7 @@ if test $bu_cv_header_utime_h = yes; then
AC_DEFINE(HAVE_GOOD_UTIME_H, 1, [Does <utime.h> define struct utimbuf?])
fi
-AC_CHECK_DECLS([environ, getc_unlocked, stpcpy, strnlen])
+AC_CHECK_DECLS([environ, getc_unlocked, stpcpy, strnlen, snprintf, vsnprintf, strtol, strtoul])
# Link in zlib/zstd if we can. This allows us to read compressed debug
# sections. This is used only by readelf.c (objdump uses bfd for
diff --git a/gas/config.in b/gas/config.in
index 33482aa73dc..fd48752497b 100644
--- a/gas/config.in
+++ b/gas/config.in
@@ -93,6 +93,9 @@
*/
#undef HAVE_DCGETTEXT
+/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
+#undef HAVE_DECL_FFS
+
/* Is the prototype for getopt in <unistd.h> in the expected format? */
#undef HAVE_DECL_GETOPT
@@ -100,10 +103,30 @@
don't. */
#undef HAVE_DECL_MEMPCPY
+/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
+ don't. */
+#undef HAVE_DECL_SNPRINTF
+
/* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't.
*/
#undef HAVE_DECL_STPCPY
+/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
+ */
+#undef HAVE_DECL_STRTOL
+
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRTOUL
+
+/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRTOULL
+
+/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
+ don't. */
+#undef HAVE_DECL_VSNPRINTF
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
diff --git a/gas/configure b/gas/configure
index bf3ccf3006d..2fe9eae96f7 100755
--- a/gas/configure
+++ b/gas/configure
@@ -16029,6 +16029,66 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STPCPY $ac_have_decl
_ACEOF
+ac_fn_c_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" "$ac_includes_default"
+if test "x$ac_cv_have_decl_ffs" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FFS $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_snprintf" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "vsnprintf" "ac_cv_have_decl_vsnprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_vsnprintf" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_VSNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoull" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOULL $ac_have_decl
+_ACEOF
diff --git a/gas/configure.ac b/gas/configure.ac
index 09089b395c5..7e799d3d0c1 100644
--- a/gas/configure.ac
+++ b/gas/configure.ac
@@ -1021,7 +1021,7 @@ fi
GAS_CHECK_DECL_NEEDED(environ, f, char **f, $gas_test_headers)
GAS_CHECK_DECL_NEEDED(ffs, f, int (*f)(int), $gas_test_headers)
-AC_CHECK_DECLS([mempcpy, stpcpy])
+AC_CHECK_DECLS([mempcpy, stpcpy, ffs, snprintf, vsnprintf, strtol, strtoul, strtoull])
BFD_BINARY_FOPEN
diff --git a/gdb/config.in b/gdb/config.in
index 2e42440d4cc..f73b3b16eda 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -155,10 +155,18 @@
don't. */
#undef HAVE_DECL_GETTHRDS
+/* Define to 1 if you have the declaration of `mkstemps', and to 0 if you
+ don't. */
+#undef HAVE_DECL_MKSTEMPS
+
/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
don't. */
#undef HAVE_DECL_SNPRINTF
+/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRNLEN
+
/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
*/
#undef HAVE_DECL_STRTOL
diff --git a/gdb/configure b/gdb/configure
index e747ffce49f..cb708f1983f 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -29607,6 +29607,17 @@ cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STRTOULL $ac_have_decl
_ACEOF
+ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strnlen" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNLEN $ac_have_decl
+_ACEOF
+
ac_fn_c_check_decl "$LINENO" "strverscmp" "ac_cv_have_decl_strverscmp" "$ac_includes_default"
if test "x$ac_cv_have_decl_strverscmp" = xyes; then :
ac_have_decl=1
@@ -29616,6 +29627,17 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STRVERSCMP $ac_have_decl
+_ACEOF
+
+ac_fn_c_check_decl "$LINENO" "mkstemps" "ac_cv_have_decl_mkstemps" "$ac_includes_default"
+if test "x$ac_cv_have_decl_mkstemps" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MKSTEMPS $ac_have_decl
_ACEOF
ac_fn_c_check_type "$LINENO" "long long" "ac_cv_type_long_long" "$ac_includes_default"
diff --git a/gdbserver/config.in b/gdbserver/config.in
index cf6ebe0a4f2..a73b518fa46 100644
--- a/gdbserver/config.in
+++ b/gdbserver/config.in
@@ -58,10 +58,18 @@
/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
#undef HAVE_DECL_FFS
+/* Define to 1 if you have the declaration of `mkstemps', and to 0 if you
+ don't. */
+#undef HAVE_DECL_MKSTEMPS
+
/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
don't. */
#undef HAVE_DECL_SNPRINTF
+/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRNLEN
+
/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
*/
#undef HAVE_DECL_STRTOL
diff --git a/gdbserver/configure b/gdbserver/configure
index e00e1e1c1c5..bc232efcaa4 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -13180,6 +13180,17 @@ cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STRTOULL $ac_have_decl
_ACEOF
+ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strnlen" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNLEN $ac_have_decl
+_ACEOF
+
ac_fn_c_check_decl "$LINENO" "strverscmp" "ac_cv_have_decl_strverscmp" "$ac_includes_default"
if test "x$ac_cv_have_decl_strverscmp" = xyes; then :
ac_have_decl=1
@@ -13189,6 +13200,17 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STRVERSCMP $ac_have_decl
+_ACEOF
+
+ac_fn_c_check_decl "$LINENO" "mkstemps" "ac_cv_have_decl_mkstemps" "$ac_includes_default"
+if test "x$ac_cv_have_decl_mkstemps" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MKSTEMPS $ac_have_decl
_ACEOF
ac_fn_c_check_type "$LINENO" "long long" "ac_cv_type_long_long" "$ac_includes_default"
diff --git a/gdbsupport/config.in b/gdbsupport/config.in
index ff84ab0d600..91d8e17ecbe 100644
--- a/gdbsupport/config.in
+++ b/gdbsupport/config.in
@@ -58,10 +58,18 @@
/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
#undef HAVE_DECL_FFS
+/* Define to 1 if you have the declaration of `mkstemps', and to 0 if you
+ don't. */
+#undef HAVE_DECL_MKSTEMPS
+
/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
don't. */
#undef HAVE_DECL_SNPRINTF
+/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRNLEN
+
/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
*/
#undef HAVE_DECL_STRTOL
diff --git a/gdbsupport/configure b/gdbsupport/configure
index 7ed4e259ffe..3849420d198 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -10518,6 +10518,17 @@ cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STRTOULL $ac_have_decl
_ACEOF
+ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strnlen" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNLEN $ac_have_decl
+_ACEOF
+
ac_fn_c_check_decl "$LINENO" "strverscmp" "ac_cv_have_decl_strverscmp" "$ac_includes_default"
if test "x$ac_cv_have_decl_strverscmp" = xyes; then :
ac_have_decl=1
@@ -10527,6 +10538,17 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STRVERSCMP $ac_have_decl
+_ACEOF
+
+ac_fn_c_check_decl "$LINENO" "mkstemps" "ac_cv_have_decl_mkstemps" "$ac_includes_default"
+if test "x$ac_cv_have_decl_mkstemps" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MKSTEMPS $ac_have_decl
_ACEOF
ac_fn_c_check_type "$LINENO" "long long" "ac_cv_type_long_long" "$ac_includes_default"
diff --git a/gdbsupport/libiberty.m4 b/gdbsupport/libiberty.m4
index 6c4a83c59a3..ae7a7c03705 100644
--- a/gdbsupport/libiberty.m4
+++ b/gdbsupport/libiberty.m4
@@ -26,6 +26,6 @@ AC_DEFUN([libiberty_INIT],
AC_CHECK_DECLS([basename(char *)])
AC_CHECK_DECLS_ONCE([ffs, asprintf, vasprintf, snprintf, vsnprintf])
- AC_CHECK_DECLS_ONCE([strtol, strtoul, strtoll, strtoull])
- AC_CHECK_DECLS_ONCE([strverscmp])
+ AC_CHECK_DECLS_ONCE([strtol, strtoul, strtoll, strtoull, strnlen])
+ AC_CHECK_DECLS_ONCE([strverscmp, mkstemps])
])
diff --git a/gold/config.in b/gold/config.in
index 3dcb30da9f4..5c866efb6f1 100644
--- a/gold/config.in
+++ b/gold/config.in
@@ -59,10 +59,6 @@
*/
#undef HAVE_DCGETTEXT
-/* Define to 1 if you have the declaration of `asprintf', and to 0 if you
- don't. */
-#undef HAVE_DECL_ASPRINTF
-
/* Define to 1 if you have the declaration of `basename', and to 0 if you
don't. */
#undef HAVE_DECL_BASENAME
@@ -79,9 +75,6 @@
don't. */
#undef HAVE_DECL_BSWAP_64
-/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
-#undef HAVE_DECL_FFS
-
/* Define to 1 if you have the declaration of `memmem', and to 0 if you don't.
*/
#undef HAVE_DECL_MEMMEM
@@ -94,9 +87,17 @@
don't. */
#undef HAVE_DECL_STRNDUP
-/* Define to 1 if you have the declaration of `strverscmp', and to 0 if you
+/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
+ */
+#undef HAVE_DECL_STRTOL
+
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
don't. */
-#undef HAVE_DECL_STRVERSCMP
+#undef HAVE_DECL_STRTOUL
+
+/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRTOULL
/* Define to 1 if you have the declaration of `vasprintf', and to 0 if you
don't. */
diff --git a/gold/configure b/gold/configure
index 36fb3a0085c..6735f28b018 100755
--- a/gold/configure
+++ b/gold/configure
@@ -12000,26 +12000,6 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_BASENAME $ac_have_decl
_ACEOF
-ac_fn_c_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" "$ac_includes_default"
-if test "x$ac_cv_have_decl_ffs" = xyes; then :
- ac_have_decl=1
-else
- ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_FFS $ac_have_decl
-_ACEOF
-ac_fn_c_check_decl "$LINENO" "asprintf" "ac_cv_have_decl_asprintf" "$ac_includes_default"
-if test "x$ac_cv_have_decl_asprintf" = xyes; then :
- ac_have_decl=1
-else
- ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_ASPRINTF $ac_have_decl
-_ACEOF
ac_fn_c_check_decl "$LINENO" "vasprintf" "ac_cv_have_decl_vasprintf" "$ac_includes_default"
if test "x$ac_cv_have_decl_vasprintf" = xyes; then :
ac_have_decl=1
@@ -12050,15 +12030,55 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_VSNPRINTF $ac_have_decl
_ACEOF
-ac_fn_c_check_decl "$LINENO" "strverscmp" "ac_cv_have_decl_strverscmp" "$ac_includes_default"
-if test "x$ac_cv_have_decl_strverscmp" = xyes; then :
+ac_fn_c_check_decl "$LINENO" "strndup" "ac_cv_have_decl_strndup" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strndup" = xyes; then :
ac_have_decl=1
else
ac_have_decl=0
fi
cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_STRVERSCMP $ac_have_decl
+#define HAVE_DECL_STRNDUP $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "memmem" "ac_cv_have_decl_memmem" "$ac_includes_default"
+if test "x$ac_cv_have_decl_memmem" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MEMMEM $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoull" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOULL $ac_have_decl
_ACEOF
@@ -12443,26 +12463,6 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_BASENAME $ac_have_decl
_ACEOF
-ac_fn_cxx_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" "$ac_includes_default"
-if test "x$ac_cv_have_decl_ffs" = xyes; then :
- ac_have_decl=1
-else
- ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_FFS $ac_have_decl
-_ACEOF
-ac_fn_cxx_check_decl "$LINENO" "asprintf" "ac_cv_have_decl_asprintf" "$ac_includes_default"
-if test "x$ac_cv_have_decl_asprintf" = xyes; then :
- ac_have_decl=1
-else
- ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_ASPRINTF $ac_have_decl
-_ACEOF
ac_fn_cxx_check_decl "$LINENO" "vasprintf" "ac_cv_have_decl_vasprintf" "$ac_includes_default"
if test "x$ac_cv_have_decl_vasprintf" = xyes; then :
ac_have_decl=1
@@ -12493,16 +12493,6 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_VSNPRINTF $ac_have_decl
_ACEOF
-ac_fn_cxx_check_decl "$LINENO" "strverscmp" "ac_cv_have_decl_strverscmp" "$ac_includes_default"
-if test "x$ac_cv_have_decl_strverscmp" = xyes; then :
- ac_have_decl=1
-else
- ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_STRVERSCMP $ac_have_decl
-_ACEOF
ac_fn_cxx_check_decl "$LINENO" "strndup" "ac_cv_have_decl_strndup" "$ac_includes_default"
if test "x$ac_cv_have_decl_strndup" = xyes; then :
ac_have_decl=1
@@ -12523,6 +12513,36 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_MEMMEM $ac_have_decl
_ACEOF
+ac_fn_cxx_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_cxx_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_cxx_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoull" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOULL $ac_have_decl
+_ACEOF
# Use of ::std::tr1::unordered_map::rehash causes undefined symbols
diff --git a/gold/configure.ac b/gold/configure.ac
index 89348b660be..e181fa842aa 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -620,7 +620,7 @@ dnl We have to check these in C, not C++, because autoconf generates
dnl tests which have no type information, and current glibc provides
dnl multiple declarations of functions like basename when compiling
dnl with C++.
-AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp])
+AC_CHECK_DECLS([basename, vasprintf, snprintf, vsnprintf, strndup, memmem, strtol, strtoul, strtoull])
dnl Check if gcc supports the -gpubnames option.
dnl Use -Werror in case of compilers that make unknown -g options warnings.
@@ -663,7 +663,7 @@ esac
AC_SUBST(DLOPEN_LIBS)
AC_CHECK_FUNCS(mallinfo mallinfo2 posix_fallocate fallocate readv sysconf times mkdtemp)
-AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp, strndup, memmem])
+AC_CHECK_DECLS([basename, vasprintf, snprintf, vsnprintf, strndup, memmem, strtol, strtoul, strtoull])
# Use of ::std::tr1::unordered_map::rehash causes undefined symbols
# at link time with some versions of GCC.
diff --git a/gprof/configure b/gprof/configure
index f2c7218ecbf..f279abbf15f 100755
--- a/gprof/configure
+++ b/gprof/configure
@@ -1903,6 +1903,52 @@ $as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_func
+
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ as_decl_name=`echo $2|sed 's/ *(.*//'`
+ as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+ (void) $as_decl_use;
+#else
+ (void) $as_decl_name;
+#endif
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
@@ -11029,7 +11075,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11032 "configure"
+#line 11078 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11135,7 +11181,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11138 "configure"
+#line 11184 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11764,6 +11810,17 @@ _ACEOF
fi
done
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+
ALL_LINGUAS="bg da de eo es fi fr ga hu id it ja ms nl pt_BR ro ru rw sr sv tr uk vi"
diff --git a/gprof/configure.ac b/gprof/configure.ac
index 91e7a9afb75..a72f3690cce 100644
--- a/gprof/configure.ac
+++ b/gprof/configure.ac
@@ -41,6 +41,7 @@ ACX_LARGEFILE
# These are in addition to what is made available in bfd/.
AC_CHECK_HEADERS(sys/time.h)
AC_CHECK_FUNCS(setitimer)
+AC_CHECK_DECLS([strtoul])
ALL_LINGUAS="bg da de eo es fi fr ga hu id it ja ms nl pt_BR ro ru rw sr sv tr uk vi"
ZW_GNU_GETTEXT_SISTER_DIR
diff --git a/gprof/gconfig.in b/gprof/gconfig.in
index f8cf42db7cc..a80b39fd8d9 100644
--- a/gprof/gconfig.in
+++ b/gprof/gconfig.in
@@ -19,6 +19,10 @@
/* Is the prototype for getopt in <unistd.h> in the expected format? */
#undef HAVE_DECL_GETOPT
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRTOUL
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
diff --git a/gprofng/common/config.h.in b/gprofng/common/config.h.in
index 5f2c1278c95..dca17db2042 100644
--- a/gprofng/common/config.h.in
+++ b/gprofng/common/config.h.in
@@ -19,6 +19,30 @@
don't. */
#undef HAVE_DECL_BASENAME
+/* Define to 1 if you have the declaration of `mkstemps', and to 0 if you
+ don't. */
+#undef HAVE_DECL_MKSTEMPS
+
+/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
+ don't. */
+#undef HAVE_DECL_SNPRINTF
+
+/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
+ */
+#undef HAVE_DECL_STRTOL
+
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRTOUL
+
+/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRTOULL
+
+/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
+ don't. */
+#undef HAVE_DECL_VSNPRINTF
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
diff --git a/gprofng/configure b/gprofng/configure
index 0888933579b..9f1a758f806 100755
--- a/gprofng/configure
+++ b/gprofng/configure
@@ -17613,6 +17613,76 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_BASENAME $ac_have_decl
_ACEOF
+ac_fn_c_check_decl "$LINENO" "mkstemps" "ac_cv_have_decl_mkstemps" "$ac_includes_default"
+if test "x$ac_cv_have_decl_mkstemps" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MKSTEMPS $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_snprintf" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "vsnprintf" "ac_cv_have_decl_vsnprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_vsnprintf" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_VSNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoull" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOULL $ac_have_decl
+_ACEOF
for ac_func in clock_gettime strsignal
do :
diff --git a/gprofng/configure.ac b/gprofng/configure.ac
index 3a2eb0265dd..87fb223b583 100644
--- a/gprofng/configure.ac
+++ b/gprofng/configure.ac
@@ -245,7 +245,7 @@ AC_SUBST(GPROFNG_NO_SWITCH_CFLAGS)
AC_SUBST(GPROFNG_CPPFLAGS, [${gprofng_cppflags}])
AC_SUBST(NOLTO_CFLAGS, [${nolto_cflags}])
-AC_CHECK_DECLS([basename])
+AC_CHECK_DECLS([basename, mkstemps, snprintf, vsnprintf, strtol, strtoul, strtoul, strtoull])
AC_CHECK_FUNCS(clock_gettime strsignal)
# For riscv builds inside incomplete environments such as during intermediate
diff --git a/include/libiberty.h b/include/libiberty.h
index bdb491b9b37..e18377ee8f5 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -114,7 +114,7 @@ extern char *expandargstr (const char *, const char *);
|| defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) \
|| defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) \
|| defined (__DragonFly__) || defined (HAVE_DECL_BASENAME)
-extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
+extern char *(basename) (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
#else
/* Do not allow basename to be used if there is no prototype seen. We
either need to use the above prototype or have one from
@@ -213,17 +213,17 @@ extern int fdmatch (int fd1, int fd2);
/* Prototypes vary from system to system, so we only provide a
prototype on systems where we know that we need it. */
#if defined (HAVE_DECL_FFS) && !HAVE_DECL_FFS
-extern int ffs(int);
+extern int (ffs) (int);
#endif
#if defined (HAVE_DECL_MKSTEMPS) && !HAVE_DECL_MKSTEMPS
-extern int mkstemps(char *, int);
+extern int (mkstemps) (char *, int);
#endif
/* Make memrchr available on systems that do not have it. */
#if !defined (__GNU_LIBRARY__ ) && !defined (__linux__) && \
!defined (HAVE_MEMRCHR)
-extern void *memrchr(const void *, int, size_t);
+extern void *(memrchr) (const void *, int, size_t);
#endif
/* Get the working directory. The result is cached, so don't call
@@ -675,11 +675,11 @@ extern void *bsearch_r (const void *, const void *,
int (*)(const void *, const void *, void *),
void *);
-#if defined(HAVE_DECL_ASPRINTF) && !HAVE_DECL_ASPRINTF
+#if defined (HAVE_DECL_ASPRINTF) && !HAVE_DECL_ASPRINTF
/* Like sprintf but provides a pointer to malloc'd storage, which must
be freed by the caller. */
-extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
+extern int (asprintf) (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
#endif
/* Like asprintf but allocates memory without fail. This works like
@@ -687,11 +687,11 @@ extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
extern char *xasprintf (const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_PRINTF_1;
-#if defined(HAVE_DECL_VASPRINTF) && !HAVE_DECL_VASPRINTF
+#if defined (HAVE_DECL_VASPRINTF) && !HAVE_DECL_VASPRINTF
/* Like vsprintf but provides a pointer to malloc'd storage, which
must be freed by the caller. */
-extern int vasprintf (char **, const char *, va_list) ATTRIBUTE_PRINTF(2,0);
+extern int (vasprintf) (char **, const char *, va_list) ATTRIBUTE_PRINTF(2,0);
#endif
/* Like vasprintf but allocates memory without fail. This works like
@@ -699,45 +699,45 @@ extern int vasprintf (char **, const char *, va_list) ATTRIBUTE_PRINTF(2,0);
extern char *xvasprintf (const char *, va_list) ATTRIBUTE_MALLOC ATTRIBUTE_PRINTF(1,0);
-#if defined(HAVE_DECL_SNPRINTF) && !HAVE_DECL_SNPRINTF
+#if defined (HAVE_DECL_SNPRINTF) && !HAVE_DECL_SNPRINTF
/* Like sprintf but prints at most N characters. */
-extern int snprintf (char *, size_t, const char *, ...) ATTRIBUTE_PRINTF_3;
+extern int (snprintf) (char *, size_t, const char *, ...) ATTRIBUTE_PRINTF_3;
#endif
-#if defined(HAVE_DECL_VSNPRINTF) && !HAVE_DECL_VSNPRINTF
+#if defined (HAVE_DECL_VSNPRINTF) && !HAVE_DECL_VSNPRINTF
/* Like vsprintf but prints at most N characters. */
-extern int vsnprintf (char *, size_t, const char *, va_list) ATTRIBUTE_PRINTF(3,0);
+extern int (vsnprintf) (char *, size_t, const char *, va_list) ATTRIBUTE_PRINTF(3,0);
#endif
#if defined (HAVE_DECL_STRNLEN) && !HAVE_DECL_STRNLEN
-extern size_t strnlen (const char *, size_t);
+extern size_t (strnlen) (const char *, size_t);
#endif
-#if defined(HAVE_DECL_STRVERSCMP) && !HAVE_DECL_STRVERSCMP
+#if defined (HAVE_DECL_STRVERSCMP) && !HAVE_DECL_STRVERSCMP
/* Compare version strings. */
-extern int strverscmp (const char *, const char *);
+extern int (strverscmp) (const char *, const char *);
#endif
-#if defined(HAVE_DECL_STRTOL) && !HAVE_DECL_STRTOL
-extern long int strtol (const char *nptr,
- char **endptr, int base);
+#if defined (HAVE_DECL_STRTOL) && !HAVE_DECL_STRTOL
+extern long int (strtol) (const char *nptr,
+ char **endptr, int base);
#endif
-#if defined(HAVE_DECL_STRTOUL) && !HAVE_DECL_STRTOUL
-extern unsigned long int strtoul (const char *nptr,
- char **endptr, int base);
+#if defined (HAVE_DECL_STRTOUL) && !HAVE_DECL_STRTOUL
+extern unsigned long int (strtoul) (const char *nptr,
+ char **endptr, int base);
#endif
-#if defined(HAVE_LONG_LONG) && defined(HAVE_DECL_STRTOLL) && !HAVE_DECL_STRTOLL
+#if defined (HAVE_LONG_LONG) && defined (HAVE_DECL_STRTOLL) && !HAVE_DECL_STRTOL
__extension__
-extern long long int strtoll (const char *nptr,
- char **endptr, int base);
+extern long long int (strtoll) (const char *nptr,
+ char **endptr, int base);
#endif
-#if defined(HAVE_LONG_LONG) && defined(HAVE_DECL_STRTOULL) && !HAVE_DECL_STRTOULL
+#if defined (HAVE_LONG_LONG) && defined (HAVE_DECL_STRTOULL) && !HAVE_DECL_STRTOUL
__extension__
-extern unsigned long long int strtoull (const char *nptr,
- char **endptr, int base);
+extern unsigned long long int (strtoull) (const char *nptr,
+ char **endptr, int base);
#endif
/* Set the title of a process */
diff --git a/ld/config.in b/ld/config.in
index 1353370340d..cab652327ea 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -118,10 +118,26 @@
*/
#undef HAVE_DECL_STPCPY
+/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRNLEN
+
+/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
+ */
+#undef HAVE_DECL_STRTOL
+
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRTOUL
+
/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
don't. */
#undef HAVE_DECL_STRTOULL
+/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
+ don't. */
+#undef HAVE_DECL_VSNPRINTF
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
diff --git a/ld/configure b/ld/configure
index cbf80648e1b..1f7c553c774 100755
--- a/ld/configure
+++ b/ld/configure
@@ -18731,6 +18731,56 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STPCPY $ac_have_decl
_ACEOF
+ac_fn_c_check_decl "$LINENO" "vsnprintf" "ac_cv_have_decl_vsnprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_vsnprintf" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_VSNPRINTF $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strnlen" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNLEN $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
if test "x$ac_cv_have_decl_strtoull" = xyes; then :
ac_have_decl=1
diff --git a/ld/configure.ac b/ld/configure.ac
index 8c5e9606ac0..7e2b2540871 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -451,7 +451,7 @@ AC_CHECK_FUNCS(close getrusage glob lseek mkstemp open realpath waitpid mallinfo
BFD_BINARY_FOPEN
-AC_CHECK_DECLS([environ, stpcpy, strtoull])
+AC_CHECK_DECLS([environ, stpcpy, vsnprintf, strtoul, strnlen, strtol, strtoul, strtoull])
GCC_AC_FUNC_MMAP
diff --git a/libctf/config.h.in b/libctf/config.h.in
index 359f1f5ae1d..f670d155493 100644
--- a/libctf/config.h.in
+++ b/libctf/config.h.in
@@ -44,6 +44,10 @@
don't. */
#undef HAVE_DECL_BSWAP_64
+/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
+ don't. */
+#undef HAVE_DECL_SNPRINTF
+
/* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't.
*/
#undef HAVE_DECL_STPCPY
diff --git a/libctf/configure b/libctf/configure
index 8ccc9ac4ee1..00312c0f92c 100755
--- a/libctf/configure
+++ b/libctf/configure
@@ -17015,6 +17015,16 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_VASPRINTF $ac_have_decl
_ACEOF
+ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_snprintf" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SNPRINTF $ac_have_decl
+_ACEOF
ac_fn_c_check_decl "$LINENO" "stpcpy" "ac_cv_have_decl_stpcpy" "$ac_includes_default"
if test "x$ac_cv_have_decl_stpcpy" = xyes; then :
ac_have_decl=1
diff --git a/libctf/configure.ac b/libctf/configure.ac
index 1e1b429c98e..61db028f58f 100644
--- a/libctf/configure.ac
+++ b/libctf/configure.ac
@@ -122,7 +122,7 @@ AC_CHECK_FUNCS(pread)
dnl Check for bswap_{16,32,64}
AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64], [], [], [[#include <byteswap.h>]])
-AC_CHECK_DECLS([asprintf, vasprintf, stpcpy])
+AC_CHECK_DECLS([asprintf, vasprintf, snprintf, stpcpy])
dnl Check for qsort_r. (Taken from gnulib.)
AC_CHECK_FUNCS_ONCE([qsort_r])
diff --git a/opcodes/config.in b/opcodes/config.in
index 36e654292b2..9b5d3268c2b 100644
--- a/opcodes/config.in
+++ b/opcodes/config.in
@@ -30,10 +30,6 @@
don't. */
#undef HAVE_DECL_ASPRINTF
-/* Define to 1 if you have the declaration of `basename', and to 0 if you
- don't. */
-#undef HAVE_DECL_BASENAME
-
/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
don't. */
#undef HAVE_DECL_SNPRINTF
@@ -42,10 +38,26 @@
*/
#undef HAVE_DECL_STPCPY
+/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRNLEN
+
+/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
+ */
+#undef HAVE_DECL_STRTOL
+
+/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRTOUL
+
/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
don't. */
#undef HAVE_DECL_STRTOULL
+/* Define to 1 if you have the declaration of `vasprintf', and to 0 if you
+ don't. */
+#undef HAVE_DECL_VASPRINTF
+
/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
don't. */
#undef HAVE_DECL_VSNPRINTF
diff --git a/opcodes/configure b/opcodes/configure
index 2ae65d00cbd..3c5314b10f1 100755
--- a/opcodes/configure
+++ b/opcodes/configure
@@ -13981,15 +13981,15 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_ASPRINTF $ac_have_decl
_ACEOF
-ac_fn_c_check_decl "$LINENO" "basename" "ac_cv_have_decl_basename" "$ac_includes_default"
-if test "x$ac_cv_have_decl_basename" = xyes; then :
+ac_fn_c_check_decl "$LINENO" "vasprintf" "ac_cv_have_decl_vasprintf" "$ac_includes_default"
+if test "x$ac_cv_have_decl_vasprintf" = xyes; then :
ac_have_decl=1
else
ac_have_decl=0
fi
cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_BASENAME $ac_have_decl
+#define HAVE_DECL_VASPRINTF $ac_have_decl
_ACEOF
ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" "$ac_includes_default"
if test "x$ac_cv_have_decl_snprintf" = xyes; then :
@@ -14011,6 +14011,36 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STPCPY $ac_have_decl
_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtol" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoul" "ac_cv_have_decl_strtoul" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoul" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOUL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strnlen" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNLEN $ac_have_decl
+_ACEOF
ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
if test "x$ac_cv_have_decl_strtoull" = xyes; then :
ac_have_decl=1
diff --git a/opcodes/configure.ac b/opcodes/configure.ac
index c6d8972aa0a..5dcc4a39d03 100644
--- a/opcodes/configure.ac
+++ b/opcodes/configure.ac
@@ -96,7 +96,7 @@ BFD_64_BIT
AC_SUBST(HDEFINES)
AC_PROG_INSTALL
-AC_CHECK_DECLS([asprintf, basename, snprintf, stpcpy, strtoull, vsnprintf])
+AC_CHECK_DECLS([asprintf, vasprintf, snprintf, stpcpy, strtol, strtoul, strnlen, strtoull, vsnprintf])
# Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't do
# since sigsetjmp might only be defined as a macro.
diff --git a/sim/config.h.in b/sim/config.h.in
index 44ff51580c7..0fcfbac19dd 100644
--- a/sim/config.h.in
+++ b/sim/config.h.in
@@ -51,10 +51,18 @@
/* Is the prototype for getopt in <unistd.h> in the expected format? */
#undef HAVE_DECL_GETOPT
+/* Define to 1 if you have the declaration of `mkstemps', and to 0 if you
+ don't. */
+#undef HAVE_DECL_MKSTEMPS
+
/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
don't. */
#undef HAVE_DECL_SNPRINTF
+/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRNLEN
+
/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
*/
#undef HAVE_DECL_STRTOL
diff --git a/sim/configure b/sim/configure
index da4caa57aa1..da1778a5ef1 100755
--- a/sim/configure
+++ b/sim/configure
@@ -14375,6 +14375,17 @@ cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STRTOULL $ac_have_decl
_ACEOF
+ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strnlen" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNLEN $ac_have_decl
+_ACEOF
+
ac_fn_c_check_decl "$LINENO" "strverscmp" "ac_cv_have_decl_strverscmp" "$ac_includes_default"
if test "x$ac_cv_have_decl_strverscmp" = xyes; then :
ac_have_decl=1
@@ -14384,6 +14395,17 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STRVERSCMP $ac_have_decl
+_ACEOF
+
+ac_fn_c_check_decl "$LINENO" "mkstemps" "ac_cv_have_decl_mkstemps" "$ac_includes_default"
+if test "x$ac_cv_have_decl_mkstemps" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_MKSTEMPS $ac_have_decl
_ACEOF
ac_fn_c_check_type "$LINENO" "long long" "ac_cv_type_long_long" "$ac_includes_default"
base-commit: 5678a7bfceb3a6ea18bcde1ae68f7e96c43c998b
prerequisite-patch-id: 6bb7a1f3d29820aec4c1fe7c2b30a99b1c33b604
prerequisite-patch-id: 5e93f3723d2db6831a34d17656b17543529b0809
--
2.56.1.291.g6a80de6356
--
NULL && (void)
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-11-20 15:26 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 0:49 [PATCH] Fix libiberty.h inclusion on non-glibc hosts tree-wide Nick Alcock
2026-11-18 7:24 ` Jan Beulich
2026-11-18 7:41 ` Iain Sandoe
2026-11-18 11:50 ` Nick Alcock
2026-11-18 8:39 ` Sam James
2026-11-18 12:00 ` Nick Alcock
2026-11-18 12:12 ` Sam James
2026-11-18 17:18 ` Nix
2026-11-19 20:35 ` Tom Tromey
2026-11-20 15:25 ` [PATCH v2] Support libiberty functions as macros; fix up AC_CHECK_DECL tree-wide Nick Alcock
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox