aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2025-03-12 15:04:31 +0000
committerIain Sandoe <iain@sandoe.co.uk>2025-03-25 19:29:12 +0000
commitf3d07779fdb729c7ee81b8e764921becf8ecf1d0 (patch)
tree0822530dd1dc4b414a8f2328735d17e9e08a6a82
parent737a5760bb24a0a945cc2c916ba452e3f0060c58 (diff)
downloadgcc-f3d07779fdb729c7ee81b8e764921becf8ecf1d0.zip
gcc-f3d07779fdb729c7ee81b8e764921becf8ecf1d0.tar.gz
gcc-f3d07779fdb729c7ee81b8e764921becf8ecf1d0.tar.bz2
libiberty: Append <libgen.h> to AC_CHECK_DECLS [PR119218].
Darwin and Solaris, at least, provide basename() in libc, but only declare it in <libgen.h>. That library is not one of the set in AC_INCLUDES_DEFAULT and so we fail the config test and fall back to the libiberty-provided version. In itself, this is not an issue; however, if we include <libgen.h> and libiberty.h in the same TU we do then get a decl conflict. PR other/119218 libiberty/ChangeLog: * config.in: Regenerate. * configure: Regenerate. * configure.ac: Append <libgen.h> to AC_INCLUDES_DEFAULT when checking for the 'basename' decl. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
-rw-r--r--libiberty/config.in3
-rwxr-xr-xlibiberty/configure12
-rw-r--r--libiberty/configure.ac9
3 files changed, 19 insertions, 5 deletions
diff --git a/libiberty/config.in b/libiberty/config.in
index 1b1f2b0..b055150 100644
--- a/libiberty/config.in
+++ b/libiberty/config.in
@@ -153,6 +153,9 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
+/* Define to 1 if you have the <libgen.h> header file. */
+#undef HAVE_LIBGEN_H
+
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
diff --git a/libiberty/configure b/libiberty/configure
index 38856a0..347719c 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -5745,7 +5745,7 @@ host_makefile_frag=${frag}
# It's OK to check for header files. Although the compiler may not be
# able to link anything, it had better be able to at least compile
# something.
-for ac_header in sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h
+for ac_header in sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h libgen.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_preproc "$LINENO" "$ac_header" "$as_ac_Header"
@@ -7389,7 +7389,12 @@ fi
done
as_ac_Symbol=`$as_echo "ac_cv_have_decl_basename(char *)" | $as_tr_sh`
-ac_fn_c_check_decl "$LINENO" "basename(char *)" "$as_ac_Symbol" "$ac_includes_default"
+ac_fn_c_check_decl "$LINENO" "basename(char *)" "$as_ac_Symbol" "
+$ac_includes_default
+#ifdef HAVE_LIBGEN_H
+# include <libgen.h>
+#endif
+"
if eval test \"x\$"$as_ac_Symbol"\" = x"yes"; then :
ac_have_decl=1
else
@@ -7399,7 +7404,8 @@ 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"
+
+ 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
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index c27e08e..5bad0f9 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -291,7 +291,7 @@ AC_SUBST_FILE(host_makefile_frag)
# It's OK to check for header files. Although the compiler may not be
# able to link anything, it had better be able to at least compile
# something.
-AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h)
+AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h spawn.h libgen.h)
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
@@ -723,7 +723,12 @@ if test -z "${setobjs}"; then
[AC_MSG_RESULT([no])])
AC_CHECK_FUNCS($checkfuncs)
- AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf])
+ AC_CHECK_DECLS([basename(char *)], [], [], [
+AC_INCLUDES_DEFAULT
+#ifdef HAVE_LIBGEN_H
+# include <libgen.h>
+#endif])
+ AC_CHECK_DECLS([ffs, asprintf, vasprintf, snprintf, vsnprintf])
AC_CHECK_DECLS([calloc, getenv, getopt, malloc, realloc])
case "${host}" in
*-*-darwin*) ;; # Darwin's sbrk implementation is deprecated.