From f4245e06307672302a636632c76fe34aa89cbd73 Mon Sep 17 00:00:00 2001 From: ro Date: Wed, 19 Oct 2011 16:02:30 +0000 Subject: [PATCH] Properly test for madvise on Solaris 10 (PR bootstrap/50777) PR bootstrap/50777 * configure.ac: Save and restore CXXFLAGS around gcc_AC_CHECK_DECLS uses. Check for madvise() declaration with g++ if --enable-build-with-cxx. * configure: Regenerate. * config.in: Regenerate. * ggc-page.c (USING_MADVISE): Also check HAVE_DECL_MADVISE. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180195 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 10 +++++ gcc/config.in | 7 +++ gcc/configure | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- gcc/configure.ac | 20 ++++++++- gcc/ggc-page.c | 5 ++- 5 files changed, 166 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ecf319db019..e67dcbf24c0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2011-10-19 Rainer Orth + + PR bootstrap/50777 + * configure.ac: Save and restore CXXFLAGS around + gcc_AC_CHECK_DECLS uses. + Check for madvise() declaration with g++ if --enable-build-with-cxx. + * configure: Regenerate. + * config.in: Regenerate. + * ggc-page.c (USING_MADVISE): Also check HAVE_DECL_MADVISE. + 2011-10-19 Alexandre Oliva PR debug/49310 diff --git a/gcc/config.in b/gcc/config.in index e8148b6d571..3950e289b7c 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -753,6 +753,13 @@ #endif +/* Define to 1 if we found a declaration for 'madvise', otherwise define to 0. + */ +#ifndef USED_FOR_TARGET +#undef HAVE_DECL_MADVISE +#endif + + /* Define to 1 if we found a declaration for 'malloc', otherwise define to 0. */ #ifndef USED_FOR_TARGET diff --git a/gcc/configure b/gcc/configure index 32542dd455d..0540430dc20 100755 --- a/gcc/configure +++ b/gcc/configure @@ -10415,6 +10415,8 @@ $as_echo "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h # We will need to find libiberty.h and ansidecl.h saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include" +saved_CXXFLAGS="$CXXFLAGS" +CXXFLAGS="$CXXFLAGS -I${srcdir} -I${srcdir}/../include" for ac_func in getenv atol asprintf sbrk abort atof getcwd getwd \ strsignal strstr strverscmp \ errno snprintf vsnprintf vasprintf malloc realloc calloc \ @@ -10719,6 +10721,127 @@ fi done +# g++ on Solaris 10+ defines _XOPEN_SOURCE=600, which hides the madvise() +# prototype. +if test "$ENABLE_BUILD_WITH_CXX" = "yes"; then : + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + for ac_func in madvise +do + ac_tr_decl=`$as_echo "HAVE_DECL_$ac_func" | $as_tr_cpp` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $ac_func is declared" >&5 +$as_echo_n "checking whether $ac_func is declared... " >&6; } +if { as_var=gcc_cv_have_decl_$ac_func; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#undef $ac_tr_decl +#define $ac_tr_decl 1 + + #include "ansidecl.h" + #include "system.h" + + +int +main () +{ +#ifndef $ac_func +char *(*pfn) = (char *(*)) $ac_func ; +#endif + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval "gcc_cv_have_decl_$ac_func=yes" +else + eval "gcc_cv_have_decl_$ac_func=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +if eval "test \"`echo '$gcc_cv_have_decl_'$ac_func`\" = yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } ; cat >>confdefs.h <<_ACEOF +#define $ac_tr_decl 1 +_ACEOF + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } ; cat >>confdefs.h <<_ACEOF +#define $ac_tr_decl 0 +_ACEOF + +fi + +done + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +else + for ac_func in madvise +do + ac_tr_decl=`$as_echo "HAVE_DECL_$ac_func" | $as_tr_cpp` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $ac_func is declared" >&5 +$as_echo_n "checking whether $ac_func is declared... " >&6; } +if { as_var=gcc_cv_have_decl_$ac_func; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#undef $ac_tr_decl +#define $ac_tr_decl 1 + + #include "ansidecl.h" + #include "system.h" + + +int +main () +{ +#ifndef $ac_func +char *(*pfn) = (char *(*)) $ac_func ; +#endif + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "gcc_cv_have_decl_$ac_func=yes" +else + eval "gcc_cv_have_decl_$ac_func=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +if eval "test \"`echo '$gcc_cv_have_decl_'$ac_func`\" = yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } ; cat >>confdefs.h <<_ACEOF +#define $ac_tr_decl 1 +_ACEOF + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } ; cat >>confdefs.h <<_ACEOF +#define $ac_tr_decl 0 +_ACEOF + +fi + +done + + +fi + # More time-related stuff. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct tms" >&5 $as_echo_n "checking for struct tms... " >&6; } @@ -10795,8 +10918,9 @@ $as_echo "#define HAVE_CLOCK_T 1" >>confdefs.h fi -# Restore CFLAGS from before the gcc_AC_NEED_DECLARATIONS tests. +# Restore CFLAGS, CXXFLAGS from before the gcc_AC_NEED_DECLARATIONS tests. CFLAGS="$saved_CFLAGS" +CXXFLAGS="$saved_CXXFLAGS" # Check whether --enable-initfini-array was given. if test "${enable_initfini_array+set}" = set; then : @@ -17948,7 +18072,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17951 "configure" +#line 18075 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18054,7 +18178,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18057 "configure" +#line 18181 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index d19ca077b2e..d63acea68f5 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1094,6 +1094,8 @@ AM_LANGINFO_CODESET # We will need to find libiberty.h and ansidecl.h saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include" +saved_CXXFLAGS="$CXXFLAGS" +CXXFLAGS="$CXXFLAGS -I${srcdir} -I${srcdir}/../include" gcc_AC_CHECK_DECLS(getenv atol asprintf sbrk abort atof getcwd getwd \ strsignal strstr strverscmp \ errno snprintf vsnprintf vasprintf malloc realloc calloc \ @@ -1146,6 +1148,21 @@ gcc_AC_CHECK_DECLS(sigaltstack, , ,[ #include ]) +# g++ on Solaris 10+ defines _XOPEN_SOURCE=600, which hides the madvise() +# prototype. +AS_IF([test "$ENABLE_BUILD_WITH_CXX" = "yes"], + [AC_LANG_PUSH([C++]) + gcc_AC_CHECK_DECLS(madvise, , ,[ + #include "ansidecl.h" + #include "system.h" + ]) + AC_LANG_POP([C++])], + [gcc_AC_CHECK_DECLS(madvise, , ,[ + #include "ansidecl.h" + #include "system.h" + ]) +]) + # More time-related stuff. AC_CACHE_CHECK(for struct tms, ac_cv_struct_tms, [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ @@ -1172,8 +1189,9 @@ if test $gcc_cv_type_clock_t = yes; then [Define if defines clock_t.]) fi -# Restore CFLAGS from before the gcc_AC_NEED_DECLARATIONS tests. +# Restore CFLAGS, CXXFLAGS from before the gcc_AC_NEED_DECLARATIONS tests. CFLAGS="$saved_CFLAGS" +CXXFLAGS="$saved_CXXFLAGS" gcc_AC_INITFINI_ARRAY diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c index 2da99db9cf8..617a49348d7 100644 --- a/gcc/ggc-page.c +++ b/gcc/ggc-page.c @@ -1,6 +1,6 @@ /* "Bag-of-pages" garbage collector for the GNU compiler. Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, - 2010 Free Software Foundation, Inc. + 2010, 2011 Free Software Foundation, Inc. This file is part of GCC. @@ -50,7 +50,8 @@ along with GCC; see the file COPYING3. If not see #define USING_MALLOC_PAGE_GROUPS #endif -#if defined(HAVE_MADVISE) && defined(MADV_DONTNEED) && defined(USING_MMAP) +#if defined(HAVE_MADVISE) && HAVE_DECL_MADVISE && defined(MADV_DONTNEED) \ + && defined(USING_MMAP) # define USING_MADVISE #endif -- 2.11.4.GIT