This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
3.4/3.5 PATCH: Fix many Solaris 10 g++ testsuite failures
- From: Rainer Orth <ro at TechFak dot Uni-Bielefeld dot DE>
- To: gcc-patches at gcc dot gnu dot org
- Cc: libstdc++ at gcc dot gnu dot org, Bruce Korb <bkorb at gnu dot org>
- Date: Fri, 30 Apr 2004 21:31:26 +0200 (MEST)
- Subject: 3.4/3.5 PATCH: Fix many Solaris 10 g++ testsuite failures
Bootstrapping current mainline on Solaris 10/x86 Beta 2, I noticed many new
failures in the g++ testsuite, e.g.
Executing on host: /amnt/figaro/volumes/obj-gcc/gcc/obj.sol86/gcc-3.5.0-20040427/10-gcc/gcc/testsuite/../g++ -B/amnt/figaro/volumes/obj-gcc/gcc/obj.sol86/gcc-3.5.0-20040427/10-gcc/gcc/testsuite/../ /vol/gnu/src/gcc/gcc-dist/gcc/testsuite/g++.dg/init/array4.C -nostdinc++ -I/vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/include/i386-pc-solaris2.10 -I/vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/include -I/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/libsupc++ -I/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/libsupc++ -I/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/include/backward -I/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite -fmessage-length=0 -ansi -pedantic-errors -Wno-long-long -S -o array4.s (timeout = 300)
In file included from /vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/include/iosfwd:50,
from /vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/include/bits/stl_algobase.h:70,
from /vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/include/bits/char_traits.h:46,
from /vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/include/string:47,
from /vol/gnu/src/gcc/gcc-dist/gcc/testsuite/g++.dg/init/array4.C:8:
/vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/include/bits/postypes.h:72: error: `int64_t' does not name a type
This happens because of the following: during libstdc++-v3 configure,
int64_t is detected and thus used in bits/postypes.h.
The definition of int64_t is from <sys/int_types.h> where it's now defined
as follows:
#if (!defined(_STRICT_STDC) && !defined(_NO_LONGLONG)) || defined(_STDC_C99)
typedef long long int64_t;
#endif
While the configure test is run without -ansi, large parts of the g++ test
suite are run with that flag, which removes the definition of int64_t
because _STRICT_STDC is now true. To restore it, one can cause _STDC_C99
to be defined (by defining __STDC_VERSION__=199901L), which allows
libstdc++-v3 to use ISO C99 features, so this is useful otherwise. This is
what we have done for IRIX 6.5 as well.
To make this work, we need to define _XPG6 (i.e. _XOPEN_SOURCE=600) to
avoid getting a hard error from <sys/feature_tests.h>:
#if defined(_STDC_C99) && (defined(__XOPEN_OR_POSIX) && !defined(_XPG6))
#error "Compiler or options invalid for pre-UNIX 03 X/Open applications \
and pre-2001 POSIX applications"
With those changes alone, bootstrap breaks building the stdc++.h pch files:
/vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/gcc/xgcc -shared-libgcc -B/vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/gcc/ -nostdinc++ -L/vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/src -L/vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/src/.libs -B/vol/gcc/share/i386-pc-solaris2.10/bin/ -B/vol/gcc/share/i386-pc-solaris2.10/lib/ -isystem /vol/gcc/share/i386-pc-solaris2.10/include -isystem /vol/gcc/share/i386-pc-solaris2.10/sys-include -Winvalid-pch -Wno-deprecated -x c++-header -g -O2 -I/vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/include/i386-pc-solaris2.10 -I/vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/include -I/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/libsupc++ /vol/gnu/src/gcc/gcc-dist/libstdc++-v3/include/stdc++.h -O0 -g -o ./i386-pc-solaris2.10/bits/stdc++.h.gch/O0g; \
[...]
In file included from /vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/include/cwchar:54,
from /vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/include/bits/postypes.h:46,
from /vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/include/iosfwd:50,
from /vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/include/bits/stl_algobase.h:70,
from /vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/i386-pc-solaris2.10/libstdc++-v3/include/algorithm:66,
from /vol/gnu/src/gcc/gcc-dist/libstdc++-v3/include/stdc++.h:51:
/usr/include/wchar.h:102: error: conflicting declaration 'typedef void* va_list'
/vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/gcc/include/stdarg.h:85: error: 'va_list' has a previous declaration as `typedef char* va_list'
/usr/include/wchar.h:102: error: declaration of `typedef void* va_list'
/vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/gcc/include/stdarg.h:85: error: conflicts with previous declaration `typedef char* va_list'
/usr/include/wchar.h:102: error: declaration of `typedef void* va_list'
/vol/gcc/obj/gcc-3.5.0-20040427/10-gcc/gcc/include/stdarg.h:85: error: conflicts with previous declaration `typedef char* va_list'
This happens because _XPG6 adds a definition of va_list to <wchar.h>, which
is identical to <sys/va_list.h>:
#ifdef __STDC__
typedef void *__va_list;
#else
typedef char *__va_list;
#endif
Contrary to that, config/i386/i386.c (ix86_build_builtin_va_list) has
/* For i386 we use plain pointer to argument area. */
if (!TARGET_64BIT)
return build_pointer_type (char_type_node);
which is obviously incompatible: since __STDC__ is always defined, either
as 0 or as 1, only the __STDC__ case needs to be considered. To make this
right, we should use the default (std_build_builtin_va_list from
builtins.c), as the Solaris 2/SPARC port does. This inconsistency had
recently been reported by Brad Spencer for the 3.4 branch:
http://gcc.gnu.org/ml/gcc-bugs/2004-04/msg02567.html
The patch below does this, using the mips port as a guide: since there is
no direct way to override i386.c's definition of
TARGET_BUILD_BUILTIN_VA_LIST, I need to add a test for Solaris 2 to
ix86_build_builtin_va_list.
Even after those fixes, libstdc++-v3 doesn't compile because
<sys/feature_tests.h> now exposes the restrict keyword like this
#if (defined(__STDC__) && defined(_STDC_C99))
#define _RESTRICT_KYWD restrict
#else
#define _RESTRICT_KYWD
#endif
while g++ only understands __restrict. I've fixed this with fixincludes
similarly to my previous irix__restrict fixincludes hack.
After those changes, I could bootstrap without regressions on
sparc-sun-solaris2.8 (which should be unaffected by those changes since the
system headers neither deal with XPG6 or C99), and with two regressions on
i386-pc-solaris2.10:
FAIL: 26_numerics/c99_classification_macros_c++.cc (test for excess errors)
FAIL: 26_numerics/c99_classification_macros_c.cc (test for excess errors)
In the first case, I get the following errors:
FAIL: 26_numerics/c99_classification_macros_c++.cc (test for excess errors)
Excess errors:
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:44: warning: new declaration `void __builtin_signbit()'
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:44: warning: ambiguates built-in declaration `int __builtin_signbit(double)'
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:46:16: macro "isgreater" requires 2 arguments, but only 1 given
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc: At global scope:
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:46: error: invalid function declaration
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:48:21: macro "isgreaterequal" requires 2 arguments, but only 1 given
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:48: error: invalid function declaration
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:50:13: macro "isless" requires 2 arguments, but only 1 given
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:50: error: invalid function declaration
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:52:18: macro "islessequal" requires 2 arguments, but only 1 given
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:52: error: invalid function declaration
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:54:20: macro "islessgreater" requires 2 arguments, but only 1 given
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:54: error: invalid function declaration
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:56:18: macro "isunordered" requires 2 arguments, but only 1 given
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:56: error: invalid function declaration
Unfortunately, the set of errors changes when capturing the preprocessor
output with -save-temps (maybe a pch problem?):
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:46:16: macro "isgreater" requires 2 arguments, but only 1 given
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:48:21: macro "isgreaterequal" requires 2 arguments, but only 1 given
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:50:13: macro "isless" requires 2 arguments, but only 1 given
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:52:18: macro "islessequal" requires 2 arguments, but only 1 given
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:54:20: macro "islessgreater" requires 2 arguments, but only 1 given
/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc:56:18: macro "isunordered" requires 2 arguments, but only 1 given
Those problems happen because c99_classification_macros_c++.cc has e.g.
void isgreater() { }
but _GLIBCXX_USE_C99_MATH isn't defined in config.h, so we retain the macro
definition of isgreater from <iso/math_c99.h>, which of course takes two
arguments.
The first configure test fails like so:
conftest.cc: In function `int main()':
conftest.cc:27: error: `__builtin_fpclassify' was not declared in this scope
I'll have to figure out how to fix/work around this.
Anyway, ok for mainline (and the 3.4 branch once regression tested)?
Rainer
-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University
Thu Apr 29 00:08:16 2004 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* config/sol2.h (TARGET_OS_CPP_BUILTINS): Define __STDC_VERSION__
for Solaris 10. Use XPG6 instead of XPG5.
* config/i386/i386.h (TARGET_SOLARIS2): Provide default.
* config/i386/sol2.h (TARGET_SOLARIS2): Override.
* config/i386/i386.c (ix86_build_builtin_va_list): Return default
for Solaris 2.
* fixinc/inclhack.def (solaris___restrict): New fix.
* fixinc/fixincl.x: Regenerate.
* fixinc/tests/base/sys/feature_tests.h: New test.
Index: gcc/config/sol2.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sol2.h,v
retrieving revision 1.9
diff -u -p -r1.9 sol2.h
--- gcc/config/sol2.h 18 Dec 2003 20:13:50 -0000 1.9
+++ gcc/config/sol2.h 30 Apr 2004 18:26:10 -0000
@@ -65,10 +65,15 @@ Boston, MA 02111-1307, USA. */
builtin_assert ("system=svr4"); \
/* For C++ we need to add some additional macro \
definitions required by the C++ standard \
- library. */ \
+ library. \
+ In Solaris 10, int64_t from <sys/int_types.h>\
+ is only visible with g++ -ansi for ISO C99 \
+ compilations. Those only work together with \
+ XPG6. */ \
if (c_dialect_cxx ()) \
{ \
- builtin_define ("_XOPEN_SOURCE=500"); \
+ builtin_define ("__STDC_VERSION__=199901L");\
+ builtin_define ("_XOPEN_SOURCE=600"); \
builtin_define ("_LARGEFILE_SOURCE=1"); \
builtin_define ("_LARGEFILE64_SOURCE=1"); \
builtin_define ("__EXTENSIONS__"); \
Index: gcc/config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.662
diff -u -p -r1.662 i386.c
--- gcc/config/i386/i386.c 12 Apr 2004 23:23:14 -0000 1.662
+++ gcc/config/i386/i386.c 30 Apr 2004 18:26:12 -0000
@@ -2972,6 +2972,10 @@ ix86_build_builtin_va_list (void)
{
tree f_gpr, f_fpr, f_ovf, f_sav, record, type_decl;
+ /* Solaris 2/x86, like SPARC, uses the default. */
+ if (TARGET_SOLARIS2)
+ return std_build_builtin_va_list ();
+
/* For i386 we use plain pointer to argument area. */
if (!TARGET_64BIT)
return build_pointer_type (char_type_node);
Index: gcc/config/i386/i386.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.h,v
retrieving revision 1.384
diff -u -p -r1.384 i386.h
--- gcc/config/i386/i386.h 9 Apr 2004 19:57:45 -0000 1.384
+++ gcc/config/i386/i386.h 30 Apr 2004 18:26:17 -0000
@@ -450,6 +450,9 @@ extern int x86_prefetch_sse;
redefines this to 1. */
#define TARGET_MACHO 0
+/* Solaris 2 specific stuff. */
+#define TARGET_SOLARIS2 0
+
/* This macro is similar to `TARGET_SWITCHES' but defines names of
command options that have values. Its definition is an
initializer with a subgrouping for each command option.
Index: gcc/config/i386/sol2.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/sol2.h,v
retrieving revision 1.28
diff -u -p -r1.28 sol2.h
--- gcc/config/i386/sol2.h 26 Sep 2003 04:07:46 -0000 1.28
+++ gcc/config/i386/sol2.h 30 Apr 2004 18:26:17 -0000
@@ -20,6 +20,10 @@ along with GCC; see the file COPYING. I
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+/* We are compiling for Solaris 2 now. */
+#undef TARGET_SOLARIS2
+#define TARGET_SOLARIS2 1
+
/* The Solaris 2.0 x86 linker botches alignment of code sections.
It tries to align to a 16 byte boundary by padding with 0x00000090
ints, rather than 0x90 bytes (nop). This generates trash in the
Index: gcc/fixinc/inclhack.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/inclhack.def,v
retrieving revision 1.196
diff -u -p -r1.196 inclhack.def
--- gcc/fixinc/inclhack.def 24 Apr 2004 22:42:29 -0000 1.196
+++ gcc/fixinc/inclhack.def 30 Apr 2004 18:26:32 -0000
@@ -2440,6 +2440,27 @@ fix = {
/*
+ * Solaris 10 <sys/feature_tests.h> unconditionally defines
+ * _RESTRICT_KYWD as restrict iff _STDC_C99. This is wrong for C++, which
+ * needs many C99 features, but only supports __restrict.
+ */
+fix = {
+ hackname = solaris___restrict;
+ files = sys/feature_tests.h;
+ select = "#define[ \t]+_RESTRICT_KYWD[ \t]+restrict";
+
+ mach = "*-*-solaris2*";
+ c_fix = format;
+ c_fix_arg = "#ifndef __cplusplus\n"
+ "%0\n"
+ "#else\n"
+ "#define _RESTRICT_KYWD __restrict\n"
+ "#endif";
+
+ test_text = "#define _RESTRICT_KYWD restrict";
+};
+
+/*
* Sun Solaris 2.5.1, 2.6 defines PTHREAD_{MUTEX|COND}_INITIALIZER
* incorrectly, so we replace them with versions that correspond to
* the definition. We also explicitly name this fix "1" and the next
@@ -3161,6 +3182,9 @@ fix = {
select =
'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
+ /* The fix is wrong on IRIX 5/6 and creates a conflict with another
+ prototype in <sys/profil.h>. */
+ bypass = 'Silicon Graphics';
c_fix = format;
c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
Index: gcc/fixinc/tests/base/sys/feature_tests.h
===================================================================
RCS file: gcc/fixinc/tests/base/sys/feature_tests.h
diff -N gcc/fixinc/tests/base/sys/feature_tests.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc/fixinc/tests/base/sys/feature_tests.h 30 Apr 2004 18:26:32 -0000
@@ -0,0 +1,18 @@
+/* DO NOT EDIT THIS FILE.
+
+ It has been auto-edited by fixincludes from:
+
+ "fixinc/tests/inc/sys/feature_tests.h"
+
+ This had to be done to correct non-standard usages in the
+ original, manufacturer supplied header file. */
+
+
+
+#if defined( SOLARIS___RESTRICT_CHECK )
+#ifndef __cplusplus
+#define _RESTRICT_KYWD restrict
+#else
+#define _RESTRICT_KYWD __restrict
+#endif
+#endif /* SOLARIS___RESTRICT_CHECK */