public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix --enable-build-with-cxx build
@ 2011-07-11 20:16 Eric Botcazou
  2011-07-12  9:12 ` Rainer Orth
  2011-07-12 10:24 ` Eric Botcazou
  0 siblings, 2 replies; 6+ messages in thread
From: Eric Botcazou @ 2011-07-11 20:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: Laurent GUERBY, Arnaud Charlet

[-- Attachment #1: Type: text/plain, Size: 2130 bytes --]

This is an updated version of Laurent's patch originally here:
  http://gcc.gnu.org/ml/gcc/2009-06/msg00635.html

Bootstrapped/regtested on x86_64-suse-linux with --enable-build-with-cxx.

Arno, I think we should apply it.  This isn't very intrusive in the end and 
with it we can go full C++ instead of requiring 3 compilers to bootstrap.


2011-07-11  Laurent GUERBY <laurent@guerby.net>
            Eric Botcazou  <ebotcazou@adacore.com>

gnattools/
	* Makefile.in (TOOLS_FLAGS_TO_PASS_1): Add LINKER.
	(TOOLS_FLAGS_TO_PASS_1re): Likewise.
	(TOOLS_FLAGS_TO_PASS_NATIVE): Likewise.
	(TOOLS_FLAGS_TO_PASS_CROSS): Likewise.

gcc/
	* prefix.h: Wrap up in extern "C" block.

ada/
	* adadecode.c: Likewise.
	* adadecode.h: Likewise.
	* adaint.c: Likewise.
	* adaint.h: Likewise.
	* argv.c: Likewise.
	* arit64.c: Likewise.
	* atree.h: Likewise.
	* aux-io.c: Likewise.
	* cal.c: Likewise.
	* cio.c: Likewise.
	* cstreams.c: Likewise.
	* ctrl_c.c: Likewise.
	* env.c: Likewise.
	* errno.c: Likewise.
	* exit.c: Likewise.
	* expect.c: Likewise.
	* fe.h: Likewise.
	* final.c: Likewise.
	* init.c: Likewise.
	* initialize.c: Likewise.
	* link.c: Likewise.
	* mkdir.c: Likewise.
	* namet.h: Likewise.
	* nlists.h: Likewise.
	* raise-gcc.c: Likewise.
	* raise.c: Likewise.
	* raise.h: Likewise.
	* repinfo.h: Likewise.
	* s-oscons-tmplt.c: Likewise.
	* seh_init.c: Likewise.
	* socket.c: Likewise.
	* sysdep.c: Likewise.
	* targext.c: Likewise.
	* tb-alvms.c: Likewise.
	* tb-alvxw.c: Likewise.
	* tb-gcc.c: Likewise.
	* tb-ivms.c: Likewise.
	* tracebak.c: Likewise.
	* uintp.h: Likewise.
	* urealp.h: Likewise.
	* vx_stack_info.c: Likewise.
	* xeinfo.adb: Wrap up generated C code in extern "C" block.
	* xsinfo.adb: Wrap up generated C code in extern "C" block.
	* xsnamest.adb: Wrap up generated C code in extern "C" block.
	* gcc-interface/gadaint.h: Wrap up in extern "C" block.
	* gcc-interface/gigi.h: Wrap up prototypes in extern "C" block.
	* gcc-interface/misc.c: Wrap up prototypes in extern "C" block.
	* gcc-interface/Make-lang.in (GCC_LINK): Use LINKER.
	* gcc-interface/Makefile.in (GCC_LINK): Likewise.


-- 
Eric Botcazou

[-- Attachment #2: ada_build_with_cxx.diff --]
[-- Type: text/x-diff, Size: 35542 bytes --]

Index: gnattools/Makefile.in
===================================================================
--- gnattools/Makefile.in	(revision 176072)
+++ gnattools/Makefile.in	(working copy)
@@ -67,6 +67,7 @@ ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdi
 # Variables for gnattools1, native
 TOOLS_FLAGS_TO_PASS_1= \
 	"CC=../../xgcc -B../../" \
+	"LINKER=$(CXX)" \
 	"CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
 	"LDFLAGS=$(LDFLAGS)" \
 	"ADAFLAGS=$(ADAFLAGS)" \
@@ -82,6 +83,7 @@ TOOLS_FLAGS_TO_PASS_1= \
 # Variables for regnattools
 TOOLS_FLAGS_TO_PASS_1re= \
 	"CC=../../xgcc -B../../" \
+	"LINKER=$(CXX)" \
 	"CFLAGS=$(CFLAGS)" \
 	"ADAFLAGS=$(ADAFLAGS)" \
 	"ADA_CFLAGS=$(ADA_CFLAGS)" \
@@ -99,6 +101,7 @@ TOOLS_FLAGS_TO_PASS_1re= \
 # Variables for gnattools2, native
 TOOLS_FLAGS_TO_PASS_NATIVE= \
 	"CC=../../xgcc -B../../" \
+	"LINKER=$(CXX)" \
 	"CFLAGS=$(CFLAGS)" \
 	"ADAFLAGS=$(ADAFLAGS)" \
 	"ADA_CFLAGS=$(ADA_CFLAGS)" \
@@ -115,6 +118,7 @@ TOOLS_FLAGS_TO_PASS_NATIVE= \
 # Variables for gnattools, cross
 TOOLS_FLAGS_TO_PASS_CROSS= \
 	"CC=$(CC)" \
+	"LINKER=$(CXX)" \
 	"CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
 	"LDFLAGS=$(LDFLAGS)" \
 	"ADAFLAGS=$(ADAFLAGS)"	\
Index: gcc/ada/adadecode.h
===================================================================
--- gcc/ada/adadecode.h	(revision 176072)
+++ gcc/ada/adadecode.h	(working copy)
@@ -29,6 +29,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* This function will return the Ada name from the encoded form.
    The Ada coding is done in exp_dbug.ads and this is the inverse function.
    see exp_dbug.ads for full encoding rules, a short description is added
@@ -51,3 +55,7 @@ extern void get_encoding (const char *,
    function used in the binutils and GDB. Always consider using __gnat_decode
    instead of ada_demangle. Caller must free the pointer returned.  */
 extern char *ada_demangle (const char *);
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/sysdep.c
===================================================================
--- gcc/ada/sysdep.c	(revision 176072)
+++ gcc/ada/sysdep.c	(working copy)
@@ -30,7 +30,11 @@
  ****************************************************************************/
 
 /* This file contains system dependent symbols that are referenced in the
-   GNAT Run Time Library */
+   GNAT Run Time Library.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #ifdef __vxworks
 #include "ioLib.h"
@@ -1012,3 +1016,7 @@ __gnat_is_file_not_found_error (int errn
          return 0;
    }
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/targext.c
===================================================================
--- gcc/ada/targext.c	(revision 176072)
+++ gcc/ada/targext.c	(working copy)
@@ -29,9 +29,13 @@
  *                                                                          *
  ****************************************************************************/
 
-/*  This file contains target-specific parameters describing the file       */
-/*  extension for object and executable files. It is used by the compiler,  */
-/*  binder and tools.                                                       */
+/*  This file contains target-specific parameters describing the file
+    extension for object and executable files. It is used by the compiler,
+    inder and tools.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #ifdef IN_RTS
 #include "tconfig.h"
@@ -54,3 +58,7 @@
 const char *__gnat_target_object_extension = TARGET_OBJECT_SUFFIX;
 const char *__gnat_target_executable_extension = TARGET_EXECUTABLE_SUFFIX;
 const char *__gnat_target_debuggable_extension = TARGET_EXECUTABLE_SUFFIX;
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/s-oscons-tmplt.c
===================================================================
--- gcc/ada/s-oscons-tmplt.c	(revision 176072)
+++ gcc/ada/s-oscons-tmplt.c	(working copy)
@@ -93,6 +93,10 @@ pragma Style_Checks ("M32766");
 #endif
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdlib.h>
 #include <string.h>
 #include <limits.h>
@@ -1376,3 +1380,7 @@ CND(PTHREAD_ONCE_SIZE, "Pad in pthread_o
 end System.OS_Constants;
 */
 }
+
+#ifdef __cplusplus
+  }
+#endif
Index: gcc/ada/env.c
===================================================================
--- gcc/ada/env.c	(revision 176072)
+++ gcc/ada/env.c	(working copy)
@@ -37,6 +37,10 @@
 #define _BSD
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -323,3 +327,7 @@ void __gnat_clearenv (void) {
   clearenv ();
 #endif
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/final.c
===================================================================
--- gcc/ada/final.c	(revision 176072)
+++ gcc/ada/final.c	(working copy)
@@ -29,6 +29,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern void __gnat_finalize (void);
 
 /* This routine is called at the extreme end of execution of an Ada program
@@ -40,3 +44,7 @@ void
 __gnat_finalize (void)
 {
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/init.c
===================================================================
--- gcc/ada/init.c	(revision 176072)
+++ gcc/ada/init.c	(working copy)
@@ -38,6 +38,10 @@
     installed by this file are used to catch the resulting signals that come
     from these probes failing (i.e. touching protected pages).  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* This file should be kept synchronized with 2sinit.ads, 2sinit.adb,
    s-init-ae653-cert.adb and s-init-xi-sparc.adb.  All these files implement
    the required functionality for different targets.  */
@@ -2403,3 +2407,7 @@ __gnat_adjust_context_for_raise (int sig
 }
 
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/xsnamest.adb
===================================================================
--- gcc/ada/xsnamest.adb	(revision 176072)
+++ gcc/ada/xsnamest.adb	(working copy)
@@ -194,6 +194,10 @@ begin
    Create (OutB, Out_File, "snames.nb");
    Create (OutH, Out_File, "snames.nh");
 
+   Put_Line (OutH, "#ifdef __cplusplus");
+   Put_Line (OutH, "extern ""C"" {");
+   Put_Line (OutH, "#endif");
+
    Anchored_Mode := True;
    Val := 0;
 
@@ -274,4 +278,8 @@ begin
       Line := Get_Line (InH);
       Put_Line (OutH, Line);
    end loop;
+
+   Put_Line (OutH, "#ifdef __cplusplus");
+   Put_Line (OutH, "}");
+   Put_Line (OutH, "#endif");
 end XSnamesT;
Index: gcc/ada/errno.c
===================================================================
--- gcc/ada/errno.c	(revision 176072)
+++ gcc/ada/errno.c	(working copy)
@@ -32,9 +32,11 @@
 /* This file provides access to the C-language errno to the Ada interface
    for POSIX.  It is not possible in general to import errno, even in
    Ada compilers that allow (as GNAT does) the importation of variables,
-   as it may be defined using a macro.
-*/
+   as it may be defined using a macro.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #define _REENTRANT
 #define _THREAD_SAFE
@@ -64,3 +66,7 @@ __set_errno(int err)
 {
   errno = err;
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/xsinfo.adb
===================================================================
--- gcc/ada/xsinfo.adb	(revision 176072)
+++ gcc/ada/xsinfo.adb	(working copy)
@@ -162,6 +162,11 @@ begin
    end loop;
 
    Put_Line (Ofile, "");
+
+   Put_Line (Ofile, "#ifdef __cplusplus");
+   Put_Line (Ofile, "extern ""C"" {");
+   Put_Line (Ofile, "#endif");
+
    NKV := 0;
 
    --  Loop through node kind codes
@@ -248,6 +253,9 @@ exception
    when Done =>
       Close (InS);
       Put_Line (Ofile, "");
+      Put_Line (Ofile, "#ifdef __cplusplus");
+      Put_Line (Ofile, "}");
+      Put_Line (Ofile, "#endif");
       Close (Ofile);
       Set_Exit_Status (0);
 
Index: gcc/ada/nlists.h
===================================================================
--- gcc/ada/nlists.h	(revision 176072)
+++ gcc/ada/nlists.h	(working copy)
@@ -29,7 +29,11 @@
    nlists.adb and must be kept synchronized with changes in these files.
 
    Note that only routines for reading the tree are included, since the
-   tree transformer is not supposed to modify the tree in any way. */
+   tree transformer is not supposed to modify the tree in any way.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /*  The following is the structure used for the list headers table */
 
@@ -128,3 +132,7 @@ List_Containing (Node_Id Node)
 {
   return Nodes_Ptr[Node - First_Node_Id].V.NX.link;
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/aux-io.c
===================================================================
--- gcc/ada/aux-io.c	(revision 176072)
+++ gcc/ada/aux-io.c	(working copy)
@@ -29,6 +29,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdio.h>
 
 #ifdef IN_RTS
@@ -96,3 +100,7 @@ c_fileno (FILE *s)
 {
   return fileno (s);
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/initialize.c
===================================================================
--- gcc/ada/initialize.c	(revision 176072)
+++ gcc/ada/initialize.c	(working copy)
@@ -32,10 +32,14 @@
 /*  This unit provides default implementation for __gnat_initialize ()
     which is called before the elaboration of the partition. It is provided
     in a separate file/object so that users can replace it easily.
-    The default implementation should be null on most targets. */
+    The default implementation should be null on most targets.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* The following include is here to meet the published VxWorks requirement
-   that the __vxworks header appear before any other include. */
+   that the __vxworks header appear before any other include.  */
 #ifdef __vxworks
 #include "vxWorks.h"
 #endif
@@ -359,3 +363,7 @@ __gnat_initialize (void *eh ATTRIBUTE_UN
 }
 
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/tb-alvms.c
===================================================================
--- gcc/ada/tb-alvms.c	(revision 176072)
+++ gcc/ada/tb-alvms.c	(working copy)
@@ -39,6 +39,10 @@
    Most of the contents is directed by the OpenVMS/Alpha Conventions (ABI)
    document, sections of which we will refer to as ABI-<section_number>.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <vms/pdscdef.h>
 #include <vms/libicb.h>
 #include <vms/chfctxdef.h>
@@ -394,3 +398,7 @@ __gnat_backtrace (void **array, int size
 
   return cnt;
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/repinfo.h
===================================================================
--- gcc/ada/repinfo.h	(revision 176072)
+++ gcc/ada/repinfo.h	(working copy)
@@ -31,6 +31,10 @@
 
 /* This file corresponds to the Ada file repinfo.ads.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef Uint Node_Ref;
 typedef Uint Node_Ref_Or_Val;
 typedef char TCode;
@@ -75,3 +79,7 @@ typedef char TCode;
 #define Create_Node repinfo__create_node
 extern Node_Ref Create_Node	(TCode, Node_Ref_Or_Val,
 				 Node_Ref_Or_Val, Node_Ref_Or_Val);
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/vx_stack_info.c
===================================================================
--- gcc/ada/vx_stack_info.c	(revision 176072)
+++ gcc/ada/vx_stack_info.c	(working copy)
@@ -30,7 +30,11 @@
  ****************************************************************************/
 
 /* VxWorks-specific file to have access to task-specific data and be able
-   to extract the stack boundaries for stack checking. */
+   to extract the stack boundaries for stack checking.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #include <taskLib.h>
 
@@ -59,3 +63,7 @@ __gnat_get_stack_info (stack_info *vxwor
   vxworks_stack_info->base = descriptor.td_pStackBase;
   vxworks_stack_info->end  = descriptor.td_pStackEnd;
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/fe.h
===================================================================
--- gcc/ada/fe.h	(revision 176072)
+++ gcc/ada/fe.h	(working copy)
@@ -32,6 +32,10 @@
 /* This file contains definitions to access front-end functions and
    variables used by gigi.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* comperr:  */
 
 #define Compiler_Abort comperr__compiler_abort
@@ -251,3 +255,7 @@ extern void Set_Has_No_Elaboration_Code
 extern Boolean Backend_Overflow_Checks_On_Target;
 extern Boolean Stack_Check_Probes_On_Target;
 extern Boolean Stack_Check_Limits_On_Target;
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/tb-ivms.c
===================================================================
--- gcc/ada/tb-ivms.c	(revision 176072)
+++ gcc/ada/tb-ivms.c	(working copy)
@@ -30,6 +30,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Itanium Open/VMS implementation of backtrace.  Use ICB (Invocation
    Context Block) routines.  */
 #include <stdlib.h>
@@ -87,3 +91,8 @@ __gnat_backtrace (void **array, int size
   LIB$I64_FREE_INVO_CONTEXT (ctxt);
   return res;
 }
+
+#ifdef __cplusplus
+}
+#endif
+
Index: gcc/ada/mkdir.c
===================================================================
--- gcc/ada/mkdir.c	(revision 176072)
+++ gcc/ada/mkdir.c	(working copy)
@@ -29,6 +29,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __vxworks
 #include "vxWorks.h"
 #include <version.h>
@@ -71,3 +75,7 @@ __gnat_mkdir (char *dir_name)
   return mkdir (dir_name, S_IRWXU | S_IRWXG | S_IRWXO);
 #endif
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/socket.c
===================================================================
--- gcc/ada/socket.c	(revision 176072)
+++ gcc/ada/socket.c	(working copy)
@@ -29,7 +29,11 @@
  *                                                                          *
  ****************************************************************************/
 
-/*  This file provides a portable binding to the sockets API                */
+/*  This file provides a portable binding to the sockets API.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #include "gsocket.h"
 
@@ -688,3 +692,7 @@ __gnat_servent_s_proto (struct servent *
 #else
 # warning Sockets are not supported on this platform
 #endif /* defined(HAVE_SOCKETS) */
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/raise.c
===================================================================
--- gcc/ada/raise.c	(revision 176072)
+++ gcc/ada/raise.c	(working copy)
@@ -32,6 +32,10 @@
 /* Shared routines to support exception handling.  __gnat_unhandled_terminate
    is shared between all exception handling mechanisms.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -79,3 +83,7 @@ __gnat_unhandled_terminate (void)
   /* Default termination handling */
   __gnat_os_exit (1);
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/tb-alvxw.c
===================================================================
--- gcc/ada/tb-alvxw.c	(revision 176072)
+++ gcc/ada/tb-alvxw.c	(working copy)
@@ -34,6 +34,10 @@
    from GDB. This file is #included within tracebak.c in the appropriate
    case.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stddef.h>
 #include <stdlib.h>
 #include <limits.h>
@@ -939,3 +943,7 @@ __gnat_backtrace (void **array,
 
   return cnt;
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/raise.h
===================================================================
--- gcc/ada/raise.h	(revision 176072)
+++ gcc/ada/raise.h	(working copy)
@@ -29,6 +29,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* C counterparts of what System.Standard_Library defines.  */
 
 typedef unsigned Exception_Code;
@@ -60,3 +64,7 @@ extern void __gnat_install_SEH_handler
 extern void __gnat_adjust_context_for_raise (int, void *);
 
 extern int gnat_exit_status;
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/xeinfo.adb
===================================================================
--- gcc/ada/xeinfo.adb	(revision 176072)
+++ gcc/ada/xeinfo.adb	(working copy)
@@ -276,6 +276,10 @@ begin
 
    Put_Line (Ofile, "");
 
+   Put_Line (Ofile, "#ifdef __cplusplus");
+   Put_Line (Ofile, "extern ""C"" {");
+   Put_Line (Ofile, "#endif");
+
    --  Find and record pragma Inlines
 
    loop
@@ -492,6 +496,11 @@ begin
    end loop;
 
    Put_Line (Ofile, "");
+
+   Put_Line (Ofile, "#ifdef __cplusplus");
+   Put_Line (Ofile, "}");
+   Put_Line (Ofile, "#endif");
+
    Put_Line
      (Ofile,
       "/* End of einfo.h (C version of Einfo package specification) */");
Index: gcc/ada/exit.c
===================================================================
--- gcc/ada/exit.c	(revision 176072)
+++ gcc/ada/exit.c	(working copy)
@@ -29,6 +29,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __alpha_vxworks
 #include "vxWorks.h"
 #endif
@@ -53,3 +57,7 @@ __gnat_set_exit_status (int i)
 {
   gnat_exit_status = i;
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/arit64.c
===================================================================
--- gcc/ada/arit64.c	(revision 176072)
+++ gcc/ada/arit64.c	(working copy)
@@ -29,6 +29,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern void __gnat_rcheck_10(char *file, int line)
   __attribute__ ((__noreturn__));
 
@@ -55,3 +59,7 @@ long long int __gnat_mulv64 (long long i
 
   return (long long int) (neg ? -low : low);
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/adaint.c
===================================================================
--- gcc/ada/adaint.c	(revision 176072)
+++ gcc/ada/adaint.c	(working copy)
@@ -34,6 +34,10 @@
    package Osint.  Many of the subprograms in OS_Lib import standard
    library calls directly. This file contains all other routines.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __vxworks
 
 /* No need to redefine exit here.  */
@@ -291,9 +295,9 @@ const char *__gnat_library_template = GN
 /* This variable is used in hostparm.ads to say whether the host is a VMS
    system.  */
 #ifdef VMS
-const int __gnat_vmsp = 1;
+int __gnat_vmsp = 1;
 #else
-const int __gnat_vmsp = 0;
+int __gnat_vmsp = 0;
 #endif
 
 #if defined (VMS)
@@ -324,7 +328,7 @@ const int __gnat_vmsp = 0;
 #endif
 
 /* Used for Ada bindings */
-const int __gnat_size_of_file_attributes = sizeof (struct file_attributes);
+int __gnat_size_of_file_attributes = sizeof (struct file_attributes);
 
 /* Reset the file attributes as if no system call had been performed */
 void __gnat_stat_to_attr (int fd, char* name, struct file_attributes* attr);
@@ -3686,3 +3690,7 @@ void *__gnat_lwp_self (void)
    return (void *) syscall (__NR_gettid);
 }
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/adaint.h
===================================================================
--- gcc/ada/adaint.h	(revision 176072)
+++ gcc/ada/adaint.h	(working copy)
@@ -29,6 +29,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <sys/stat.h>
 #include <stdio.h>
 
@@ -262,3 +266,7 @@ extern int    get_gcc_version
 
 extern int    __gnat_binder_supports_auto_init     (void);
 extern int    __gnat_sals_init_using_constructors  (void);
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/ctrl_c.c
===================================================================
--- gcc/ada/ctrl_c.c	(revision 176072)
+++ gcc/ada/ctrl_c.c	(working copy)
@@ -29,6 +29,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -164,3 +168,7 @@ __gnat_uninstall_int_handler (void)
 {
 }
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/cio.c
===================================================================
--- gcc/ada/cio.c	(revision 176072)
+++ gcc/ada/cio.c	(working copy)
@@ -29,6 +29,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -129,3 +133,7 @@ mktemp (char *template)
   return tmpnam (NULL);
 }
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/raise-gcc.c
===================================================================
--- gcc/ada/raise-gcc.c	(revision 176072)
+++ gcc/ada/raise-gcc.c	(working copy)
@@ -32,6 +32,10 @@
 /* Code related to the integration of the GCC mechanism for exception
    handling.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -1240,3 +1244,7 @@ __gnat_Unwind_ForcedUnwind (_Unwind_Exce
 }
 
 #endif /* IN_RTS */
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/cstreams.c
===================================================================
--- gcc/ada/cstreams.c	(revision 176072)
+++ gcc/ada/cstreams.c	(working copy)
@@ -29,7 +29,11 @@
  *                                                                          *
  ****************************************************************************/
 
-/* Routines required for implementing routines in Interfaces.C.Streams */
+/* Routines required for implementing routines in Interfaces.C.Streams.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #ifdef __vxworks
 #include "vxWorks.h"
@@ -242,3 +246,7 @@ __gnat_full_name (char *nam, char *buffe
 
   return buffer;
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/cal.c
===================================================================
--- gcc/ada/cal.c	(revision 176072)
+++ gcc/ada/cal.c	(working copy)
@@ -29,11 +29,15 @@
  *                                                                          *
  ****************************************************************************/
 
-/*  This file contains those routines named by Import pragmas in package    */
-/*  GNAT.Calendar. It is used to do Duration to timeval conversion.         */
-/*  These are simple wrappers function to abstract the fact that the C      */
-/*  struct timeval fields type are not normalized (they are generally       */
-/*  defined as int or long values).                                         */
+/*  This file contains those routines named by Import pragmas in package 
+    GNAT.Calendar. It is used to do Duration to timeval conversion.
+    These are simple wrappers function to abstract the fact that the C
+    struct timeval fields type are not normalized (they are generally
+    defined as int or long values).  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #if defined(VMS) || defined(__nucleus__)
 
@@ -107,3 +111,7 @@ gnat_time (void)
 {
   return time (0);
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/uintp.h
===================================================================
--- gcc/ada/uintp.h	(revision 176072)
+++ gcc/ada/uintp.h	(working copy)
@@ -24,7 +24,11 @@
  ****************************************************************************/
 
 /* This file corresponds to the Ada package specification Uintp. It was
-   created manually from the files uintp.ads and uintp.adb  */
+   created manually from the files uintp.ads and uintp.adb.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* Support for universal integer arithmetic */
 
@@ -94,3 +98,7 @@ extern struct Uint_Entry *uintp__uints__
 
 #define Udigits_Ptr uintp__udigits__table
 extern int *uintp__udigits__table;
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/tracebak.c
===================================================================
--- gcc/ada/tracebak.c	(revision 176072)
+++ gcc/ada/tracebak.c	(working copy)
@@ -46,6 +46,10 @@
    Alpha/VMS
 */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __alpha_vxworks
 #include "vxWorks.h"
 #endif
@@ -513,3 +517,7 @@ __gnat_backtrace (void **array ATTRIBUTE
 #endif
 
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/urealp.h
===================================================================
--- gcc/ada/urealp.h	(revision 176072)
+++ gcc/ada/urealp.h	(working copy)
@@ -24,7 +24,11 @@
  ****************************************************************************/
 
 /* This file corresponds to the Ada package specification Urealp. It was
-   created manually from the files urealp.ads and urealp.adb  */
+   created manually from the files urealp.ads and urealp.adb.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* Support for universal real arithmetic.  */
 
@@ -48,3 +52,7 @@ enum Rounding_Mode {Floor = 0, Ceiling =
 #define Machine eval_fat__machine
 extern Ureal Machine		(Entity_Id, Ureal, enum Rounding_Mode,
 				 Node_Id);
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/namet.h
===================================================================
--- gcc/ada/namet.h	(revision 176072)
+++ gcc/ada/namet.h	(working copy)
@@ -26,6 +26,10 @@
 /* This is the C file that corresponds to the Ada package specification
    Namet. It was created manually from files namet.ads and namet.adb.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Structure defining a names table entry.  */
 
 struct Name_Entry
@@ -127,3 +131,7 @@ extern Source_File_Index Get_Source_File
 extern Logical_Line_Number Get_Logical_Line_Number (Source_Ptr);
 extern Column_Number Get_Column_Number (Source_Ptr);
 extern Source_Ptr Instantiation (Source_File_Index);
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/tb-gcc.c
===================================================================
--- gcc/ada/tb-gcc.c	(revision 176072)
+++ gcc/ada/tb-gcc.c	(working copy)
@@ -34,6 +34,10 @@
    underlying GCC unwinding support associated with the exception handling
    infrastructure.  This will only work for ZCX based applications.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <unwind.h>
 
 /* The implementation boils down to a call to _Unwind_Backtrace with a
@@ -124,3 +128,7 @@ __gnat_backtrace (void ** traceback __at
   return uw_data.n_entries_filled;
 #endif
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/gcc-interface/Makefile.in
===================================================================
--- gcc/ada/gcc-interface/Makefile.in	(revision 176072)
+++ gcc/ada/gcc-interface/Makefile.in	(working copy)
@@ -2281,7 +2281,7 @@ ADA_INCLUDE_SRCS =\
 
 LIBGNAT=../$(RTSDIR)/libgnat.a
 
-GCC_LINK=$(CC) $(GCC_LINK_FLAGS) $(ADA_INCLUDES)
+GCC_LINK=$(LINKER) $(GCC_LINK_FLAGS) $(ADA_INCLUDES)
 
 # when compiling the tools, the runtime has to be first on the path so that
 # it hides the runtime files lying with the rest of the sources
Index: gcc/ada/gcc-interface/gadaint.h
===================================================================
--- gcc/ada/gcc-interface/gadaint.h	(revision 176072)
+++ gcc/ada/gcc-interface/gadaint.h	(working copy)
@@ -30,6 +30,14 @@
 #ifndef GCC_ADAINT_H
 #define GCC_ADAINT_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern char *__gnat_to_canonical_file_spec (char *);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* GCC_ADAINT_H */
Index: gcc/ada/gcc-interface/Make-lang.in
===================================================================
--- gcc/ada/gcc-interface/Make-lang.in	(revision 176072)
+++ gcc/ada/gcc-interface/Make-lang.in	(working copy)
@@ -104,7 +104,7 @@ ADA_TOOLS_FLAGS_TO_PASS=\
 	"GNATLINK=../../gnatlink"	\
 	"GNATBIND=../../gnatbind"
 
-GCC_LINK=$(CC) -static-libgcc $(LDFLAGS)
+GCC_LINK=$(LINKER) -static-libgcc $(LDFLAGS)
 
 # Lists of files for various purposes.
 
Index: gcc/ada/gcc-interface/gigi.h
===================================================================
--- gcc/ada/gcc-interface/gigi.h	(revision 176072)
+++ gcc/ada/gcc-interface/gigi.h	(working copy)
@@ -199,6 +199,10 @@ struct File_Info_Type
   Nat Num_Source_Lines;
 };
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* This is the main program of the back-end.  It sets up all the table
    structures and then generates code.  */
 extern void gigi (Node_Id gnat_root, int max_gnat_node,
@@ -218,6 +222,10 @@ extern void gigi (Node_Id gnat_root, int
                   Entity_Id standard_exception_type,
                   Int gigi_operating_mode);
 
+#ifdef __cplusplus
+}
+#endif
+
 /* GNAT_NODE is the root of some GNAT tree.  Return the root of the
    GCC tree corresponding to that GNAT tree.  Normally, no code is generated;
    we just return an equivalent tree which is used elsewhere to generate
@@ -929,6 +937,11 @@ extern int fp_size_to_prec (int size);
 /* These functions return the basic data type sizes and related parameters
    about the target machine.  */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern Pos get_target_bits_per_unit (void);
 extern Pos get_target_bits_per_word (void);
 extern Pos get_target_char_size (void);
@@ -953,6 +966,10 @@ extern Nat get_target_strict_alignment (
 extern Nat get_target_double_float_alignment (void);
 extern Nat get_target_double_scalar_alignment (void);
 
+#ifdef __cplusplus
+}
+#endif
+
 /* Let code know whether we are targetting VMS without need of
    intrusive preprocessor directives.  */
 #ifndef TARGET_ABI_OPEN_VMS
Index: gcc/ada/gcc-interface/misc.c
===================================================================
--- gcc/ada/gcc-interface/misc.c	(revision 176072)
+++ gcc/ada/gcc-interface/misc.c	(working copy)
@@ -68,12 +68,20 @@ const char **save_argv;
 extern int gnat_argc;
 extern char **gnat_argv;
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Declare functions we use as part of startup.  */
 extern void __gnat_initialize (void *);
 extern void __gnat_install_SEH_handler (void *);
 extern void adainit (void);
 extern void _ada_gnat1drv (void);
 
+#ifdef __cplusplus
+}
+#endif
+
 /* The parser for the language.  For us, we process the GNAT tree.  */
 
 static void
Index: gcc/ada/argv.c
===================================================================
--- gcc/ada/argv.c	(revision 176072)
+++ gcc/ada/argv.c	(working copy)
@@ -42,6 +42,10 @@
    main program, and these routines are accessed from the
    Ada.Command_Line.Environment package. */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -116,3 +120,7 @@ __gnat_fill_env (char *a, int i)
   if (gnat_envp != NULL)
     strncpy (a, gnat_envp[i], strlen (gnat_envp[i]));
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/atree.h
===================================================================
--- gcc/ada/atree.h	(revision 176072)
+++ gcc/ada/atree.h	(working copy)
@@ -29,7 +29,11 @@
    atree.adb and must be kept synchronized with changes in these files.
 
    Note that only routines for reading the tree are included, since the tree
-   transformer is not supposed to modify the tree in any way. */
+   transformer is not supposed to modify the tree in any way.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* Structure used for the first part of the node in the case where we have
    an Nkind.  */
@@ -734,3 +738,6 @@ extern Node_Id Current_Error_Node;
 #define Flag253(N)     (Nodes_Ptr[(N) - First_Node_Id + 4].U.NK.flag71)
 #define Flag254(N)     (Nodes_Ptr[(N) - First_Node_Id + 4].U.NK.flag72)
 
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/expect.c
===================================================================
--- gcc/ada/expect.c	(revision 176072)
+++ gcc/ada/expect.c	(working copy)
@@ -30,6 +30,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __alpha_vxworks
 #include "vxWorks.h"
 #endif
@@ -511,3 +515,7 @@ __gnat_expect_poll (int *fd, int num_fd,
   return -1;
 }
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/seh_init.c
===================================================================
--- gcc/ada/seh_init.c	(revision 176072)
+++ gcc/ada/seh_init.c	(working copy)
@@ -32,6 +32,10 @@
 /*  This unit contains support for SEH (Structured Exception Handling).
     Right now the only implementation is for Win32.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -311,3 +315,7 @@ void __gnat_install_SEH_handler (void *e
 {
 }
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/adadecode.c
===================================================================
--- gcc/ada/adadecode.c	(revision 176072)
+++ gcc/ada/adadecode.c	(working copy)
@@ -352,6 +352,10 @@ __gnat_decode (const char *coded_name, c
     }
 }
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_GCC
 char *
 ada_demangle (const char *coded_name)
@@ -402,3 +406,7 @@ get_encoding (const char *coded_name, ch
 
   *dest_index = '\0';
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/ada/link.c
===================================================================
--- gcc/ada/link.c	(revision 176072)
+++ gcc/ada/link.c	(working copy)
@@ -29,9 +29,12 @@
  *                                                                          *
  ****************************************************************************/
 
-/*  This file contains host-specific parameters describing the behavior     */
-/*  of the linker. It is used by gnatlink as well as all tools that use     */
-/*  Mlib.                                                                   */
+/*  This file contains host-specific parameters describing the behavior of the
+    linker.  It is used by gnatlink as well as all tools that use Mlib.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #include <string.h>
 
@@ -254,3 +257,7 @@ const char *__gnat_object_library_extens
 unsigned char __gnat_separate_run_path_options = 0;
 const char *__gnat_default_libgcc_subdir = "lib";
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: gcc/prefix.h
===================================================================
--- gcc/prefix.h	(revision 176072)
+++ gcc/prefix.h	(working copy)
@@ -21,10 +21,20 @@ License along with GCC; see the file COP
 #ifndef GCC_PREFIX_H
 #define GCC_PREFIX_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* These functions are called by the Ada frontend with C convention.  */
+
 /* Update PATH using KEY if PATH starts with PREFIX.  The returned
    string is always malloc-ed, and the caller is responsible for
    freeing it.  */
 extern char *update_path (const char *path, const char *key);
 extern void set_std_prefix (const char *, int);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* ! GCC_PREFIX_H */

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Ada] Fix --enable-build-with-cxx build
  2011-07-11 20:16 [Ada] Fix --enable-build-with-cxx build Eric Botcazou
@ 2011-07-12  9:12 ` Rainer Orth
  2011-07-12 10:24 ` Eric Botcazou
  1 sibling, 0 replies; 6+ messages in thread
From: Rainer Orth @ 2011-07-12  9:12 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches, Laurent GUERBY, Arnaud Charlet

Eric Botcazou <ebotcazou@adacore.com> writes:

> gcc/
> 	* prefix.h: Wrap up in extern "C" block.
>
> ada/
> 	* adadecode.c: Likewise.

No `Likewise.' in different ChangeLogs :-)

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Ada] Fix --enable-build-with-cxx build
  2011-07-11 20:16 [Ada] Fix --enable-build-with-cxx build Eric Botcazou
  2011-07-12  9:12 ` Rainer Orth
@ 2011-07-12 10:24 ` Eric Botcazou
  2011-07-12 10:36   ` Arnaud Charlet
  2011-07-21 14:34   ` Eric Botcazou
  1 sibling, 2 replies; 6+ messages in thread
From: Eric Botcazou @ 2011-07-12 10:24 UTC (permalink / raw)
  To: gcc-patches; +Cc: Laurent GUERBY, Arnaud Charlet

[-- Attachment #1: Type: text/plain, Size: 2128 bytes --]

> This is an updated version of Laurent's patch originally here:
>   http://gcc.gnu.org/ml/gcc/2009-06/msg00635.html

Revised version, only 33 files modified now (instead of 51).  We compile the C 
files for the compiler proper (and gnatbind) with the C++ compiler, but we 
keep compiling them with the C compiler in the other cases (library & tools).
I think that this is in keeping with the other compilers (e.g. libgcc is still 
compiled with the C compiler).

Bootstrapped/regtested on x86_64-suse-linux with --enable-build-with-cxx.

Arno, do you have any objections to me applying this?


2011-07-12  Laurent GUERBY  <laurent@guerby.net>
            Eric Botcazou  <ebotcazou@adacore.com>

gcc/
        * prefix.h: Wrap up in extern "C" block.
ada/
        * adadecode.c: Wrap up in extern "C" block.
        * adadecode.h: Likewise.
        * adaint.c: Likewise.  Remove 'const' keyword.
        * adaint.h: Likewise.
        * argv.c: Likewise.
        * atree.h: Likewise.
        * cio.c: Likewise.
        * cstreams.c: Likewise.
        * env.c: Likewise.
        * exit.c: Likewise.
        * fe.h: Likewise.
        * final.c: Likewise.
        * init.c: Likewise.
        * initialize.c: Likewise.
        * link.c: Likewise.
        * namet.h: Likewise.
        * nlists.h: Likewise.
        * raise.c: Likewise.
        * raise.h: Likewise.
        * repinfo.h: Likewise.
        * seh_init.c: Likewise.
        * targext.c: Likewise.
        * tracebak.c: Likewise.
        * uintp.h: Likewise.
        * urealp.h: Likewise.
        * xeinfo.adb: Wrap up generated C code in extern "C" block.
        * xsinfo.adb: Likewise.
        * xsnamest.adb: Likewise.
        * gcc-interface/gadaint.h: Wrap up in extern "C" block.
        * gcc-interface/gigi.h: Wrap up some prototypes in extern "C" block.
        * gcc-interface/misc.c: Likewise.
        * gcc-interface/Make-lang.in (GCC_LINK): Use LINKER.
	(GNAT1_C_OBJS): Remove ada/b_gnat1.o.  List ada/seh_init.o and
	ada/targext.o here...
	(GNAT_ADA_OBJS): ...and not here.
	(GNAT1_ADA_OBJS): Add ada/b_gnat1.o.
	(GNATBIND_OBJS): Reorder.


-- 
Eric Botcazou

[-- Attachment #2: ada_build_with_cxx-2.diff --]
[-- Type: text/x-diff, Size: 42919 bytes --]

Index: ada/adadecode.h
===================================================================
--- ada/adadecode.h	(revision 176072)
+++ ada/adadecode.h	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                              C Header File                               *
  *                                                                          *
- *           Copyright (C) 2001-2009, Free Software Foundation, Inc.        *
+ *           Copyright (C) 2001-2011, Free Software Foundation, Inc.        *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -29,6 +29,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* This function will return the Ada name from the encoded form.
    The Ada coding is done in exp_dbug.ads and this is the inverse function.
    see exp_dbug.ads for full encoding rules, a short description is added
@@ -51,3 +55,7 @@ extern void get_encoding (const char *,
    function used in the binutils and GDB. Always consider using __gnat_decode
    instead of ada_demangle. Caller must free the pointer returned.  */
 extern char *ada_demangle (const char *);
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/targext.c
===================================================================
--- ada/targext.c	(revision 176072)
+++ ada/targext.c	(working copy)
@@ -29,9 +29,13 @@
  *                                                                          *
  ****************************************************************************/
 
-/*  This file contains target-specific parameters describing the file       */
-/*  extension for object and executable files. It is used by the compiler,  */
-/*  binder and tools.                                                       */
+/*  This file contains target-specific parameters describing the file
+    extension for object and executable files.  It is used by the compiler,
+    binder and tools.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #ifdef IN_RTS
 #include "tconfig.h"
@@ -54,3 +58,7 @@
 const char *__gnat_target_object_extension = TARGET_OBJECT_SUFFIX;
 const char *__gnat_target_executable_extension = TARGET_EXECUTABLE_SUFFIX;
 const char *__gnat_target_debuggable_extension = TARGET_EXECUTABLE_SUFFIX;
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/env.c
===================================================================
--- ada/env.c	(revision 176072)
+++ ada/env.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *            Copyright (C) 2005-2010, Free Software Foundation, Inc.       *
+ *            Copyright (C) 2005-2011, Free Software Foundation, Inc.       *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -37,6 +37,10 @@
 #define _BSD
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -323,3 +327,7 @@ void __gnat_clearenv (void) {
   clearenv ();
 #endif
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/final.c
===================================================================
--- ada/final.c	(revision 176072)
+++ ada/final.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *          Copyright (C) 1992-2009 Free Software Foundation, Inc.          *
+ *          Copyright (C) 1992-2011, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -29,14 +29,22 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern void __gnat_finalize (void);
 
 /* This routine is called at the extreme end of execution of an Ada program
    (the call is generated by the binder). The standard routine does nothing
    at all, the intention is that this be replaced by system specific code
-   where finalization is required. */
+   where finalization is required.  */
 
 void
 __gnat_finalize (void)
 {
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/init.c
===================================================================
--- ada/init.c	(revision 176072)
+++ ada/init.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *          Copyright (C) 1992-2010, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2011, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -38,6 +38,10 @@
     installed by this file are used to catch the resulting signals that come
     from these probes failing (i.e. touching protected pages).  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* This file should be kept synchronized with 2sinit.ads, 2sinit.adb,
    s-init-ae653-cert.adb and s-init-xi-sparc.adb.  All these files implement
    the required functionality for different targets.  */
@@ -2403,3 +2407,7 @@ __gnat_adjust_context_for_raise (int sig
 }
 
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/xsnamest.adb
===================================================================
--- ada/xsnamest.adb	(revision 176072)
+++ ada/xsnamest.adb	(working copy)
@@ -194,6 +194,10 @@ begin
    Create (OutB, Out_File, "snames.nb");
    Create (OutH, Out_File, "snames.nh");
 
+   Put_Line (OutH, "#ifdef __cplusplus");
+   Put_Line (OutH, "extern ""C"" {");
+   Put_Line (OutH, "#endif");
+
    Anchored_Mode := True;
    Val := 0;
 
@@ -274,4 +278,8 @@ begin
       Line := Get_Line (InH);
       Put_Line (OutH, Line);
    end loop;
+
+   Put_Line (OutH, "#ifdef __cplusplus");
+   Put_Line (OutH, "}");
+   Put_Line (OutH, "#endif");
 end XSnamesT;
Index: ada/xsinfo.adb
===================================================================
--- ada/xsinfo.adb	(revision 176072)
+++ ada/xsinfo.adb	(working copy)
@@ -162,6 +162,11 @@ begin
    end loop;
 
    Put_Line (Ofile, "");
+
+   Put_Line (Ofile, "#ifdef __cplusplus");
+   Put_Line (Ofile, "extern ""C"" {");
+   Put_Line (Ofile, "#endif");
+
    NKV := 0;
 
    --  Loop through node kind codes
@@ -248,6 +253,9 @@ exception
    when Done =>
       Close (InS);
       Put_Line (Ofile, "");
+      Put_Line (Ofile, "#ifdef __cplusplus");
+      Put_Line (Ofile, "}");
+      Put_Line (Ofile, "#endif");
       Close (Ofile);
       Set_Exit_Status (0);
 
Index: ada/nlists.h
===================================================================
--- ada/nlists.h	(revision 176072)
+++ ada/nlists.h	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                              C Header File                               *
  *                                                                          *
- *            Copyright (C) 1992-2008, Free Software Foundation, Inc.       *
+ *            Copyright (C) 1992-2011, Free Software Foundation, Inc.       *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -29,7 +29,11 @@
    nlists.adb and must be kept synchronized with changes in these files.
 
    Note that only routines for reading the tree are included, since the
-   tree transformer is not supposed to modify the tree in any way. */
+   tree transformer is not supposed to modify the tree in any way.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /*  The following is the structure used for the list headers table */
 
@@ -128,3 +132,7 @@ List_Containing (Node_Id Node)
 {
   return Nodes_Ptr[Node - First_Node_Id].V.NX.link;
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/initialize.c
===================================================================
--- ada/initialize.c	(revision 176072)
+++ ada/initialize.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *          Copyright (C) 1992-2009, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2011, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -32,10 +32,14 @@
 /*  This unit provides default implementation for __gnat_initialize ()
     which is called before the elaboration of the partition. It is provided
     in a separate file/object so that users can replace it easily.
-    The default implementation should be null on most targets. */
+    The default implementation should be null on most targets.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* The following include is here to meet the published VxWorks requirement
-   that the __vxworks header appear before any other include. */
+   that the __vxworks header appear before any other include.  */
 #ifdef __vxworks
 #include "vxWorks.h"
 #endif
@@ -359,3 +363,7 @@ __gnat_initialize (void *eh ATTRIBUTE_UN
 }
 
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/repinfo.h
===================================================================
--- ada/repinfo.h	(revision 176072)
+++ ada/repinfo.h	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                              C Header File                               *
  *                                                                          *
- *          Copyright (C) 1999-2009 Free Software Foundation, Inc.          *
+ *          Copyright (C) 1999-2011, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -31,6 +31,10 @@
 
 /* This file corresponds to the Ada file repinfo.ads.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef Uint Node_Ref;
 typedef Uint Node_Ref_Or_Val;
 typedef char TCode;
@@ -75,3 +79,7 @@ typedef char TCode;
 #define Create_Node repinfo__create_node
 extern Node_Ref Create_Node	(TCode, Node_Ref_Or_Val,
 				 Node_Ref_Or_Val, Node_Ref_Or_Val);
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/fe.h
===================================================================
--- ada/fe.h	(revision 176072)
+++ ada/fe.h	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                              C Header File                               *
  *                                                                          *
- *          Copyright (C) 1992-2010, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2011, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -32,6 +32,10 @@
 /* This file contains definitions to access front-end functions and
    variables used by gigi.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* comperr:  */
 
 #define Compiler_Abort comperr__compiler_abort
@@ -251,3 +255,7 @@ extern void Set_Has_No_Elaboration_Code
 extern Boolean Backend_Overflow_Checks_On_Target;
 extern Boolean Stack_Check_Probes_On_Target;
 extern Boolean Stack_Check_Limits_On_Target;
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/raise.c
===================================================================
--- ada/raise.c	(revision 176072)
+++ ada/raise.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *             Copyright (C) 1992-2009, Free Software Foundation, Inc.      *
+ *             Copyright (C) 1992-2011, Free Software Foundation, Inc.      *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -32,6 +32,10 @@
 /* Shared routines to support exception handling.  __gnat_unhandled_terminate
    is shared between all exception handling mechanisms.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -79,3 +83,7 @@ __gnat_unhandled_terminate (void)
   /* Default termination handling */
   __gnat_os_exit (1);
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/raise.h
===================================================================
--- ada/raise.h	(revision 176072)
+++ ada/raise.h	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                              C Header File                               *
  *                                                                          *
- *          Copyright (C) 1992-2009, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2011, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -29,6 +29,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* C counterparts of what System.Standard_Library defines.  */
 
 typedef unsigned Exception_Code;
@@ -60,3 +64,7 @@ extern void __gnat_install_SEH_handler
 extern void __gnat_adjust_context_for_raise (int, void *);
 
 extern int gnat_exit_status;
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/xeinfo.adb
===================================================================
--- ada/xeinfo.adb	(revision 176072)
+++ ada/xeinfo.adb	(working copy)
@@ -276,6 +276,10 @@ begin
 
    Put_Line (Ofile, "");
 
+   Put_Line (Ofile, "#ifdef __cplusplus");
+   Put_Line (Ofile, "extern ""C"" {");
+   Put_Line (Ofile, "#endif");
+
    --  Find and record pragma Inlines
 
    loop
@@ -492,6 +496,11 @@ begin
    end loop;
 
    Put_Line (Ofile, "");
+
+   Put_Line (Ofile, "#ifdef __cplusplus");
+   Put_Line (Ofile, "}");
+   Put_Line (Ofile, "#endif");
+
    Put_Line
      (Ofile,
       "/* End of einfo.h (C version of Einfo package specification) */");
Index: ada/exit.c
===================================================================
--- ada/exit.c	(revision 176072)
+++ ada/exit.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *          Copyright (C) 1992-2009 Free Software Foundation, Inc.          *
+ *          Copyright (C) 1992-2011, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -29,6 +29,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __alpha_vxworks
 #include "vxWorks.h"
 #endif
@@ -44,7 +48,7 @@
 
 #include "adaint.h"
 
-/* Routine used by Ada.Command_Line.Set_Exit_Status */
+/* Routine used by Ada.Command_Line.Set_Exit_Status.  */
 
 int gnat_exit_status = 0;
 
@@ -53,3 +57,7 @@ __gnat_set_exit_status (int i)
 {
   gnat_exit_status = i;
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/adaint.c
===================================================================
--- ada/adaint.c	(revision 176072)
+++ ada/adaint.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *          Copyright (C) 1992-2010, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2011, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -34,6 +34,10 @@
    package Osint.  Many of the subprograms in OS_Lib import standard
    library calls directly. This file contains all other routines.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __vxworks
 
 /* No need to redefine exit here.  */
@@ -291,9 +295,9 @@ const char *__gnat_library_template = GN
 /* This variable is used in hostparm.ads to say whether the host is a VMS
    system.  */
 #ifdef VMS
-const int __gnat_vmsp = 1;
+int __gnat_vmsp = 1;
 #else
-const int __gnat_vmsp = 0;
+int __gnat_vmsp = 0;
 #endif
 
 #if defined (VMS)
@@ -324,7 +328,7 @@ const int __gnat_vmsp = 0;
 #endif
 
 /* Used for Ada bindings */
-const int __gnat_size_of_file_attributes = sizeof (struct file_attributes);
+int __gnat_size_of_file_attributes = sizeof (struct file_attributes);
 
 /* Reset the file attributes as if no system call had been performed */
 void __gnat_stat_to_attr (int fd, char* name, struct file_attributes* attr);
@@ -3686,3 +3690,7 @@ void *__gnat_lwp_self (void)
    return (void *) syscall (__NR_gettid);
 }
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/adaint.h
===================================================================
--- ada/adaint.h	(revision 176072)
+++ ada/adaint.h	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                              C Header File                               *
  *                                                                          *
- *          Copyright (C) 1992-2010, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2011, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -29,6 +29,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <sys/stat.h>
 #include <stdio.h>
 
@@ -262,3 +266,7 @@ extern int    get_gcc_version
 
 extern int    __gnat_binder_supports_auto_init     (void);
 extern int    __gnat_sals_init_using_constructors  (void);
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/cio.c
===================================================================
--- ada/cio.c	(revision 176072)
+++ ada/cio.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *          Copyright (C) 1992-2009, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2011, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -29,6 +29,10 @@
  *                                                                          *
  ****************************************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -129,3 +133,7 @@ mktemp (char *template)
   return tmpnam (NULL);
 }
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/cstreams.c
===================================================================
--- ada/cstreams.c	(revision 176072)
+++ ada/cstreams.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *              Auxiliary C functions for Interfaces.C.Streams              *
  *                                                                          *
- *          Copyright (C) 1992-2010, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2011, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -29,7 +29,11 @@
  *                                                                          *
  ****************************************************************************/
 
-/* Routines required for implementing routines in Interfaces.C.Streams */
+/* Routines required for implementing routines in Interfaces.C.Streams.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #ifdef __vxworks
 #include "vxWorks.h"
@@ -242,3 +246,7 @@ __gnat_full_name (char *nam, char *buffe
 
   return buffer;
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/uintp.h
===================================================================
--- ada/uintp.h	(revision 176072)
+++ ada/uintp.h	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                              C Header File                               *
  *                                                                          *
- *            Copyright (C) 1992-2010, Free Software Foundation, Inc.       *
+ *            Copyright (C) 1992-2011, Free Software Foundation, Inc.       *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -23,8 +23,12 @@
  *                                                                          *
  ****************************************************************************/
 
-/* This file corresponds to the Ada package specification Uintp. It was
-   created manually from the files uintp.ads and uintp.adb  */
+/* This file corresponds to the Ada package specification Uintp.  It was
+   created manually from the files uintp.ads and uintp.adb.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* Support for universal integer arithmetic */
 
@@ -94,3 +98,7 @@ extern struct Uint_Entry *uintp__uints__
 
 #define Udigits_Ptr uintp__udigits__table
 extern int *uintp__udigits__table;
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/tracebak.c
===================================================================
--- ada/tracebak.c	(revision 176072)
+++ ada/tracebak.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *                     Copyright (C) 2000-2010, AdaCore                     *
+ *            Copyright (C) 2000-2011, Free Software Foundation, Inc.       *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -46,6 +46,10 @@
    Alpha/VMS
 */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __alpha_vxworks
 #include "vxWorks.h"
 #endif
@@ -513,3 +517,7 @@ __gnat_backtrace (void **array ATTRIBUTE
 #endif
 
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/urealp.h
===================================================================
--- ada/urealp.h	(revision 176072)
+++ ada/urealp.h	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                              C Header File                               *
  *                                                                          *
- *            Copyright (C) 1992-2007, Free Software Foundation, Inc.       *
+ *            Copyright (C) 1992-2011, Free Software Foundation, Inc.       *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -23,8 +23,12 @@
  *                                                                          *
  ****************************************************************************/
 
-/* This file corresponds to the Ada package specification Urealp. It was
-   created manually from the files urealp.ads and urealp.adb  */
+/* This file corresponds to the Ada package specification Urealp.  It was
+   created manually from the files urealp.ads and urealp.adb.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* Support for universal real arithmetic.  */
 
@@ -48,3 +52,7 @@ enum Rounding_Mode {Floor = 0, Ceiling =
 #define Machine eval_fat__machine
 extern Ureal Machine		(Entity_Id, Ureal, enum Rounding_Mode,
 				 Node_Id);
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/namet.h
===================================================================
--- ada/namet.h	(revision 176072)
+++ ada/namet.h	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                              C Header File                               *
  *                                                                          *
- *            Copyright (C) 1992-2008, Free Software Foundation, Inc.       *
+ *            Copyright (C) 1992-2011, Free Software Foundation, Inc.       *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -24,7 +24,11 @@
  ****************************************************************************/
 
 /* This is the C file that corresponds to the Ada package specification
-   Namet. It was created manually from files namet.ads and namet.adb.  */
+   Namet.  It was created manually from files namet.ads and namet.adb.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* Structure defining a names table entry.  */
 
@@ -127,3 +131,7 @@ extern Source_File_Index Get_Source_File
 extern Logical_Line_Number Get_Logical_Line_Number (Source_Ptr);
 extern Column_Number Get_Column_Number (Source_Ptr);
 extern Source_Ptr Instantiation (Source_File_Index);
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/gcc-interface/gadaint.h
===================================================================
--- ada/gcc-interface/gadaint.h	(revision 176072)
+++ ada/gcc-interface/gadaint.h	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                              C Header File                               *
  *                                                                          *
- *             Copyright (C) 2010, Free Software Foundation, Inc.           *
+ *           Copyright (C) 2010-2011, Free Software Foundation, Inc.        *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -30,6 +30,14 @@
 #ifndef GCC_ADAINT_H
 #define GCC_ADAINT_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern char *__gnat_to_canonical_file_spec (char *);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* GCC_ADAINT_H */
Index: ada/gcc-interface/Make-lang.in
===================================================================
--- ada/gcc-interface/Make-lang.in	(revision 176072)
+++ ada/gcc-interface/Make-lang.in	(working copy)
@@ -104,19 +104,19 @@ ADA_TOOLS_FLAGS_TO_PASS=\
 	"GNATLINK=../../gnatlink"	\
 	"GNATBIND=../../gnatbind"
 
-GCC_LINK=$(CC) -static-libgcc $(LDFLAGS)
+GCC_LINK=$(LINKER) $(ALL_LINKERFLAGS) -static-libgcc $(LDFLAGS)
 
 # Lists of files for various purposes.
 
 # Languages-specific object files for Ada.
+
 # Object files for gnat1 from C sources.
-GNAT1_C_OBJS = ada/b_gnat1.o ada/adadecode.o ada/adaint.o ada/cstreams.o \
- ada/cio.o ada/targtyps.o ada/decl.o ada/misc.o ada/utils.o ada/utils2.o \
- ada/trans.o ada/cuintp.o ada/argv.o ada/raise.o ada/init.o ada/tracebak.o \
- ada/initialize.o ada/env.o
+GNAT1_C_OBJS = ada/adadecode.o ada/adaint.o ada/argv.o ada/cio.o \
+ ada/cstreams.o ada/env.o ada/init.o ada/initialize.o ada/raise.o \
+ ada/seh_init.o ada/targext.o ada/tracebak.o ada/cuintp.o ada/decl.o \
+ ada/misc.o ada/utils.o ada/utils2.o ada/trans.o ada/targtyps.o
 
 # Object files from Ada sources that are used by gnat1
-
 GNAT_ADA_OBJS =	\
  ada/a-charac.o	\
  ada/a-chlat1.o	\
@@ -270,7 +270,6 @@ GNAT_ADA_OBJS =	\
  ada/scng.o	\
  ada/scos.o	\
  ada/sdefault.o	\
- ada/seh_init.o	\
  ada/sem.o	\
  ada/sem_aggr.o	\
  ada/sem_attr.o	\
@@ -320,7 +319,6 @@ GNAT_ADA_OBJS =	\
  ada/switch.o	\
  ada/system.o	\
  ada/table.o	\
- ada/targext.o	\
  ada/targparm.o	\
  ada/tbuild.o	\
  ada/tree_gen.o	\
@@ -338,24 +336,24 @@ GNAT_ADA_OBJS =	\
  ada/widechar.o
 
 # Object files for gnat executables
-GNAT1_ADA_OBJS = $(GNAT_ADA_OBJS) ada/back_end.o ada/gnat1drv.o
+GNAT1_ADA_OBJS = $(GNAT_ADA_OBJS) ada/back_end.o ada/gnat1drv.o ada/b_gnat1.o
 
 GNAT1_OBJS = $(GNAT1_C_OBJS) $(GNAT1_ADA_OBJS)
 
 GNATBIND_OBJS = \
  ada/adaint.o     \
  ada/argv.o       \
- ada/exit.o       \
  ada/cio.o        \
  ada/cstreams.o   \
  ada/env.o        \
+ ada/exit.o       \
  ada/final.o      \
  ada/init.o       \
  ada/initialize.o \
- ada/seh_init.o   \
  ada/link.o       \
- ada/targext.o    \
  ada/raise.o      \
+ ada/seh_init.o   \
+ ada/targext.o    \
  ada/tracebak.o   \
  ada/ada.o        \
  ada/a-clrefi.o   \
Index: ada/gcc-interface/gigi.h
===================================================================
--- ada/gcc-interface/gigi.h	(revision 176072)
+++ ada/gcc-interface/gigi.h	(working copy)
@@ -199,6 +199,10 @@ struct File_Info_Type
   Nat Num_Source_Lines;
 };
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* This is the main program of the back-end.  It sets up all the table
    structures and then generates code.  */
 extern void gigi (Node_Id gnat_root, int max_gnat_node,
@@ -218,6 +222,10 @@ extern void gigi (Node_Id gnat_root, int
                   Entity_Id standard_exception_type,
                   Int gigi_operating_mode);
 
+#ifdef __cplusplus
+}
+#endif
+
 /* GNAT_NODE is the root of some GNAT tree.  Return the root of the
    GCC tree corresponding to that GNAT tree.  Normally, no code is generated;
    we just return an equivalent tree which is used elsewhere to generate
@@ -929,6 +937,11 @@ extern int fp_size_to_prec (int size);
 /* These functions return the basic data type sizes and related parameters
    about the target machine.  */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern Pos get_target_bits_per_unit (void);
 extern Pos get_target_bits_per_word (void);
 extern Pos get_target_char_size (void);
@@ -953,6 +966,10 @@ extern Nat get_target_strict_alignment (
 extern Nat get_target_double_float_alignment (void);
 extern Nat get_target_double_scalar_alignment (void);
 
+#ifdef __cplusplus
+}
+#endif
+
 /* Let code know whether we are targetting VMS without need of
    intrusive preprocessor directives.  */
 #ifndef TARGET_ABI_OPEN_VMS
Index: ada/gcc-interface/misc.c
===================================================================
--- ada/gcc-interface/misc.c	(revision 176072)
+++ ada/gcc-interface/misc.c	(working copy)
@@ -68,12 +68,20 @@ const char **save_argv;
 extern int gnat_argc;
 extern char **gnat_argv;
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Declare functions we use as part of startup.  */
 extern void __gnat_initialize (void *);
 extern void __gnat_install_SEH_handler (void *);
 extern void adainit (void);
 extern void _ada_gnat1drv (void);
 
+#ifdef __cplusplus
+}
+#endif
+
 /* The parser for the language.  For us, we process the GNAT tree.  */
 
 static void
Index: ada/argv.c
===================================================================
--- ada/argv.c	(revision 176072)
+++ ada/argv.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *         Copyright (C) 1992-2009, Free Software Foundation, Inc.          *
+ *         Copyright (C) 1992-2011, Free Software Foundation, Inc.          *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -30,17 +30,21 @@
  ****************************************************************************/
 
 /* Routines for accessing command line arguments from both the runtime
-   library and from the compiler itself. In the former case, gnat_argc
+   library and from the compiler itself.  In the former case, gnat_argc
    and gnat_argv are the original argc and argv values as stored by the
    binder generated main program, and these routines are accessed from
-   the Ada.Command_Line package. In the compiler case, gnat_argc and
+   the Ada.Command_Line package.  In the compiler case, gnat_argc and
    gnat_argv are the values as modified by toplev, and these routines
-   are accessed from the Osint package. */
+   are accessed from the Osint package.  */
 
 /* Also routines for accessing the environment from the runtime library.
    Gnat_envp is the original envp value as stored by the binder generated
    main program, and these routines are accessed from the
-   Ada.Command_Line.Environment package. */
+   Ada.Command_Line.Environment package.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #ifdef IN_RTS
 #include "tconfig.h"
@@ -116,3 +120,7 @@ __gnat_fill_env (char *a, int i)
   if (gnat_envp != NULL)
     strncpy (a, gnat_envp[i], strlen (gnat_envp[i]));
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/atree.h
===================================================================
--- ada/atree.h	(revision 176072)
+++ ada/atree.h	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                              C Header File                               *
  *                                                                          *
- *          Copyright (C) 1992-2010, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2011, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -29,7 +29,11 @@
    atree.adb and must be kept synchronized with changes in these files.
 
    Note that only routines for reading the tree are included, since the tree
-   transformer is not supposed to modify the tree in any way. */
+   transformer is not supposed to modify the tree in any way.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* Structure used for the first part of the node in the case where we have
    an Nkind.  */
@@ -734,3 +738,6 @@ extern Node_Id Current_Error_Node;
 #define Flag253(N)     (Nodes_Ptr[(N) - First_Node_Id + 4].U.NK.flag71)
 #define Flag254(N)     (Nodes_Ptr[(N) - First_Node_Id + 4].U.NK.flag72)
 
+#ifdef __cplusplus
+}
+#endif
Index: ada/seh_init.c
===================================================================
--- ada/seh_init.c	(revision 176072)
+++ ada/seh_init.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *           Copyright (C) 2005-2009, Free Software Foundation, Inc.        *
+ *           Copyright (C) 2005-2011, Free Software Foundation, Inc.        *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -32,6 +32,10 @@
 /*  This unit contains support for SEH (Structured Exception Handling).
     Right now the only implementation is for Win32.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_RTS
 #include "tconfig.h"
 #include "tsystem.h"
@@ -311,3 +315,7 @@ void __gnat_install_SEH_handler (void *e
 {
 }
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/adadecode.c
===================================================================
--- ada/adadecode.c	(revision 176072)
+++ ada/adadecode.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *           Copyright (C) 2001-2009, Free Software Foundation, Inc.        *
+ *           Copyright (C) 2001-2011, Free Software Foundation, Inc.        *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -352,6 +352,10 @@ __gnat_decode (const char *coded_name, c
     }
 }
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef IN_GCC
 char *
 ada_demangle (const char *coded_name)
@@ -402,3 +406,7 @@ get_encoding (const char *coded_name, ch
 
   *dest_index = '\0';
 }
+
+#ifdef __cplusplus
+}
+#endif
Index: ada/link.c
===================================================================
--- ada/link.c	(revision 176072)
+++ ada/link.c	(working copy)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *          Copyright (C) 1992-2009, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2011, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -29,9 +29,12 @@
  *                                                                          *
  ****************************************************************************/
 
-/*  This file contains host-specific parameters describing the behavior     */
-/*  of the linker. It is used by gnatlink as well as all tools that use     */
-/*  Mlib.                                                                   */
+/*  This file contains host-specific parameters describing the behavior of the
+    linker.  It is used by gnatlink as well as all tools that use Mlib.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #include <string.h>
 
@@ -254,3 +257,7 @@ const char *__gnat_object_library_extens
 unsigned char __gnat_separate_run_path_options = 0;
 const char *__gnat_default_libgcc_subdir = "lib";
 #endif
+
+#ifdef __cplusplus
+}
+#endif
Index: prefix.h
===================================================================
--- prefix.h	(revision 176072)
+++ prefix.h	(working copy)
@@ -21,10 +21,20 @@ License along with GCC; see the file COP
 #ifndef GCC_PREFIX_H
 #define GCC_PREFIX_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* These functions are called by the Ada frontend with C convention.  */
+
 /* Update PATH using KEY if PATH starts with PREFIX.  The returned
    string is always malloc-ed, and the caller is responsible for
    freeing it.  */
 extern char *update_path (const char *path, const char *key);
 extern void set_std_prefix (const char *, int);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* ! GCC_PREFIX_H */

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Ada] Fix --enable-build-with-cxx build
  2011-07-12 10:24 ` Eric Botcazou
@ 2011-07-12 10:36   ` Arnaud Charlet
  2011-07-12 17:34     ` Eric Botcazou
  2011-07-21 14:34   ` Eric Botcazou
  1 sibling, 1 reply; 6+ messages in thread
From: Arnaud Charlet @ 2011-07-12 10:36 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches, Laurent GUERBY

> Revised version, only 33 files modified now (instead of 51).  We compile the C
> files for the compiler proper (and gnatbind) with the C++ compiler, but we
> keep compiling them with the C compiler in the other cases (library & tools).
> I think that this is in keeping with the other compilers (e.g. libgcc is still
> compiled with the C compiler).
> 
> Bootstrapped/regtested on x86_64-suse-linux with
> --enable-build-with-cxx.
> 
> Arno, do you have any objections to me applying this?

Certainly looks better to me.

Arno

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Ada] Fix --enable-build-with-cxx build
  2011-07-12 10:36   ` Arnaud Charlet
@ 2011-07-12 17:34     ` Eric Botcazou
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Botcazou @ 2011-07-12 17:34 UTC (permalink / raw)
  To: Arnaud Charlet; +Cc: gcc-patches, Laurent GUERBY

> Certainly looks better to me.

Thanks, applied.  In any case, it's only a quantitative issue: since gigi will 
very likely use C++ features at some point, it needs to be compiled with the 
C++ compiler, which means that all the FE headers must be extern "C".  So half 
of the 33 files must be modified and I think that it's simpler to modify them 
all and use a single compilation scheme than maintaining two such schemes.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Ada] Fix --enable-build-with-cxx build
  2011-07-12 10:24 ` Eric Botcazou
  2011-07-12 10:36   ` Arnaud Charlet
@ 2011-07-21 14:34   ` Eric Botcazou
  1 sibling, 0 replies; 6+ messages in thread
From: Eric Botcazou @ 2011-07-21 14:34 UTC (permalink / raw)
  To: gcc-patches; +Cc: Laurent GUERBY, Arnaud Charlet

[-- Attachment #1: Type: text/plain, Size: 601 bytes --]

> Revised version, only 33 files modified now (instead of 51).  We compile
> the C files for the compiler proper (and gnatbind) with the C++ compiler,
> but we keep compiling them with the C compiler in the other cases (library
> & tools). I think that this is in keeping with the other compilers (e.g.
> libgcc is still compiled with the C compiler).

This introduced a circular dependency in the Makefile.  Fixed thusly.


2011-07-21  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/Make-lang.in (GNAT1_ADA_OBJS): Move ada/b_gnat1.o to...
        (GNAT1_OBJS): ...here.


-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-diff, Size: 589 bytes --]

Index: gcc-interface/Make-lang.in
===================================================================
--- gcc-interface/Make-lang.in	(revision 176495)
+++ gcc-interface/Make-lang.in	(working copy)
@@ -336,9 +336,9 @@ GNAT_ADA_OBJS =	\
  ada/widechar.o
 
 # Object files for gnat executables
-GNAT1_ADA_OBJS = $(GNAT_ADA_OBJS) ada/back_end.o ada/gnat1drv.o ada/b_gnat1.o
+GNAT1_ADA_OBJS = $(GNAT_ADA_OBJS) ada/back_end.o ada/gnat1drv.o
 
-GNAT1_OBJS = $(GNAT1_C_OBJS) $(GNAT1_ADA_OBJS)
+GNAT1_OBJS = $(GNAT1_C_OBJS) $(GNAT1_ADA_OBJS) ada/b_gnat1.o
 
 GNATBIND_OBJS = \
  ada/adaint.o     \

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-21 13:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-11 20:16 [Ada] Fix --enable-build-with-cxx build Eric Botcazou
2011-07-12  9:12 ` Rainer Orth
2011-07-12 10:24 ` Eric Botcazou
2011-07-12 10:36   ` Arnaud Charlet
2011-07-12 17:34     ` Eric Botcazou
2011-07-21 14:34   ` Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).