Ralf Wildenhues wrote: > * Pedro LamarÃo wrote on Thu, Aug 27, 2009 at 12:24:07AM CEST: > > 2009/8/26 Ralf Wildenhues: > > > > >> The problem is that AC_CHECK_DECLS gets confused by overloaded > > >> functions, and glibc 2.10 has overloaded declarations of basename > > >> and some other string functions for const-correctness. > > > > > > Could you show the config.log snippet that shows the failed test? > > > Is this a new error due to the autotools upgrade, or new due to > > > glibc 2.10? > > > > I think this is new in glibc 2.10, for the reasons given by Jason Merrill > > above. > > I've discussed this problem with Jerry Quinn before, and he had a > > tentative patch that worked for me. > > As I understand things, this patch is on hold waiting for a solution > > to the bootstrap comparison problem being discussed in another thread. > > > > I am waiting for a solution to these problems to continue work on the > > std::sort gcc-in-cxx subproject; keeping all these patches up to date > > with trunk is too difficult for me right now. > > Currently, I have a patch to an old revision of the trunk.
> Well, can you post the patch, or did I somehow miss it on the list? > I'd be particularly interested if it tries to fix the Autoconf test > in some sensible way. Here's the patch I sent Pedro: Index: gcc/configure =================================================================== --- gcc/configure (revision 149964) +++ gcc/configure (working copy) @@ -10650,8 +10650,9 @@ + for ac_func in times clock kill getrlimit setrlimit atoll atoq \ - sysconf strsignal getrusage nl_langinfo \ + sysconf strsignal getrusage nl_langinfo basename \ gettimeofday mbstowcs wcswidth mmap mincore setlocale \ clearerr_unlocked feof_unlocked ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked putchar_unlocked putc_unlocked do @@ -12673,11 +12674,10 @@ - for ac_func in getenv atol asprintf sbrk abort atof getcwd getwd \ strsignal strstr strverscmp \ errno snprintf vsnprintf vasprintf malloc realloc calloc \ - free basename getopt clock getpagesize clearerr_unlocked feof_unlocked ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked putchar_unlocked putc_unlocked + free getopt clock getpagesize clearerr_unlocked feof_unlocked ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked putchar_unlocked putc_unlocked do ac_tr_decl=`echo "HAVE_DECL_$ac_func" | $as_tr_cpp` echo "$as_me:$LINENO: checking whether $ac_func is declared" >&5 Index: gcc/config.in =================================================================== --- gcc/config.in (revision 149964) +++ gcc/config.in (working copy) @@ -321,6 +321,12 @@ #endif +/* Define if your assembler supports LWSYNC instructions. */ +#ifndef USED_FOR_TARGET +#undef HAVE_AS_LWSYNC +#endif + + /* Define if your assembler supports mfcr field. */ #ifndef USED_FOR_TARGET #undef HAVE_AS_MFCRF @@ -351,23 +357,18 @@ #endif -/* Define if your assembler supports popcntb instruction. */ +/* Define if your assembler supports popcntb field. */ #ifndef USED_FOR_TARGET #undef HAVE_AS_POPCNTB #endif -/* Define if your assembler supports popcntd instruction. */ +/* Define if your assembler supports POPCNTD instructions. */ #ifndef USED_FOR_TARGET #undef HAVE_AS_POPCNTD #endif -/* Define if your assembler supports lwsync instruction. */ -#ifndef USED_FOR_TARGET -#undef HAVE_AS_LWSYNC -#endif - /* Define if your assembler supports .register. */ #ifndef USED_FOR_TARGET #undef HAVE_AS_REGISTER_PSEUDO_OP @@ -430,6 +431,12 @@ #endif +/* Define to 1 if you have the `basename' function. */ +#ifndef USED_FOR_TARGET +#undef HAVE_BASENAME +#endif + + /* Define to 1 if you have the `clearerr_unlocked' function. */ #ifndef USED_FOR_TARGET #undef HAVE_CLEARERR_UNLOCKED @@ -480,13 +487,6 @@ #endif -/* Define to 1 if we found a declaration for 'basename', otherwise define to - 0. */ -#ifndef USED_FOR_TARGET -#undef HAVE_DECL_BASENAME -#endif - - /* Define to 1 if we found a declaration for 'calloc', otherwise define to 0. */ #ifndef USED_FOR_TARGET Index: gcc/configure.ac =================================================================== --- gcc/configure.ac (revision 149964) +++ gcc/configure.ac (working copy) @@ -1016,7 +1016,7 @@ fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked dnl putchar_unlocked putc_unlocked) AC_CHECK_FUNCS(times clock kill getrlimit setrlimit atoll atoq \ - sysconf strsignal getrusage nl_langinfo \ + sysconf strsignal getrusage nl_langinfo basename \ gettimeofday mbstowcs wcswidth mmap mincore setlocale \ gcc_UNLOCKED_FUNCS) @@ -1068,7 +1068,7 @@ gcc_AC_CHECK_DECLS(getenv atol asprintf sbrk abort atof getcwd getwd \ strsignal strstr strverscmp \ errno snprintf vsnprintf vasprintf malloc realloc calloc \ - free basename getopt clock getpagesize gcc_UNLOCKED_FUNCS, , ,[ + free getopt clock getpagesize gcc_UNLOCKED_FUNCS, , ,[ #include "ansidecl.h" #include "system.h"]) Index: include/libiberty.h =================================================================== --- include/libiberty.h (revision 149964) +++ include/libiberty.h (working copy) @@ -100,7 +100,7 @@ declaration without arguments. If it is 0, we checked and failed to find the declaration so provide a fully prototyped one. If it is 1, we found it so don't provide any declaration at all. */ -#if !HAVE_DECL_BASENAME +#if !HAVE_BASENAME #if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) || defined (HAVE_DECL_BASENAME) extern char *basename (const char *); #else Index: libcpp/configure =================================================================== --- libcpp/configure (revision 149964) +++ libcpp/configure (working copy) @@ -4330,7 +4330,109 @@ done + +for ac_func in basename +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +else ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -4730,8 +4832,110 @@ done + +for ac_func in basename +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF +fi +done + +fi + # Checks for typedefs, structures, and compiler characteristics. echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 @@ -6341,76 +6545,6 @@ fi -echo "$as_me:$LINENO: checking whether basename is declared" >&5 -echo $ECHO_N "checking whether basename is declared... $ECHO_C" >&6 -if test "${ac_cv_have_decl_basename+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -#ifndef basename - char *p = (char *) basename; -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_cxx_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_have_decl_basename=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_have_decl_basename=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_have_decl_basename" >&5 -echo "${ECHO_T}$ac_cv_have_decl_basename" >&6 -if test $ac_cv_have_decl_basename = yes; then - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_BASENAME 1 -_ACEOF - - -else - cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_BASENAME 0 -_ACEOF - - -fi echo "$as_me:$LINENO: checking whether errno is declared" >&5 echo $ECHO_N "checking whether errno is declared... $ECHO_C" >&6 if test "${ac_cv_have_decl_errno+set}" = set; then Index: libcpp/configure.ac =================================================================== --- libcpp/configure.ac (revision 149964) +++ libcpp/configure.ac (working copy) @@ -59,10 +59,12 @@ AC_LANG(C) AC_CHECK_HEADERS(locale.h fcntl.h limits.h stddef.h \ stdlib.h strings.h string.h sys/file.h unistd.h) + AC_CHECK_FUNCS(basename) else AC_LANG(C++) AC_CHECK_HEADERS(locale.h fcntl.h limits.h stddef.h \ stdlib.h strings.h string.h sys/file.h unistd.h) + AC_CHECK_FUNCS(basename) fi # Checks for typedefs, structures, and compiler characteristics. @@ -81,7 +83,7 @@ fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked dnl putchar_unlocked putc_unlocked) AC_CHECK_FUNCS(libcpp_UNLOCKED_FUNCS) -AC_CHECK_DECLS(m4_split(m4_normalize(abort asprintf basename errno getopt \ +AC_CHECK_DECLS(m4_split(m4_normalize(abort asprintf errno getopt \ libcpp_UNLOCKED_FUNCS vasprintf))) # Checks for library functions. Index: libcpp/config.in =================================================================== --- libcpp/config.in (revision 149964) +++ libcpp/config.in (working copy) @@ -22,6 +22,9 @@ */ #undef HAVE_ALLOCA_H +/* Define to 1 if you have the `basename' function. */ +#undef HAVE_BASENAME + /* Define to 1 if you have the `clearerr_unlocked' function. */ #undef HAVE_CLEARERR_UNLOCKED @@ -33,10 +36,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 `clearerr_unlocked', and to 0 if you don't. */ #undef HAVE_DECL_CLEARERR_UNLOCKED