We need the configure result from the decl check for basename() in the GCC
configuration to match that obtained when configuring libiberty or we get
conflicts when <libgen.h> is included in any TU that also includes "system.h"
or "libiberty.h" directly.

        PR other/119250

gcc/ChangeLog:

        * config.in: Regenerate.
        * configure: Regenerate.
        * configure.ac: Match the configure test in libiberty when checking
        the basename decl.

Signed-off-by: Iain Sandoe <i...@sandoe.co.uk>
---
 gcc/config.in    | 10 ++++++++--
 gcc/configure    | 18 +++++++++++-------
 gcc/configure.ac | 12 ++++++++++--
 3 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/gcc/config.in b/gcc/config.in
index bc60d36a635..0d8a6ba1808 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -941,8 +941,8 @@
 #endif
 
 
-/* Define to 1 if you have the declaration of `basename(const char*)', and to
-   0 if you don't. */
+/* Define to 1 if you have the declaration of `basename(char*)', and to 0 if
+   you don't. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_DECL_BASENAME
 #endif
@@ -1888,6 +1888,12 @@
 #endif
 
 
+/* Define to 1 if you have the <libgen.h> header file. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_LIBGEN_H
+#endif
+
+
 /* Define to 1 if you have the <limits.h> header file. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_LIMITS_H
diff --git a/gcc/configure b/gcc/configure
index ae1d34971e4..063b9ce6701 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -9508,7 +9508,7 @@ fi
 for ac_header in limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \
                 fcntl.h ftw.h unistd.h sys/auxv.h sys/file.h sys/time.h 
sys/mman.h \
                 sys/resource.h sys/param.h sys/times.h sys/stat.h 
sys/locking.h \
-                direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h
+                direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h libgen.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_cxx_check_header_preproc "$LINENO" "$ac_header" "$as_ac_Header"
@@ -12121,10 +12121,14 @@ CXXFLAGS="$CXXFLAGS -I${srcdir} 
-I${srcdir}/../include $GMPINC"
 # normal autoconf function for these.  But force definition of
 # HAVE_DECL_BASENAME like gcc_AC_CHECK_DECLS does, to suppress the bizarre
 # basename handling in libiberty.h.
-as_ac_Symbol=`$as_echo "ac_cv_have_decl_basename(const char*)" | $as_tr_sh`
-ac_fn_cxx_check_decl "$LINENO" "basename(const char*)" "$as_ac_Symbol" "
+# Match the configure test in libiberty so that we have a consistent result.
+as_ac_Symbol=`$as_echo "ac_cv_have_decl_basename(char*)" | $as_tr_sh`
+ac_fn_cxx_check_decl "$LINENO" "basename(char*)" "$as_ac_Symbol" "
 #undef HAVE_DECL_BASENAME
 #define HAVE_DECL_BASENAME 1
+#if HAVE_LIBGEN_H
+# include <libgen.h>
+#endif
 #include \"ansidecl.h\"
 #include \"system.h\"
 "
@@ -12137,10 +12141,10 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_BASENAME $ac_have_decl
 _ACEOF
+
+
 as_ac_Symbol=`$as_echo "ac_cv_have_decl_strstr(const char*,const char*)" | 
$as_tr_sh`
 ac_fn_cxx_check_decl "$LINENO" "strstr(const char*,const char*)" 
"$as_ac_Symbol" "
-#undef HAVE_DECL_BASENAME
-#define HAVE_DECL_BASENAME 1
 #include \"ansidecl.h\"
 #include \"system.h\"
 "
@@ -21480,7 +21484,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21483 "configure"
+#line 21487 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -21586,7 +21590,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21589 "configure"
+#line 21593 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 8ef11e36210..3243472680c 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1366,7 +1366,7 @@ AC_HEADER_TIOCGWINSZ
 AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \
                 fcntl.h ftw.h unistd.h sys/auxv.h sys/file.h sys/time.h 
sys/mman.h \
                 sys/resource.h sys/param.h sys/times.h sys/stat.h 
sys/locking.h \
-                direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h)
+                direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h libgen.h)
 
 # Check for thread headers.
 AC_CHECK_HEADER(thread.h, [have_thread_h=yes], [have_thread_h=])
@@ -1645,9 +1645,17 @@ CXXFLAGS="$CXXFLAGS -I${srcdir} -I${srcdir}/../include 
$GMPINC"
 # normal autoconf function for these.  But force definition of
 # HAVE_DECL_BASENAME like gcc_AC_CHECK_DECLS does, to suppress the bizarre
 # basename handling in libiberty.h.
-AC_CHECK_DECLS([basename(const char*), strstr(const char*,const char*)], , ,[
+# Match the configure test in libiberty so that we have a consistent result.
+AC_CHECK_DECLS([basename(char*)], , ,[
 #undef HAVE_DECL_BASENAME
 #define HAVE_DECL_BASENAME 1
+#if HAVE_LIBGEN_H
+# include <libgen.h>
+#endif
+#include "ansidecl.h"
+#include "system.h"])
+
+AC_CHECK_DECLS([strstr(const char*,const char*)], , ,[
 #include "ansidecl.h"
 #include "system.h"])
 
-- 
2.39.2 (Apple Git-143)

Reply via email to