This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
3.4 PATCH: Handle C++ like ISO C94 on Tru64 UNIX
- 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, Roger Sayle <roger at eyesopen dot com>, Bruce Korb <bkorb at gnu dot org>
- Date: Fri, 21 Nov 2003 18:01:07 +0100 (MET)
- Subject: 3.4 PATCH: Handle C++ like ISO C94 on Tru64 UNIX
For quite some time, mainline GCC fails to bootstrap on Tru64 UNIX V4.0F
and V5.1B, building libstdc++-v3:
In file included from /vol/gcc/obj/gcc-3.4-20031117/4.0f-gcc/alpha-dec-osf4.0f/libstdc++-v3/include/bits/postypes.h:46,
from /vol/gcc/obj/gcc-3.4-20031117/4.0f-gcc/alpha-dec-osf4.0f/libstdc++-v3/include/iosfwd:50,
from /vol/gcc/obj/gcc-3.4-20031117/4.0f-gcc/alpha-dec-osf4.0f/libstdc++-v3/include/bits/localefwd.h:47,
from /vol/gcc/obj/gcc-3.4-20031117/4.0f-gcc/alpha-dec-osf4.0f/libstdc++-v3/include/locale:44,
from /vol/gnu/src/gcc/gcc-dist/libstdc++-v3/src/codecvt.cc:30:
/vol/gcc/obj/gcc-3.4-20031117/4.0f-gcc/alpha-dec-osf4.0f/libstdc++-v3/include/cwchar:150: error: `::fwide' has not been declared
make[4]: *** [codecvt.lo] Error 1
This happens because the fwide declaration in <wchar.h> looks as this:
#if (__STDC_VERSION__ == 199409)
extern int fwide __((FILE *, int));
extern wchar_t *wcstok_r __((wchar_t *, const wchar_t *, wchar_t **));
extern size_t __wcsftime_isoc __((wchar_t *, size_t, const wchar_t *, const struct tm *));
#define wcstok wcstok_r
#define wcsftime __wcsftime_isoc
#else
extern wchar_t *wcstok __((wchar_t *, const wchar_t *));
extern size_t wcsftime __((wchar_t *, size_t, const char *, const struct tm *));
# if defined(_REENTRANT) || defined(_THREAD_SAFE)
extern wchar_t *wcstok_r __((wchar_t *, const wchar_t *, wchar_t **));
# endif /* _REENTRANT || _THREAD_SAFE */
#endif /* __STDC_VERSION__ */
Bootstrap started failing when libstdc++-v3 became more lenient about wchar
requirements: the fwide test in acinclude.m4 only uses AC_CHECK_FUNCS,
which can only detect that the function exists in libc, but doesn't test if
a prototype is available at compile time.
To fix this, I define __STDC_VERSION__ to 199409L for C++ in
TARGET_OS_CPP_BUILTINS. Unfortunately, this isn't enough, since
include/c_std/std_cwchar.h has
#undef wcsftime
#undef wcstok
effectively removing the wcsftime and wcstok declarations. My solution is
to use fixincludes and have the wcstok/wcsftime declarations use
__asm__("wcstok_r"/"__wcsftime_isoc") to change the external names of the
functions.
This fixes the problem on Tru64 UNIX V4.0F. The situation on V5.1B is more
difficult; I'll post a separate patch once the issues there are completely
resolved.
I still need a fix for PR bootstrap/12898 for the bootstrap to complete
successfully, e.g.
http://gcc.gnu.org/ml/gcc-patches/2003-11/msg01598.html
With those changes, a bootstrap on alpha-dec-osf4.0f, and there are no
obvious regressions compared to the last successfull bootstrap on
20031029.
Ok for mainline?
Rainer
-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University
Fri Nov 21 17:44:16 2003 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* config/alpha/osf.h (TARGET_OS_CPP_BUILTINS): Define
__STDC_VERSION__ to ISO C94 for C++.
* fixinc/inclhack.def (alpha_wchar): New fix.
* fixinc/fixincl.x: Regenerate.
* fixinc/tests/base/wchar.h: New file.
Index: gcc/config/alpha/osf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/alpha/osf.h,v
retrieving revision 1.34
diff -u -p -r1.34 osf.h
--- gcc/config/alpha/osf.h 27 Sep 2003 04:48:12 -0000 1.34
+++ gcc/config/alpha/osf.h 21 Nov 2003 16:24:42 -0000
@@ -49,6 +49,13 @@ Boston, MA 02111-1307, USA. */
to be defined for <math.h>. */ \
if (LONG_DOUBLE_TYPE_SIZE == 128) \
builtin_define ("__X_FLOAT"); \
+ \
+ /* Tru64 UNIX V4/V5 provide several ISO C94 \
+ features protected by the corresponding \
+ __STDC_VERSION__ macro. libstdc++ v3 \
+ needs them as well. */ \
+ if (c_dialect_cxx ()) \
+ builtin_define ("__STDC_VERSION__=199409L"); \
} while (0)
/* Accept DEC C flags for multithreaded programs. We use _PTHREAD_USE_D4
Index: gcc/fixinc/inclhack.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/inclhack.def,v
retrieving revision 1.187
diff -u -p -r1.187 inclhack.def
--- gcc/fixinc/inclhack.def 3 Nov 2003 21:07:34 -0000 1.187
+++ gcc/fixinc/inclhack.def 21 Nov 2003 16:24:48 -0000
@@ -634,6 +634,23 @@ fix = {
/*
+ * Change external names of wcstok/wcsftime via asm instead of macros on
+ * Tru64 UNIX V4.0.
+ */
+fix = {
+ hackname = alpha_wchar;
+ files = wchar.h;
+
+ mach = "alpha*-dec-osf4*";
+ select = "#define wcstok wcstok_r";
+ sed = "s@#define wcstok wcstok_r@extern wchar_t *wcstok __((wchar_t *, const wchar_t *, wchar_t **)) __asm__(\"wcstok_r\");@";
+ sed = "s@#define wcsftime __wcsftime_isoc@extern size_t wcsftime __((wchar_t *, size_t, const wchar_t *, const struct tm *)) __asm__(\"__wcsftime_isoc\");@";
+ test_text = "#define wcstok wcstok_r\n"
+ "#define wcsftime __wcsftime_isoc";
+};
+
+
+/*
* For C++, avoid any typedef or macro definition of bool,
* and use the built in type instead.
* HP/UX 10.20 also has it in curses_colr/curses.h.
Index: gcc/fixinc/tests/base/wchar.h
===================================================================
RCS file: gcc/fixinc/tests/base/wchar.h
diff -N gcc/fixinc/tests/base/wchar.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc/fixinc/tests/base/wchar.h 21 Nov 2003 16:31:38 -0000
@@ -0,0 +1,15 @@
+/* DO NOT EDIT THIS FILE.
+
+ It has been auto-edited by fixincludes from:
+
+ "fixinc/tests/inc/wchar.h"
+
+ This had to be done to correct non-standard usages in the
+ original, manufacturer supplied header file. */
+
+
+
+#if defined( ALPHA_WCHAR_CHECK )
+extern wchar_t *wcstok __((wchar_t *, const wchar_t *, wchar_t **)) __asm__("wcstok_r");
+extern size_t wcsftime __((wchar_t *, size_t, const wchar_t *, const struct tm *)) __asm__("__wcsftime_isoc");
+#endif /* ALPHA_WCHAR_CHECK */