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]

3.0 PATCH: Fix wchar_t definition for bi-arch Solaris 7/8 and IRIX 6


A bootstrap of a bi-arch sparcv9-sun-solaris2.8 compiler failed initially
when the resulting compiler didn't compile
sparcv9-sun-solaris2.8/libstdc++-v3/src/c++locale.o:

/vol/gcc/obj/gcc-3.0-20010523/8-sparcv9-cc/gcc/xgcc -B/vol/gcc/obj/gcc-3.0-20010523/8-sparcv9-cc/gcc/ -nostdinc++ -L/vol/gcc/obj/gcc-3.0-20010523/8-sparcv9-cc/sparcv9-sun-solaris2.8/libstdc++-v3/src -L/vol/gcc/obj/gcc-3.0-20010523/8-sparcv9-cc/sparcv9-sun-solaris2.8/libstdc++-v3/src/.libs -B/vol/gcc/sparcv9-sun-solaris2.8/bin/ -B/vol/gcc/sparcv9-sun-solaris2.8/lib/ -isystem /vol/gcc/sparcv9-sun-solaris2.8/include -nostdinc++ -I/vol/gnu/src/gcc/gcc-3.0-branch-dist/libstdc++-v3/include -I/vol/gnu/src/gcc/gcc-3.0-branch-dist/libstdc++-v3/include/std -I/vol/gnu/src/gcc/gcc-3.0-branch-dist/libstdc++-v3/include/c_std -I../include -I/vol/gnu/src/gcc/gcc-3.0-branch-dist/libstdc++-v3/libsupc++ -I../libio -I/vol/gnu/src/gcc/gcc-3.0-branch-dist/libstdc++-v3/libio -I/vol/gnu/src/gcc/gcc-3.0-branch-dist/libstdc++-v3/libmath -g -O2 -fno-implicit-templates -Wall -Wno-format -W -Wwrite-strings -Winline -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -g -c c++locale.cc  !
-fPIC -DPIC -o .libs/c++locale.o
c++locale.cc: In member function `void 
   std::numpunct<_CharT>::_M_initialize_numpunct(int*) [with _CharT = 
   wchar_t]':
c++locale.cc:66: character constant too long
c++locale.cc:67: character constant too long
c++locale.cc: In member function `void std::moneypunct<_CharT, 
   _Intl>::_M_initialize_moneypunct(int*) [with _CharT = wchar_t, bool _Intl = 
   false]':
c++locale.cc:96: character constant too long
c++locale.cc:97: character constant too long
make[4]: *** [c++locale.lo] Error 1

As reported in PR libstdc++/2568, I initially succeeded with Andrew's patch
http://gcc.gnu.org/ml/gcc-patches/2001-04/msg01155.html, but Neil Booth
helped very much to point out the real problem:

Solaris 8 <iso/wchar_iso.h> (and several other headers) have this
construct:

#ifndef _WCHAR_T
#define _WCHAR_T
#if defined(_LP64)
typedef int     wchar_t;
#else
typedef long    wchar_t;
#endif
#endif  /* !_WCHAR_T */

but config/svr4.h (which are the definitions in effect on Solaris 2) has

#undef WCHAR_TYPE
#define WCHAR_TYPE "long int"

#undef WCHAR_TYPE_SIZE
#define WCHAR_TYPE_SIZE BITS_PER_WORD

This is right for 32-bit compilations, but wrong for -m64 (i.e. 64-bit
compilation, which will cause _LP64 to be defined).

The situation is similar on IRIX 6: <sys/types.h> has

#ifndef _WCHAR_T
#define _WCHAR_T
#if (_MIPS_SZLONG == 32)
typedef long wchar_t;
#endif
#if (_MIPS_SZLONG == 64)
typedef __int32_t wchar_t;
#endif
#endif

but config/mips/irix5.h does the following:

#undef WCHAR_TYPE
#undef WCHAR_TYPE_SIZE

#define WCHAR_TYPE "int"
#define WCHAR_TYPE_SIZE INT_TYPE_SIZE
#define MAX_WCHAR_TYPE_SIZE MAX_INT_TYPE_SIZE

with this in config/mips/mips.h:

#define INT_TYPE_SIZE (TARGET_INT64 ? 64 : 32)
#define MAX_INT_TYPE_SIZE 64

So the IRIX 6 configration doesn't account for wchar_t changing with
-mabi=64 either, and would get even more broken with -mint64 (which causes
int to be a 64-bit type!).

The following patch should fix both problems.  I haven't bootstrapped yet,
though: I plan to do some major cleanup on the Solaris 2 configurations
before firing off the bootstrap, and my IRIX 6 host (a 2 CPU R8000 Power
Challenge/L) is terribly slow (with a bootstrap taking between two and
three days ;-), and I may need to apply other fixes before the next
bootstrap.

	Rainer

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

Email: ro@TechFak.Uni-Bielefeld.DE


Mon May 28 14:56:26 2001  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	* config/mips/iris6.h (NO_BUILTIN_WCHAR_TYPE): Define.
	(WCHAR_TYPE): Override.
	(WCHAR_TYPE_SIZE): Likewise.

	* config/sparc/sol2-sld-64.h (NO_BUILTIN_WCHAR_TYPE): Define.
	(WCHAR_TYPE): Override.
	(WCHAR_TYPE_SIZE): Likewise.
	(CPP_ARCH32_SPEC): Add __WCHAR_TYPE__ definition.
	(CPP_ARCH64_SPEC): Likewise.

Index: gcc/config/mips/iris6.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/iris6.h,v
retrieving revision 1.28.2.3
diff -u -p -r1.28.2.3 iris6.h
--- iris6.h	2001/05/23 06:55:03	1.28.2.3
+++ iris6.h	2001/05/28 20:05:35
@@ -39,6 +39,16 @@ Boston, MA 02111-1307, USA.  */
    we avoid creating such labels.  */
 #define DWARF2_GENERATE_TEXT_SECTION_LABEL 0
 
+/* wchar_t is defined differently with and without -mabi=64.  */
+
+#define NO_BUILTIN_WCHAR_TYPE
+
+#undef WCHAR_TYPE
+#define WCHAR_TYPE (Pmode == DImode ? "int" : "long")
+
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
 /* For Irix 6, -mabi=64 implies TARGET_LONG64.  */
 /* This is handled in override_options.  */
 
Index: gcc/config/sparc/sol2-sld-64.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sol2-sld-64.h,v
retrieving revision 1.13.4.1
diff -u -p -r1.13.4.1 sol2-sld-64.h
--- sol2-sld-64.h	2001/04/11 13:04:21	1.13.4.1
+++ sol2-sld-64.h	2001/05/28 20:05:35
@@ -161,11 +161,23 @@
 %{!m32:" ASM_CPU64_DEFAULT_SPEC "} \
 ")
 
+/* wchar_t is called differently in <wchar.h> for 32 and 64-bit
+   compilations.  */
+#define NO_BUILTIN_WCHAR_TYPE
+
+#undef WCHAR_TYPE
+#define WCHAR_TYPE (TARGET_ARCH64 ? "int" : "long int")
+
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
 #undef CPP_ARCH32_SPEC
 #define CPP_ARCH32_SPEC "-D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int \
+-D__WCHAR_TYPE__=long\\ int \
 -D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc"
 #undef CPP_ARCH64_SPEC
 #define CPP_ARCH64_SPEC "-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int \
+-D__WCHAR_TYPE__=int \
 -D__arch64__ -Acpu=sparc64 -Amachine=sparcv9 -D__sparcv9"
 
 #undef CPP_ARCH_SPEC


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