Patchwork [gccgo] Fixes for building with --enable-build-with-cxx

login
register
mail settings
Submitter Ian Taylor
Date Nov. 11, 2010, 11 p.m.
Message ID <mcroc9vpisp.fsf@google.com>
Download mbox | patch
Permalink /patch/70888/
State New
Headers show

Comments

Ian Taylor - Nov. 11, 2010, 11 p.m.
This changes the gcc-specific parts of the Go frontend in order to build
with --enable-build-with-cxx.

* Leave ALL_CXXFLAGS to the top-level Makefile.in.
* Build gospec.o with $(COMPILER) rather than $(CC).
* Define GO_EXTERN_C for .cc files to use with function definitions.
* Don't use extern "C" if ENABLE_BUILD_WITH_CXX.
* Include "config.h" before all header files.

Committed to gccgo branch.

Ian

Patch

Index: go/Make-lang.in
===================================================================
--- go/Make-lang.in	(revision 166591)
+++ go/Make-lang.in	(working copy)
@@ -20,10 +20,6 @@ 
 
 # This file provides the language dependent support in the main Makefile.
 
-# C++ support.  This should really be in the top level Makefile.
-
-ALL_CXXFLAGS = $(filter-out -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wc++-compat, $(ALL_COMPILERFLAGS)) $(CXXFLAGS)
-
 # Build Go export info generator.
 INTERNAL_CFLAGS += -DGO_DEBUGGING_INFO
 
@@ -40,7 +36,7 @@  go: go1$(exeext)
 gospec.o: $(srcdir)/go/gospec.c $(SYSTEM_H) coretypes.h $(TM_H) $(GCC_H) \
     $(CONFIG_H) opts.h
 	(SHLIB_LINK='$(SHLIB_LINK)'; \
-	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \
+	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \
 		$(INCLUDES) $(srcdir)/go/gospec.c)
 
 GCCGO_OBJS = $(GCC_OBJS) gospec.o intl.o prefix.o version.o
Index: go/go-c.h
===================================================================
--- go/go-c.h	(revision 166591)
+++ go/go-c.h	(working copy)
@@ -20,7 +20,13 @@  along with GCC; see the file COPYING3.  
 #ifndef GO_GO_C_H
 #define GO_GO_C_H
 
-#ifdef __cplusplus
+#ifdef ENABLE_BUILD_WITH_CXX
+#define GO_EXTERN_C
+#else
+#define GO_EXTERN_C extern "C"
+#endif
+
+#if defined(__cplusplus) && !defined(ENABLE_BUILD_WITH_CXX)
 extern "C"
 {
 #endif
@@ -40,7 +46,7 @@  extern void go_write_globals(void);
 extern tree go_type_for_size(unsigned int bits, int unsignedp);
 extern tree go_type_for_mode(enum machine_mode, int unsignedp);
 
-#ifdef __cplusplus
+#if defined(__cplusplus) && !defined(ENABLE_BUILD_WITH_CXX)
 } /* End extern "C".  */
 #endif
 
Index: go/go-system.h
===================================================================
--- go/go-system.h	(revision 166591)
+++ go/go-system.h	(working copy)
@@ -20,6 +20,8 @@ 
 #ifndef GO_SYSTEM_H
 #define GO_SYSTEM_H
 
+#include "config.h"
+
 // These must be included before the #poison declarations in system.h.
 
 #include <string>
@@ -41,10 +43,11 @@ 
 // later.
 #include <cstdio>
 
+#ifndef ENABLE_BUILD_WITH_CXX
 extern "C"
 {
+#endif
 
-#include "config.h"
 #include "system.h"
 #include "ansidecl.h"
 #include "coretypes.h"
@@ -53,6 +56,8 @@  extern "C"
 #include "diagnostic-core.h"
 #include "input.h"
 
+#ifndef ENABLE_BUILD_WITH_CXX
 } // End extern "C"
+#endif
 
 #endif // !defined(GO_SYSTEM_H)