[PATCH][Ada] Switch gnatbind from C to Ada generation during bootstrap

Laurent GUERBY laurent@guerby.net
Sat Jun 27 13:13:00 GMT 2009


Hi,

As discussed for gcc-in-cxx branch to support Ada one potential issue is
the compilation of the binder generated C file. A solution is to switch
the binder to generate Ada, that's what the patch below implements.

1/ Since we don't want the binder files to be compiled with -gnatg
(because they don't compile with it, eg they don't follow formatting
rules enforced by -gnatg) I had to add a specific
rule to compile them.

2/ The generated pragma Source_File_Name does not compile if we generate
in a subdirectory using -o as does Make-lang.in (it complains about a
"/" in the file name), so I added "$(MV) -f" as fixup (no "cd" since
ADA_INCLUDES would be wrong then).

Now I don't know if there are potential issues in using gnatbind -A
in some context.

Note: adding #ifdef to C output is not completely trivial, in some
cases the binder will output "extern void exit (int);" which
will generate conflicts with system include when the output is compiled
with a C++ compiler.

This patch has been tested with 4.1.2 as base compiler (older
I currently have access too) on x86_64-linux on both trunk
and gcc-in-cxx branch.

Ok to commit to trunk?

Laurent

2009-06-27  Laurent GUERBY  <laurent@guerby.net>

	* gcc-interface/Make-lang.in: Switch gnatbind from C to Ada
	generation.
	* gcc-interface/Makefile.in: Likewise.


Index: gcc/ada/gcc-interface/Makefile.in
===================================================================
--- gcc/ada/gcc-interface/Makefile.in	(revision 148985)
+++ gcc/ada/gcc-interface/Makefile.in	(working copy)
@@ -2549,13 +2549,15 @@
 # because all that file does, when not compiling with GCC,
 # is include the system varargs.h.
 
-b_gnatl.c : $(GNATLINK_OBJS)
-	$(GNATBIND) -C $(ADA_INCLUDES) -o b_gnatl.c gnatlink.ali
-b_gnatl.o : b_gnatl.c
+b_gnatl.adb : $(GNATLINK_OBJS)
+	$(GNATBIND) -A $(ADA_INCLUDES) -o b_gnatl.adb gnatlink.ali
+b_gnatl.o : b_gnatl.adb
+	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION)
 
-b_gnatm.c : $(GNATMAKE_OBJS)
-	$(GNATBIND) -C $(ADA_INCLUDES) -o b_gnatm.c gnatmake.ali
-b_gnatm.o : b_gnatm.c
+b_gnatm.adb : $(GNATMAKE_OBJS)
+	$(GNATBIND) -A $(ADA_INCLUDES) -o b_gnatm.adb gnatmake.ali
+b_gnatm.o : b_gnatm.adb
+	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION)
 
 ADA_INCLUDE_DIR = $(libsubdir)/adainclude
 ADA_RTL_OBJ_DIR = $(libsubdir)/adalib
Index: gcc/ada/gcc-interface/Make-lang.in
===================================================================
--- gcc/ada/gcc-interface/Make-lang.in	(revision 148985)
+++ gcc/ada/gcc-interface/Make-lang.in	(working copy)
@@ -928,13 +928,19 @@
 ada_extra_files : ada/treeprs.ads ada/einfo.h ada/sinfo.h ada/nmake.adb \
 	ada/nmake.ads ada/snames.ads ada/snames.adb ada/snames.h
 
-ada/b_gnat1.c : $(GNAT1_ADA_OBJS)
-	$(GNATBIND) -C $(ADA_INCLUDES) -o ada/b_gnat1.c -n ada/gnat1drv.ali
-ada/b_gnat1.o : ada/b_gnat1.c
+ada/b_gnat1.adb : $(GNAT1_ADA_OBJS)
+	$(GNATBIND) -A $(ADA_INCLUDES) -o b_gnat1.adb -n ada/gnat1drv.ali
+	$(MV) -f b_gnat1.adb ada/
+	$(MV) -f b_gnat1.ads ada/
+ada/b_gnat1.o : ada/b_gnat1.adb
+	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION)
 
-ada/b_gnatb.c : $(GNATBIND_OBJS) ada/gnatbind.o ada/interfac.o
-	$(GNATBIND) -C $(ADA_INCLUDES) -o ada/b_gnatb.c ada/gnatbind.ali
-ada/b_gnatb.o : ada/b_gnatb.c
+ada/b_gnatb.adb : $(GNATBIND_OBJS) ada/gnatbind.o ada/interfac.o
+	$(GNATBIND) -A $(ADA_INCLUDES) -o b_gnatb.adb ada/gnatbind.ali
+	$(MV) -f b_gnatb.adb ada/
+	$(MV) -f b_gnatb.ads ada/
+ada/b_gnatb.o : ada/b_gnatb.adb
+	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION)
 
 # We delete the files before copying, below, in case they are read-only.
 ada/treeprs.ads : ada/treeprs.adt ada/sinfo.ads ada/xtreeprs.adb





More information about the Gcc-patches mailing list