From patchwork Thu Jul 21 12:57:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Allow Tru64 UNIX bootstrap with C++ Date: Thu, 21 Jul 2011 02:57:32 -0000 From: Rainer Orth X-Patchwork-Id: 106040 Message-Id: To: gcc-patches@gcc.gnu.org Cc: Ian Lance Taylor On Tru64 UNIX, I ran into two problems with C++ bootstrap: * gcc.c doesn't compile: In file included from /vol/gcc/src/hg/trunk/local/gcc/../include/xregex.h:26:0, from /vol/gcc/src/hg/trunk/local/gcc/gcc.c:38: /vol/gcc/src/hg/trunk/local/gcc/../include/xregex2.h:402:13: error: conflicting declaration 'typedef int regoff_t' /usr/include/reg_types.h:49:15: error: 'regoff_t' has a previous declaration as 'typedef off_t regoff_t' make[3]: *** [gcc.o] Error 1 include/xregex2.h has /* Type for byte offsets within the string. POSIX mandates this. */ typedef int regoff_t; while has typedef off_t regoff_t; with : typedef long off_t; /* file offset */ While this would conflict with C, too, I only find the xregex2.h typedef in C -save-temps output. C++ is different, though: has /* only include when using full prototypes to avoid extra */ /* name space cruft in default case */ #ifndef _NO_PROTO #include #include #ifdef __cplusplus #include #endif #endif I'm thus special-casing osf in regex2.h. I had a look at upstream (gnulib) regex.h, but it is unchanged in this regard. * lto-wrapper failed to link (also on IRIX 6.5, both of which lack strsignal in libc): strsignal(int) collect2: error: ld returned 1 exit status make[3]: *** [lto-wrapper] Error 1 While the object file uses the mangled form _Z9strsignali | 0000000000000000 | U | 0000000000000000 lto-wrapper.o libiberty.a has it as a C function. The problem is that gcc/system.h isn't wrapped in extern "C". Doing so allows the link to succeed. The bootstraps are still running, ok for mainline if they succeed? Thanks. Rainer 2011-07-21 Rainer Orth gcc: * system.h [__cplusplus]: Wrap in extern "C". include: * xregex2.h [__osf__ && __cplusplus] (regoff_t): Alternative typedef. diff --git a/gcc/system.h b/gcc/system.h --- a/gcc/system.h +++ b/gcc/system.h @@ -24,6 +24,10 @@ along with GCC; see the file COPYING3. #ifndef GCC_SYSTEM_H #define GCC_SYSTEM_H +#ifdef __cplusplus +extern "C" { +#endif + /* We must include stdarg.h before stdio.h. */ #include @@ -969,4 +973,8 @@ helper_const_non_const_cast (const char #define DEBUG_VARIABLE #endif +#ifdef __cplusplus +} +#endif + #endif /* ! GCC_SYSTEM_H */ diff --git a/include/xregex2.h b/include/xregex2.h --- a/include/xregex2.h +++ b/include/xregex2.h @@ -399,7 +399,11 @@ struct re_pattern_buffer typedef struct re_pattern_buffer regex_t; /* Type for byte offsets within the string. POSIX mandates this. */ +#if defined(__osf__) && defined(__cplusplus) +typedef off_t regoff_t; +#else typedef int regoff_t; +#endif /* This is the structure we store register match data in. See