Patchwork Allow Tru64 UNIX bootstrap with C++

login
register
mail settings
Submitter Rainer Orth
Date July 21, 2011, 12:57 p.m.
Message ID <yddd3h3lrk3.fsf@manam.CeBiTec.Uni-Bielefeld.DE>
Download mbox | patch
Permalink /patch/106040/
State New
Headers show

Comments

Rainer Orth - July 21, 2011, 12:57 p.m.
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 <reg_types.h> has

typedef off_t regoff_t;

  with <sys/types.h>:

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:
  <sys/lc_core.h> has

/* only include when using full prototypes to avoid extra */
/* name space cruft in default case */
#ifndef _NO_PROTO
#include <nl_types.h>
#include <va_list.h>
#ifdef __cplusplus
#include <reg_types.h>
#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  <ro@CeBiTec.Uni-Bielefeld.DE>

	gcc:
	* system.h [__cplusplus]: Wrap in extern "C".

	include:
	* xregex2.h [__osf__ && __cplusplus] (regoff_t): Alternative
	typedef.
Joseph S. Myers - July 21, 2011, 7:53 p.m.
On Thu, 21 Jul 2011, Rainer Orth wrote:

> 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
> +

I don't think it's right to surround any system header includes with 
extern "C".  If a particular declaration in system.h needs to be extern 
"C", surround only that declaration (though preferably such declarations 
might go in other headers with their own extern "C").
Ian Taylor - July 22, 2011, 5:52 a.m.
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> 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 <stdarg.h>
>  
> @@ -969,4 +973,8 @@ helper_const_non_const_cast (const char 
>  #define DEBUG_VARIABLE
>  #endif
>  
> +#ifdef __cplusplus
> +}
> +#endif
> +
>  #endif /* ! GCC_SYSTEM_H */

I agree with Joseph that this is wrong.  We must never wrap the #include
of a system header file with extern "C".  That will simply break on some
systems.  You should only wrap extern "C" around the various HAVE_DECL
declarations.



> 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

No, the right way to handle this is to add regoff_t to include/xregex.h.

Ian

Patch

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 <stdarg.h>
 
@@ -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