diff mbox

[Ada/build] deal with some cross/native cross issues

Message ID 66B73BAF-77A5-46B4-9D81-9043E7F17BAA@codesourcery.com
State New
Headers show

Commit Message

Iain Sandoe Nov. 3, 2013, 9:35 p.m. UTC
Hi,

I've been trying to improve the building and testing of Darwin for crosses and native crosses.

This has thrown up a few small glitches in the Ada build stuff (that would seem to apply to any build-host-nativeX scenario, not just darwin).  I would imagine it would be beneficial to resolve these, since Ada requires Ada - a native cross seems like the only realistic way onto a new target.

Having said that, I am not fully conversant with the build permutations you need to achieve - so the fixes proposed here might not be the best solutions;  comments and suggestions welcome.

===

1. xgnatugn needs to be run on the build system, so needs to be built with the build system's gnatmake. 
I haven't put a canonical prefix on this since this doesn't appear to be done elsewhere.  
Defined as GNATMAKE_FOR_BUILD and passed to sub-processes.

2. Some builds might need to pass LDFLAGS to the gnat* builds.  Appended LDFLAGS to GCC_LINK.  Passed on in gnattools/Make.

3. In gnattools, the RTS dir must be for the host and not for the build;  This actually only showed up when I tried a cross from a 64bit pointer machine to a 32bit pointer one (i.e it is easy for it to go unnoticed).  

With these changes I can build working crosses and native crosses at least on Darwin between machines of different pointer size and endianess.

OK for trunk?
Iain

gcc/ada:

	* gcc-interface/Make-lang.in (GNATMAKE_FOR_BUILD): New, pass
	to subordinate builds.
	(xgnatugn): Build with GNATMAKE_FOR_BUILD.
	* gcc-interface/Makefile.in (GCC_LINK): Append LDFLAGS.

gnattools:

	* Makefile.in (TOOLS_FLAGS_TO_PASS_RE): Pass LDFLAGS.
	(RTS_DIR): Use $(host)-gnatls when the host differs from build.
gcc/ada/gcc-interface/Make-lang.in | 10 ++++++++--
 gcc/ada/gcc-interface/Makefile.in  |  2 +-
 gnattools/Makefile.in              |  6 ++++++
 3 files changed, 15 insertions(+), 3 deletions(-)

Comments

Eric Botcazou Nov. 6, 2013, 12:57 p.m. UTC | #1
> I've been trying to improve the building and testing of Darwin for crosses
> and native crosses.
> 
> This has thrown up a few small glitches in the Ada build stuff (that would
> seem to apply to any build-host-nativeX scenario, not just darwin).  I
> would imagine it would be beneficial to resolve these, since Ada requires
> Ada - a native cross seems like the only realistic way onto a new target.

Thanks for working on this.

> 1. xgnatugn needs to be run on the build system, so needs to be built with
> the build system's gnatmake. I haven't put a canonical prefix on this since
> this doesn't appear to be done elsewhere. Defined as GNATMAKE_FOR_BUILD and
> passed to sub-processes.

Why do you need to pass it to ADA_TOOLS_FLAGS_TO_PASS though?  Just replace 
$(GNATMAKE) with gnatmake.

> 2. Some builds might need to pass LDFLAGS to the gnat* builds.  Appended
> LDFLAGS to GCC_LINK.  Passed on in gnattools/Make.

OK.

> 3. In gnattools, the RTS dir must be for the host and not for the build; 
> This actually only showed up when I tried a cross from a 64bit pointer
> machine to a 32bit pointer one (i.e it is easy for it to go unnoticed).

OK, but don't you need to do the same for gnatmake/gnatbind/gnatlink here?
See gcc-interface/Make-lang.in, line 171 and below, for similar code.
diff mbox

Patch

diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in
index cd3676f..dd5392f 100644
--- a/gcc/ada/gcc-interface/Make-lang.in
+++ b/gcc/ada/gcc-interface/Make-lang.in
@@ -53,6 +53,8 @@  CHECKING_ADAFLAGS= -gnata
 endif
 WARN_ADAFLAGS= -W -Wall
 
+GNATMAKE_FOR_BUILD=gnatmake
+
 # For native builds, the base compiler might be old and we need to arrange for
 # style warnings not to be flagged as errors during stage1.  Cross compilers
 # need to be built by a recent/matching native so we might as well leave the
@@ -147,7 +149,8 @@  ifeq ($(build), $(host))
         ADA_INCLUDES="-I- -I../rts" \
         GNATMAKE="../../gnatmake" \
         GNATLINK="../../gnatlink" \
-        GNATBIND="../../gnatbind"
+        GNATBIND="../../gnatbind" \
+        GNATMAKE_FOR_BUILD="$(GNATMAKE_FOR_BUILD)"
   else
     # This is a regular cross compiler. Use the native compiler to compile
     # the tools.
@@ -166,6 +169,7 @@  ifeq ($(build), $(host))
         GNATMAKE="gnatmake" \
         GNATBIND="gnatbind" \
         GNATLINK="gnatlink" \
+        GNATMAKE_FOR_BUILD="$(GNATMAKE_FOR_BUILD)" \
         LIBGNAT=""
   endif
 else
@@ -189,6 +193,7 @@  else
         GNATMAKE="$(GNATMAKE_FOR_HOST)"      \
         GNATBIND="$(GNATBIND_FOR_HOST)"      \
         GNATLINK="$(GNATLINK_FOR_HOST)"      \
+        GNATMAKE_FOR_BUILD="$(GNATMAKE_FOR_BUILD)" \
         LIBGNAT=""
   else
     # This is a canadian cross. We should use a toolchain running on the
@@ -204,6 +209,7 @@  else
         GNATMAKE="$(GNATMAKE_FOR_HOST)"      \
         GNATBIND="$(GNATBIND_FOR_HOST)"      \
         GNATLINK="$(GNATLINK_FOR_HOST)"      \
+        GNATMAKE_FOR_BUILD="$(GNATMAKE_FOR_BUILD)" \
         LIBGNAT=""
   endif
 endif
@@ -658,7 +664,7 @@  ada.tags: force
 ada/doctools/xgnatugn$(build_exeext): ada/xgnatugn.adb
 	-$(MKDIR) ada/doctools
 	$(CP) $^ ada/doctools
-	cd ada/doctools && $(GNATMAKE) -q xgnatugn
+	cd ada/doctools && $(GNATMAKE_FOR_BUILD) -q xgnatugn
 
 # Note that doc/gnat_ugn.texi and doc/projects.texi do not depend on
 # xgnatugn being built so we can distribute a pregenerated doc/gnat_ugn.info
diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in
index 91778c5..d1a4981 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -2415,7 +2415,7 @@  TOOLS_FLAGS_TO_PASS=		\
 	"GNATLINK=$(GNATLINK)"	\
 	"GNATBIND=$(GNATBIND)"
 
-GCC_LINK=$(CXX) $(GCC_LINK_FLAGS) $(ADA_INCLUDES)
+GCC_LINK=$(CXX) $(GCC_LINK_FLAGS) $(ADA_INCLUDES) $(LDFLAGS)
 
 # Build directory for the tools. Let's copy the target-dependent
 # sources using the same mechanism as for gnatlib. The other sources are
diff --git a/gnattools/Makefile.in b/gnattools/Makefile.in
index fdd6491..118847c 100644
--- a/gnattools/Makefile.in
+++ b/gnattools/Makefile.in
@@ -24,6 +24,7 @@  srcdir = @srcdir@
 libdir = @libdir@
 build = @build@
 target = @target@
+host = @host@
 prefix = @prefix@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -92,6 +93,7 @@  TOOLS_FLAGS_TO_PASS_RE= \
 	"CC=../../xgcc -B../../" \
 	"CXX=../../xg++ -B../../ $(CXX_LFLAGS)" \
 	"CFLAGS=$(CFLAGS)" \
+	"LDFLAGS=$(LDFLAGS)" \
 	"ADAFLAGS=$(ADAFLAGS)" \
 	"ADA_CFLAGS=$(ADA_CFLAGS)" \
 	"INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
@@ -192,7 +194,11 @@  regnattools: $(GCC_DIR)/stamp-gnatlib-rts
 # put the host RTS dir first in the PATH to hide the default runtime
 # files that are among the sources
 # FIXME: This should be done in configure.
+ifeq ($(host), $(build))
 RTS_DIR:=$(strip $(subst \,/,$(shell gnatls -v | grep adalib )))
+else
+RTS_DIR:=$(strip $(subst \,/,$(shell $(host)-gnatls -v | grep adalib )))
+endif
 gnattools-cross: $(GCC_DIR)/stamp-tools
 	# gnattools1-re
 	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \