This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
3.4 PATCH: Fully obey __PRAGMA_EXTERN_PREFIX on Tru64 UNIX
- From: Rainer Orth <ro at TechFak dot Uni-Bielefeld dot DE>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Bruce Korb <bkorb at gnu dot org>, Roger Sayle <roger at eyesopen dot com>
- Date: Wed, 7 Jan 2004 21:40:07 +0100 (MET)
- Subject: 3.4 PATCH: Fully obey __PRAGMA_EXTERN_PREFIX on Tru64 UNIX
This patch is both necessary to allow mainline to bootstrap on Tru64 UNIX
V5.1B (more below) and, as a side effect, fixincludes now fully mangles the
system headers to indicate that GCC supports #pragma extern_prefix.
Now for the details: currently, mainline fails to bootstrap on
alpha-dec-osf5.1b building libstdc++-v3:
/vol/gcc/obj/gcc-3.4.0-20040105/5.1b-gcc/gcc/xgcc -shared-libgcc -B/vol/gcc/obj/gcc-3.4.0-20040105/5.1b-gcc/gcc/ -nostdinc++ -L/vol/gcc/obj/gcc-3.4.0-20040105/5.1b-gcc/alpha-dec-osf5.1b/libstdc++-v3/src -L/vol/gcc/obj/gcc-3.4.0-20040105/5.1b-gcc/alpha-dec-osf5.1b/libstdc++-v3/src/.libs -B/vol/gcc/share/alpha-dec-osf5.1b/bin/ -B/vol/gcc/share/alpha-dec-osf5.1b/lib/ -isystem /vol/gcc/share/alpha-dec-osf5.1b/include -isystem /vol/gcc/share/alpha-dec-osf5.1b/sys-include -I/vol/gcc/obj/gcc-3.4.0-20040105/5.1b-gcc/alpha-dec-osf5.1b/libstdc++-v3/include/alpha-dec-osf5.1b -I/vol/gcc/obj/gcc-3.4.0-20040105/5.1b-gcc/alpha-dec-osf5.1b/libstdc++-v3/include -I/vol/gnu/src/gcc/gcc-dist/libstdc++-v3/libsupc++ -O2 -g -O2 -mieee -g -O2 -mieee -fno-implicit-templates -Wall -W -Wwrite-strings -Wcast-qual -fdiagnostics-show-location=once -c /vol/gnu/src/gcc/gcc-dist/libstdc++-v3/src/codecvt.cc -DPIC -o .libs/codecvt.o
In file included from /vol/gcc/obj/gcc-3.4.0-20040105/5.1b-gcc/alpha-dec-osf5.1b/libstdc++-v3/include/bits/postypes.h:46,
from /vol/gcc/obj/gcc-3.4.0-20040105/5.1b-gcc/alpha-dec-osf5.1b/libstdc++-v3/include/iosfwd:50,
from /vol/gcc/obj/gcc-3.4.0-20040105/5.1b-gcc/alpha-dec-osf5.1b/libstdc++-v3/include/bits/localefwd.h:47,
from /vol/gcc/obj/gcc-3.4.0-20040105/5.1b-gcc/alpha-dec-osf5.1b/libstdc++-v3/include/locale:44,
from /vol/gnu/src/gcc/gcc-dist/libstdc++-v3/src/codecvt.cc:30:
/vol/gcc/obj/gcc-3.4.0-20040105/5.1b-gcc/alpha-dec-osf5.1b/libstdc++-v3/include/cwchar:182: error: `::wcsftime' has not been declared
/vol/gcc/obj/gcc-3.4.0-20040105/5.1b-gcc/alpha-dec-osf5.1b/libstdc++-v3/include/cwchar:193: error: `::wcstok' has not been declared
wcsftime and wcstok are not declared at this point because of the
following:
$ grep wcsftime codecvt.ii
size_t (*wcsftime) (wchar_t *, size_t, const char *, const struct tm *, struct _LC_time_t *);
[...]
#define wcsftime(__a,__b,__c,__d) _Ewcsftime (__a,__b,__c,__d)
extern size_t _Ewcsftime (wchar_t *, size_t, const wchar_t *, const struct tm *);
#undef wcsftime
using ::wcsftime;
<wchar.h> uses defines to select the proper version of wcsftime, depending
on _XOPEN_SOURCE and __STDC_VERSION__. For non-Compaq C compilers, it uses
a macro to arrive at the proper external symbol (_Ewcstime).
Unfortunately, libstdc++-v3's std_cwchar.h (aka <cwchar>) undefs this macro
again:
// Get rid of those macros defined in <wchar.h> in lieu of real functions.
so loosing the declaration.
This can all be avoided if one finally bites the bullet and teaches the
system headers that GCC supports #pragma extern_prefix, not just Compaq C.
For this, many tests for __DECC have to be changed to __DECC ||
__PRAGMA_EXTERN_PREFIX. The following collection of fixincludes hacks does
this. It allowed me to bootstrap on alpha-dec-osf5.1b, and now there are
only very few testsuite differences between alpha-dec-osf4.0f and
alpha-dec-osf5.1b (apart from a stupid bug in the libffi testsuite, to be
fixed shortly):
* additional testsuite failures on V5.1B compared to V4.0F:
+FAIL: gcc.c-torture/execute/regstack-1.c execution, -O1
+FAIL: gcc.c-torture/execute/ieee/20010226-1.c execution, -O1
+FAIL: gcc.c-torture/execute/ieee/inf-1.c execution, -O1
+FAIL: gcc.dg/compat/scalar-by-value-3 c_compat_x_tst.o-c_compat_y_tst.o execute
+FAIL: gcc.dg/compat/scalar-return-3 c_compat_x_tst.o-c_compat_y_tst.o execute
These are most likely unrelated to the patch at hand.
* additional testsuite failures on V4.0F compared to V5.1B:
+FAIL: g++.dg/parse/stack1.C (test for excess errors)
Stack overflow: pid 5489, proc cc1plus, addr 0x11fdfffd0, pc 0x12053e3bc
g++: Internal error: Segmentation fault (program cc1plus)
2 MB stack on V4.0F instead of 8 MB on V5.1B, increasing it to 8 MB
works on V4.0F, too
+FAIL: gcc.dg/builtins-20.c (test for excess errors)
link_error
Tru64 UNIX V4.0F either lacks the C99 runtime or it has bugs
cf. gcc/testsuite/gcc.dg/builtins-config.h (which assumes
HAVE_C99_RUNTIME is defined unless overridden)
So this seems to be good enough, both to fix the bootstrap failure and get
us a useful new feature as a side effect.
The fixincl hacks passed make check as well.
The only ugly thing right now is the bad_lval hack: I needed to add a
couple of files so it matches the full list that needs to be fixed in Tru64
UNIX V5.1B. Since the comments indicates that it is for Tru64 UNIX only
anyway, it may be better to just remove the file list and apply it only on
alpha*-dec-osf*?
Since the patterns used are somewhat sensitive to the exact version of the
system headers used, it may be helpful to try the patch on Tru64 UNIX V5.1,
too to make sure it doesn't break anything there. Roger, could you please
try this? I already bootstrapped on alpha-dec-osf4.0f with and without
this patch, and there are no testsuite differences.
Ok for mainline?
Rainer
-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University
Wed Jan 7 20:36:43 2004 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* fixinc/inclhack.def (alpha___extern_prefix): Renamed to ...
(alpha___extern_prefix_sys_stat): ... this.
Apply to <sys/mount.h>, too.
Tweak to match more variations.
* fixinc/tests/base/sys/stat.h: Adapt for new hackname.
* fixinc/inclhack.def (alpha___extern_prefix,
alpha___extern_prefix_standards): New hacks to obey
__PRAGMA_EXTERN_PREFIX.
* fixinc/tests/base/testing.h [ALPHA___EXTERN_PREFIX_CHECK]: New
test.
* fixinc/tests/base/standards.h: Likewise.
* fixincl/inclhack.def (alpha_pthread): Tweak to match more
variations.
New testcase.
* fixinc/tests/base/pthread.h: Handle it.
* fixincl/inclhack.def (bad_lval): Sort file list.
Add many missing files up to Tru64 UNIX V5.1B.
* gcc/fixinc/tests/base/libgen.h: Renamed to ...
* gcc/fixinc/tests/base/dirent.h: ... this to match new file list
order.
* fixinc/fixincl.x: Regenerate.
Index: gcc/fixinc/inclhack.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/inclhack.def,v
retrieving revision 1.190
diff -u -p -r1.190 inclhack.def
--- gcc/fixinc/inclhack.def 20 Dec 2003 15:49:22 -0000 1.190
+++ gcc/fixinc/inclhack.def 7 Jan 2004 19:55:34 -0000
@@ -523,11 +523,50 @@ fix = {
/*
- * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/stat.h>.
+ * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 headers.
*/
fix = {
hackname = alpha___extern_prefix;
+ select = "(.*)(defined\\(__DECC\\)|def[ \t]*__DECC)[ \t]*\n(#[ \t]*pragma[ \t]*extern_prefix.*)";
+
+ mach = "alpha*-dec-osf*";
+ c_fix = format;
+ c_fix_arg = "%1 (defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX))\n%3";
+
+ test_text = "#ifdef __DECC\n"
+ "#pragma extern_prefix \"_P\"\n"
+ "# if defined(__DECC)\n"
+ "# pragma extern_prefix \"_E\"\n"
+ "# if !defined(_LIBC_POLLUTION_H_) && defined(__DECC)\n"
+ "# pragma extern_prefix \"\"";
+};
+
+
+/*
+ * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 <standards.h>.
+ */
+fix = {
+ hackname = alpha___extern_prefix_standards;
+ files = standards.h;
+ select = ".*!defined\\(_LIBC_POLLUTION_H_\\) && !defined\\(__DECC\\)";
+
+ mach = "alpha*-dec-osf*";
+ c_fix = format;
+ c_fix_arg = "%0 && !defined(__PRAGMA_EXTERN_PREFIX)";
+
+ test_text = "#if (_ISO_C_SOURCE>=19990L) && !defined(_LIBC_POLLUTION_H_) && !defined(__DECC)";
+};
+
+
+/*
+ * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/mount.h> and
+ * <sys/stat.h>. The tests for __DECC are special in various ways, so
+ * alpha__extern_prefix cannot be used.
+ */
+fix = {
+ hackname = alpha___extern_prefix_sys_stat;
files = sys/stat.h;
+ files = sys/mount.h;
select = "#[ \t]*if[ \t]*defined\\(__DECC\\)";
mach = "alpha*-dec-osf5*";
@@ -585,15 +624,18 @@ fix = {
fix = {
hackname = alpha_pthread;
files = pthread.h;
- select = "(#[ \t]*if defined \\(_PTHREAD_ENV_DECC\\) || defined \\(_PTHREAD_ENV_EPCC\\))\n"
+ select = "((#[ \t]*if)([ \t]*defined[ \t]*\\(_PTHREAD_ENV_DECC\\)|def _PTHREAD_ENV_DECC)(.*))\n"
"(#[ \t]*define _PTHREAD_USE_PTDNAM_)";
mach = "alpha*-dec-osf*";
c_fix = format;
- c_fix_arg = "%1 || defined (__PRAGMA_EXTERN_PREFIX)\n%2";
+ c_fix_arg = "%2 defined (_PTHREAD_ENV_DECC)%4 || defined (__PRAGMA_EXTERN_PREFIX)\n%5";
test_text = "# if defined (_PTHREAD_ENV_DECC) || defined (_PTHREAD_ENV_EPCC)\n"
"# define _PTHREAD_USE_PTDNAM_\n"
+ "# endif\n"
+ "# ifdef _PTHREAD_ENV_DECC\n"
+ "# define _PTHREAD_USE_PTDNAM_\n"
"# endif";
};
@@ -734,20 +776,31 @@ fix = {
select = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
- files = libgen.h;
files = dirent.h;
files = ftw.h;
files = grp.h;
+ files = libgen.h;
files = ndbm.h;
files = pthread.h;
files = pwd.h;
files = signal.h;
files = standards.h;
+ files = stdio.h;
files = stdlib.h;
files = string.h;
files = stropts.h;
+ files = sys/mount.h;
+ files = sys/resource.h;
+ files = sys/signal.h;
+ files = sys/socket.h;
+ files = sys/stat.h;
+ files = sys/stropts.h;
+ files = sys/uio.h;
files = time.h;
files = unistd.h;
+ files = utmp.h;
+ files = utmpx.h;
+ files = wchar.h;
sed =
"s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
Index: gcc/fixinc/tests/base/dirent.h
===================================================================
RCS file: gcc/fixinc/tests/base/dirent.h
diff -N gcc/fixinc/tests/base/dirent.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc/fixinc/tests/base/dirent.h 7 Jan 2004 19:55:34 -0000
@@ -0,0 +1,16 @@
+/* DO NOT EDIT THIS FILE.
+
+ It has been auto-edited by fixincludes from:
+
+ "fixinc/tests/inc/dirent.h"
+
+ This had to be done to correct non-standard usages in the
+ original, manufacturer supplied header file. */
+
+
+
+#if defined( BAD_LVAL_CHECK )
+#pragma extern_prefix "_FOO"
+#define something _FOOsomething
+#define mumble _FOOmumble
+#endif /* BAD_LVAL_CHECK */
Index: gcc/fixinc/tests/base/libgen.h
===================================================================
RCS file: gcc/fixinc/tests/base/libgen.h
diff -N gcc/fixinc/tests/base/libgen.h
--- gcc/fixinc/tests/base/libgen.h 19 Jul 2000 14:18:30 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,16 +0,0 @@
-/* DO NOT EDIT THIS FILE.
-
- It has been auto-edited by fixincludes from:
-
- "fixinc/tests/inc/libgen.h"
-
- This had to be done to correct non-standard usages in the
- original, manufacturer supplied header file. */
-
-
-
-#if defined( BAD_LVAL_CHECK )
-#pragma extern_prefix "_FOO"
-#define something _FOOsomething
-#define mumble _FOOmumble
-#endif /* BAD_LVAL_CHECK */
Index: gcc/fixinc/tests/base/pthread.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/tests/base/pthread.h,v
retrieving revision 1.11
diff -u -p -r1.11 pthread.h
--- gcc/fixinc/tests/base/pthread.h 14 Oct 2003 11:46:47 -0000 1.11
+++ gcc/fixinc/tests/base/pthread.h 7 Jan 2004 19:55:34 -0000
@@ -19,6 +19,9 @@
# if defined (_PTHREAD_ENV_DECC) || defined (_PTHREAD_ENV_EPCC) || defined (__PRAGMA_EXTERN_PREFIX)
# define _PTHREAD_USE_PTDNAM_
# endif
+# if defined (_PTHREAD_ENV_DECC) || defined (__PRAGMA_EXTERN_PREFIX)
+# define _PTHREAD_USE_PTDNAM_
+# endif
#endif /* ALPHA_PTHREAD_CHECK */
Index: gcc/fixinc/tests/base/standards.h
===================================================================
RCS file: gcc/fixinc/tests/base/standards.h
diff -N gcc/fixinc/tests/base/standards.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc/fixinc/tests/base/standards.h 7 Jan 2004 19:55:34 -0000
@@ -0,0 +1,14 @@
+/* DO NOT EDIT THIS FILE.
+
+ It has been auto-edited by fixincludes from:
+
+ "fixinc/tests/inc/standards.h"
+
+ This had to be done to correct non-standard usages in the
+ original, manufacturer supplied header file. */
+
+
+
+#if defined( ALPHA___EXTERN_PREFIX_STANDARDS_CHECK )
+#if (_ISO_C_SOURCE>=19990L) && !defined(_LIBC_POLLUTION_H_) && !defined(__DECC) && !defined(__PRAGMA_EXTERN_PREFIX)
+#endif /* ALPHA___EXTERN_PREFIX_STANDARDS_CHECK */
Index: gcc/fixinc/tests/base/testing.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/tests/base/testing.h,v
retrieving revision 1.12
diff -u -p -r1.12 testing.h
--- gcc/fixinc/tests/base/testing.h 22 Apr 2003 23:41:28 -0000 1.12
+++ gcc/fixinc/tests/base/testing.h 7 Jan 2004 19:55:34 -0000
@@ -9,6 +9,16 @@
+#if defined( ALPHA___EXTERN_PREFIX_CHECK )
+#if (defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX))
+#pragma extern_prefix "_P"
+# if (defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX))
+# pragma extern_prefix "_E"
+# if !defined(_LIBC_POLLUTION_H_) && (defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX))
+# pragma extern_prefix ""
+#endif /* ALPHA___EXTERN_PREFIX_CHECK */
+
+
#if defined( AVOID_WCHAR_T_TYPE_CHECK )
#ifndef __cplusplus
typedef unsigned short wchar_t ;
Index: gcc/fixinc/tests/base/sys/stat.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/tests/base/sys/stat.h,v
retrieving revision 1.7
diff -u -p -r1.7 stat.h
--- gcc/fixinc/tests/base/sys/stat.h 1 Mar 2003 20:27:46 -0000 1.7
+++ gcc/fixinc/tests/base/sys/stat.h 7 Jan 2004 19:55:34 -0000
@@ -9,9 +9,9 @@
-#if defined( ALPHA___EXTERN_PREFIX_CHECK )
+#if defined( ALPHA___EXTERN_PREFIX_SYS_STAT_CHECK )
# if defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX)
-#endif /* ALPHA___EXTERN_PREFIX_CHECK */
+#endif /* ALPHA___EXTERN_PREFIX_SYS_STAT_CHECK */
#if defined( RS6000_FCHMOD_CHECK )