This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[build] Properly test for madvise on Solaris 10 (PR bootstrap/50777)


As described in the PR, Solaris 10 bootstrap is currently broken
compiling ggc-page.c in stage2 due to no declaration for madvise().
This happens because g++ defines _XOPEN_SOURCE=600, which hides the
declaration, and configure doesn't check for a declaration at all.

The following patch fixes both issues by checking for a madvise()
declaration separately and doing so with the C++ compiler.

Testing in progress on i386-pc-solaris2.8 (where it worked before),
i386-pc-solaris2.10 (bootstrap broken), i386-pc-solaris2.11 (worked
before), and x86_64-unknown-linux-gnu.

HAVE_MADVISE is 1 everywhere, HAVE_DECL_MADVISE is 1 everwhere except on
Solaris 10 in stages 2 and 3 where g++ is used.

All bootstraps are beyond the point of the breakage now.  Ok for
mainline if they pass?

Thanks.
        Rainer


2011-10-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	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.

# HG changeset patch
# Parent 1fa7cb4d63ec8cf992373dd9ba92615a589542c3
Properly test for madvise on Solaris 10 (PR bootstrap/50777)

diff --git a/gcc/configure.ac b/gcc/configure.ac
--- 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 <signal.h>
 ])
 
+# 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 <time.h> 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
--- 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.  
 #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
 
-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]