This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

3.4 PATCH: Several IRIX 6.5.1[89] ISO C99 fixes


As noticed in the thread starting at

	http://gcc.gnu.org/ml/libstdc++/2003-02/msg00079.html

libstdc++-v3 doesn't bootstrap on IRIX 6.5.18 and up due to the
introduction of several ISO C99 features in system headers and libc.  I now
ran into this problem myself and chose to use a different approach than the
one David suggested in

	http://gcc.gnu.org/ml/libstdc++/2003-02/msg00119.html

There are two different, but related problems:

* The declarations of several wide char functions in <wchar.h> are only
  visible if __c99 is defined.  This used not to be the case, giving us the
  compilation failures described in the thread above.

* Up to IRIX 6.5.18, the variant of wcsftime visible when no feature test
  macros are defined was the one in ISO C99 and XPG5.  In IRIX 6.5.19, SGI
  changed this (for backwards compatiblity reasons ;-() to the XPG4
  variant, which is incompatible with the ISO C99 one needed by libstdc++.
  There's no easy way to fix this: the XPG5 variant can be activated by
  defining _XOPEN_SOURCE=500, but this hides several other functions needed
  by libstdc++ and creates much more breakage than it fixes.  Since the
  wcsftime variant is wrong for C99 compilations without _XOPEN_SOURCE=500,
  I'll raise a bug with SGI about this issue.

I therefore chose the following approach: since libstdc++ needs many of the
C99 functions, as of course does C99 itself, I predefine __c99 for both
-std=c99 and C++.  The former matches what SGI's MIPSpro 7.4 c99 command
does and makes sense irrespective of the rest.  The latter is needed for
libstd++ and seems sensible beyond that.  Unfortunately,
<internal/sgimacros.h> defines __restrict as restrict iff __c99 is defined,
but unlike C99, G++ doesn't grok the restrict keyword, only the __restrict
form.  This is fixed via fixincludes.

The second problem above must be fixed via fixincludes as well: the
C99/XPG5 form of wcsftime is used if either _XOPEN_SOURCE==500 or __c99 is
defined.

With this patch, a full mainline bootstrap on IRIX 6.5.18 and 6.5.19
succeeded.  make check in gcc/fixinc passes as well.

Ok for mainline?

Since the patch fixes problems caused by IRIX header bugs which affect the
3.2 and 3.3 branches as well, I'd like to apply it there as well.  Ok?

	Rainer

-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University


Fri Feb 14 15:16:33 2003  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	* config/mips/iris6.h (TARGET_OS_CPP_BUILTINS): Define __c99 for
	ISO C99 and C++.

	* fixinc/inclhack.def (irix___restrict): Don't change __restrict
	for C++ on IRIX 6.5.1[89].
	* fixinc/tests/base/internal/sgimacros.h: New file.

	* fixinc/inclhack.def (irix_wcsftime): Use XPG5 variant for C99.
	* fixinc/tests/base/internal/wchar_core.h: New file.
	
Index: config/mips/iris6.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/iris6.h,v
retrieving revision 1.56
diff -u -p -r1.56 iris6.h
--- config/mips/iris6.h	26 Jan 2003 14:40:22 -0000	1.56
+++ config/mips/iris6.h	17 Feb 2003 18:11:36 -0000
@@ -125,6 +125,13 @@ Boston, MA 02111-1307, USA.  */
      if (!ISA_MIPS1 && !ISA_MIPS2)			\
 	builtin_define ("_COMPILER_VERSION=601");	\
 							\
+     /* IRIX 6.5.18 and above provide many ISO C99	\
+	features protected by the __c99 macro.		\
+	libstdc++ v3 needs them as well.  */		\
+     if ((c_language == clk_c && flag_isoc99)		\
+	 || c_language == clk_cplusplus)		\
+	builtin_define ("__c99");			\
+							\
      if (c_language == clk_cplusplus)			\
       {							\
 	builtin_define ("__EXTENSIONS__");		\
Index: fixinc/inclhack.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/inclhack.def,v
retrieving revision 1.143
diff -u -p -r1.143 inclhack.def
--- fixinc/inclhack.def	14 Feb 2003 04:19:02 -0000	1.143
+++ fixinc/inclhack.def	17 Feb 2003 18:11:36 -0000
@@ -1357,6 +1357,24 @@ fix = {
 
 
 /*
+ *  IRIX 6.5.1[89] <internal/sgimacros.h> unconditionally defines
+ *  __restrict as restrict iff __c99.  This is wrong for C++, which
+ *  needs many C99 features, but only supports __restrict.
+ */
+fix = {
+    hackname  = irix___restrict;
+    files     = internal/sgimacros.h;
+    select    = "(#ifdef __c99\n)(#[ \t]*define __restrict restrict)";
+
+    mach      = "mips-sgi-irix6.5";
+    c_fix     = format;
+    c_fix_arg = "%1"
+		"#  ifndef __cplusplus\n%2\n#  endif";
+
+    test_text = "#ifdef __c99\n#  define __restrict restrict";
+};
+
+/*
  *  IRIX 5.x's stdio.h declares some functions that take a va_list as
  *  taking char *.  However, GCC uses void * for va_list, so
  *  calling vfprintf with a va_list fails in C++.  */
@@ -1371,6 +1389,23 @@ fix = {
     "extern int printf( const char *, /* va_list */ char * );";
 };
 
+
+/*
+ *  IRIX 6.5.19 <internal/wchar_core.h> provides the XPG4 variant of
+ *  wcsftime by default.  ISO C99 requires the XPG5 variant instead.
+ */
+fix = {
+    hackname  = irix_wcsftime;
+    files     = internal/wchar_core.h;
+    select    = "#if _NO_XOPEN5\n(extern size_t[ \t]+wcsftime.*const char \*.*)";
+
+    mach      = "mips-sgi-irix6.5";
+    c_fix     = format;
+    c_fix_arg = "#if _NO_XOPEN5 && !defined(__c99)\n%1";
+
+    test_text = "#if _NO_XOPEN5\n"
+		"extern size_t          wcsftime(wchar_t *, __SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, const struct tm *);";
+};
 
 /*
  * Fixing ISC fmod declaration
Index: fixinc/tests/base/internal/sgimacros.h
===================================================================
RCS file: fixinc/tests/base/internal/sgimacros.h
diff -N fixinc/tests/base/internal/sgimacros.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ fixinc/tests/base/internal/sgimacros.h	17 Feb 2003 18:11:36 -0000
@@ -0,0 +1,17 @@
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+	"fixinc/tests/inc/internals/sgimacros.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+
+
+#if defined( IRIX___RESTRICT_CHECK )
+#ifdef __c99
+#  ifndef __cplusplus
+#  define __restrict restrict
+#  endif
+#endif  /* IRIX___RESTRICT_CHECK */
Index: fixinc/tests/base/internal/wchar_core.h
===================================================================
RCS file: fixinc/tests/base/internal/wchar_core.h
diff -N fixinc/tests/base/internal/wchar_core.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ fixinc/tests/base/internal/wchar_core.h	17 Feb 2003 18:11:36 -0000
@@ -0,0 +1,15 @@
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+	"fixinc/tests/inc/internals/wchar_core.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+
+
+#if defined( IRIX_WCSFTIME_CHECK )
+#if _NO_XOPEN5 && !defined(__c99)
+extern size_t          wcsftime(wchar_t *, __SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, const struct tm *);
+#endif  /* IRIX_WCSFTIME_CHECK */


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