3.1 PATCH: Fix Solaris 2.5.1 <widec.h> to avoid bootstrap failure

Rainer Orth ro@TechFak.Uni-Bielefeld.DE
Fri Apr 26 19:12:00 GMT 2002


I just tried a bootstrap of gcc 3.1 20020426 on Solaris 2.5.1/SPARC, which
failed building libstdc++.  The last bootstrap of 20020412 had been
successful.  The failure occured trying to compile
libstdc++-v3/src/locale.cc: 

In file included from /vol/gcc/obj/gcc-3.1-20020412/2.5.1-gcc/sparc-sun-solaris2.5.1/libstdc++-v3/include/cwchar:54,
                 from /vol/gcc/obj/gcc-3.1-20020412/2.5.1-gcc/sparc-sun-solaris2.5.1/libstdc++-v3/include/bits/fpos.h:45,
                 from /vol/gcc/obj/gcc-3.1-20020412/2.5.1-gcc/sparc-sun-solaris2.5.1/libstdc++-v3/include/bits/char_traits.h:45,
                 from /vol/gcc/obj/gcc-3.1-20020412/2.5.1-gcc/sparc-sun-solaris2.5.1/libstdc++-v3/include/string:47,
                 from /vol/gcc/obj/gcc-3.1-20020412/2.5.1-gcc/sparc-sun-solaris2.5.1/libstdc++-v3/include/bits/localefwd.h:49,
                 from /vol/gcc/obj/gcc-3.1-20020412/2.5.1-gcc/sparc-sun-solaris2.5.1/libstdc++-v3/include/locale:44,
                 from /vol/gnu/src/gcc/gcc-3.1-branch-dist/libstdc++-v3/src/locale.cc:36:
/vol/gcc/obj/gcc-3.1-20020412/2.5.1-gcc/gcc/include/wchar.h:71:28: macro "getwchar" passed 1 arguments, but takes just 0

I could trace this to the following problem: locale.cc includes widec.h
(via wctype.h <- cwctype) and then wchar.h (via cwchar ... locale).

widec.h has

#define getwchar() getwc(stdin)

and wchar.h

extern wint_t getwchar(void);

This gets us the cpp error above.  The same problem shows up even in a
minimal C testcase:

#include <widec.h>
#include <wchar.h>

I have no idea why this didn't show up before, but it's certainly a
regression from both gcc 2.95 and 3.0.

The following patch fixes the problem: it doesn't occur in Solaris 2.6 and
up since Sun chose to include <wchar.h> in <widec.h> themselves.  I chose
the same approach via fixincludes.  Manually rebuilding stmp-fixinc had the
desired effect on widec.h, and the libstdc++-v3 bootstrap continued.  I
couldn't run make check in fixinc since autogen complained:

ERROR: Unbound variable: set-writable
AutoGen ABENDED in template /vol/gnu/src/gcc/gcc-3.1-branch-dist/gcc/fixinc/check.tpl line 174

A fresh bootstrap on sparc-sun-solaris2.5.1 is now in progress, ok for
branch and mainline provided this finishes without regressions?

	Rainer



Sat Apr 27 03:24:56 2002  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	* fixinc/inclhack.def (solaris_widec): Include <wchar.h> in
	Solaris 2 <widec.h> if missing.
	* fixinc/fixincl.x: Regenerate.
	* fixinc/tests/base/widec.h: New file.

Index: inclhack.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/inclhack.def,v
retrieving revision 1.120.2.5
diff -u -p -r1.120.2.5 inclhack.def
--- inclhack.def	2 Apr 2002 18:23:17 -0000	1.120.2.5
+++ inclhack.def	27 Apr 2002 01:54:33 -0000
@@ -2093,6 +2093,23 @@ fix = {
 };
 
 /*
+ * <widec.h> until Solaris 2.5.1 defines macros for a couple of <wchar.h>
+ * functions, breaking their prototypes if that file is included afterwards.
+ * Include <wchar.h> early to avoid this issue, as is done on Solaris 2.6
+ * and up.
+ */
+fix = {
+    hackname  = solaris_widec;
+    files     = widec.h;
+    mach      = '*-*-solaris*';
+    bypass    = "wchar.h";
+    select    = "#include <euc.h>";
+    c_fix     = format;
+    c_fix_arg = "%0\n#include <wchar.h>";
+    test_text = "#include <euc.h>";
+};
+
+/*
  *  Sony NEWSOS 5.0 does not support the complete ANSI C standard.
  */
 #ifdef SONY
Index: tests/base/widec.h
===================================================================
RCS file: tests/base/widec.h
diff -N tests/base/widec.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/base/widec.h	27 Apr 2002 01:54:33 -0000
@@ -0,0 +1,12 @@
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+	"fixinc/tests/inc/widec.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+#if defined( SOLARIS_WIDEC_CHECK )
+#include <euc.h>
+#endif  /* SOLARIS_WIDEC_CHECK */



More information about the Libstdc++ mailing list