diff mbox

Two build != host fixes

Message ID 3486884.DcvUWbD7kJ@polaris
State New
Headers show

Commit Message

Eric Botcazou Dec. 11, 2013, 2:41 p.m. UTC
> I have some more fixes for Ada cross-builds that Eric commented on but need
> a little more work - will try to re-test this evening and re-post tomorrow.

It's also PR ada/55946.  Would mind trying the attached patch?

Comments

Bernd Edlinger Dec. 12, 2013, 12:11 p.m. UTC | #1
>
>> I have some more fixes for Ada cross-builds that Eric commented on but need
>> a little more work - will try to re-test this evening and re-post tomorrow.
>
> It's also PR ada/55946. Would mind trying the attached patch?
>
> --
> Eric Botcazou

Hi Eric,


your patch looks quite nice, (maybe s/host_alias= @host_alias@/host_alias = @host_alias@/)
but I have to make a few more patches, to get it working:


error: "system.ads" has restriction No_Implicit_Dynamic_Code
error: but the following files violate this restriction:
error:   "make.adb"
error:   "makeutl.adb"
error:   "prj.adb"
error:   "prj-env.adb"
error:   "prj-conf.adb"
error:   "prj-proc.adb"
error:   "prj-nmsc.adb"


that's the most weird point. If I get rid of that pragma, and re-build everything I get something that looks
like a working gcc/gnat.

The problem with SSIZE_MAX is this: it is not defined in gcc/glimits.h, and in the host!=build cross-compiler
fix-includes replaces the working limits.h with that one, so my build fails.

Bernd.
Eric Botcazou Dec. 12, 2013, 12:27 p.m. UTC | #2
> your patch looks quite nice, (maybe s/host_alias= @host_alias@/host_alias =
> @host_alias@/)

Thanks for spotting it, now fixed.

> but I have to make a few more patches, to get it working:
> 
> 
> error: "system.ads" has restriction No_Implicit_Dynamic_Code
> error: but the following files violate this restriction:
> error:   "make.adb"
> error:   "makeutl.adb"
> error:   "prj.adb"
> error:   "prj-env.adb"
> error:   "prj-conf.adb"
> error:   "prj-proc.adb"
> error:   "prj-nmsc.adb"
> 
> 
> that's the most weird point. If I get rid of that pragma, and re-build
> everything I get something that looks like a working gcc/gnat.

Nice progress!  To be fair, the violation of No_Implicit_Dynamic_Code was also 
reported under PR ada/55946, but the fix isn't to remove the pragma, as this 
particular version of system.ads should be used only to build the compiler and 
not the tools.  This issue is supposed to be addressed by the RTS_DIR thing:

# Put the host RTS dir first in the PATH to hide the default runtime
# files that are among the sources
RTS_DIR:=$(strip $(subst \,/,$(shell $(GNATLS_FOR_HOST) -v | grep adalib )))

TOOLS_FLAGS_TO_PASS_CROSS= \
	"CC=$(CC)" \
	"CXX=$(CXX)" \
	"CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
	"LDFLAGS=$(LDFLAGS)" \
	"ADAFLAGS=$(ADAFLAGS)"	\
	"ADA_CFLAGS=$(ADA_CFLAGS)" \
	"INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
	"ADA_INCLUDES=-I$(RTS_DIR)../adainclude -I$(RTS_DIR)

Could you post the command line for the compilation of one of the problematic 
units for the gnattools?
Iain Sandoe Dec. 12, 2013, 12:27 p.m. UTC | #3
Hi Eric,

On 12 Dec 2013, at 12:11, Bernd Edlinger wrote:

>> 
>>> I have some more fixes for Ada cross-builds that Eric commented on but need
>>> a little more work - will try to re-test this evening and re-post tomorrow.
>> 
>> It's also PR ada/55946. Would mind trying the attached patch?
>> 
>> --
>> Eric Botcazou
> 
> Hi Eric,
> 
> 
> your patch looks quite nice, (maybe s/host_alias= @host_alias@/host_alias = @host_alias@/)
> but I have to make a few more patches, to get it working:
> 
> 
> error: "system.ads" has restriction No_Implicit_Dynamic_Code
> error: but the following files violate this restriction:
> error:   "make.adb"
> error:   "makeutl.adb"
> error:   "prj.adb"
> error:   "prj-env.adb"
> error:   "prj-conf.adb"
> error:   "prj-proc.adb"
> error:   "prj-nmsc.adb"


using your patch + the mod I made for LDFLAGS.

I built x86_64-darwin12 X powerpc-darwin9 [build = x86_64-darwin12]
and then a native X powerpc-darwin9  [build = x86_64-darwin12]

Ada built and I can do "gnatmake hello.adb" on the powerpc system and produce a working exe, 
gcc and g++ seem to produce similar test output from recent runs.

Do you have a way to run acats for an out-of-tree test?

Iain
Eric Botcazou Dec. 12, 2013, 12:34 p.m. UTC | #4
> using your patch + the mod I made for LDFLAGS.

In gcc-interface/Makefile.in?  I wasn't sure if it was really needed.

Out of curiosity, what do you set LDFLAGS to exactly?

> I built x86_64-darwin12 X powerpc-darwin9 [build = x86_64-darwin12]
> and then a native X powerpc-darwin9  [build = x86_64-darwin12]
> 
> Ada built and I can do "gnatmake hello.adb" on the powerpc system and
> produce a working exe, gcc and g++ seem to produce similar test output from
> recent runs.

That's nice.

> Do you have a way to run acats for an out-of-tree test?

Presumably not, but you could try to run gnat.dg instead.
Iain Sandoe Dec. 12, 2013, 12:44 p.m. UTC | #5
Hi Eric,

On 12 Dec 2013, at 12:34, Eric Botcazou wrote:

>> using your patch + the mod I made for LDFLAGS.
> 
> In gcc-interface/Makefile.in?  I wasn't sure if it was really needed.
> 
> Out of curiosity, what do you set LDFLAGS to exactly?

Darwin doesn't have gettext in libSystem, I build it as a convenience library, but it still needs to refer to a system framework. For this to link the gnattools I need:

LDFLAGS="-L/path/to/my/convenience/lib -framework CoreFoundation" 

I suppose that, one day, the make machinery should do something like
LDFLAGS = @LDFLAGS@ 
to save me putting this on every GCC build line ...

>> I built x86_64-darwin12 X powerpc-darwin9 [build = x86_64-darwin12]
>> and then a native X powerpc-darwin9  [build = x86_64-darwin12]
>> 
>> Ada built and I can do "gnatmake hello.adb" on the powerpc system and
>> produce a working exe, gcc and g++ seem to produce similar test output from
>> recent runs.
> 
> That's nice.
> 
>> Do you have a way to run acats for an out-of-tree test?
> 
> Presumably not, but you could try to run gnat.dg instead.

OK - will give that a whirl next time i am in front of that machine..

It would be a useful thing to make an acats script variant to work with installed/out-of-tree testing.
Iain
Bernd Edlinger Dec. 12, 2013, 1:19 p.m. UTC | #6
>
>> your patch looks quite nice, (maybe s/host_alias= @host_alias@/host_alias =
>> @host_alias@/)
>
> Thanks for spotting it, now fixed.
>
>> but I have to make a few more patches, to get it working:
>>
>>
>> error: "system.ads" has restriction No_Implicit_Dynamic_Code
>> error: but the following files violate this restriction:
>> error: "make.adb"
>> error: "makeutl.adb"
>> error: "prj.adb"
>> error: "prj-env.adb"
>> error: "prj-conf.adb"
>> error: "prj-proc.adb"
>> error: "prj-nmsc.adb"
>>
>>
>> that's the most weird point. If I get rid of that pragma, and re-build
>> everything I get something that looks like a working gcc/gnat.
>
> Nice progress! To be fair, the violation of No_Implicit_Dynamic_Code was also
> reported under PR ada/55946, but the fix isn't to remove the pragma, as this
> particular version of system.ads should be used only to build the compiler and
> not the tools. This issue is supposed to be addressed by the RTS_DIR thing:
>
> # Put the host RTS dir first in the PATH to hide the default runtime
> # files that are among the sources
> RTS_DIR:=$(strip $(subst \,/,$(shell $(GNATLS_FOR_HOST) -v | grep adalib )))
>
> TOOLS_FLAGS_TO_PASS_CROSS= \
> "CC=$(CC)" \
> "CXX=$(CXX)" \
> "CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
> "LDFLAGS=$(LDFLAGS)" \
> "ADAFLAGS=$(ADAFLAGS)" \
> "ADA_CFLAGS=$(ADA_CFLAGS)" \
> "INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
> "ADA_INCLUDES=-I$(RTS_DIR)../adainclude -I$(RTS_DIR)
>
> Could you post the command line for the compilation of one of the problematic
> units for the gnattools?
>
> --
> Eric Botcazou

arm-linux-gnueabihf-gcc -c -I./ -I/home/ed/gnu/x/arm-linux-gnueabihf-linux64/lib/gcc/arm-linux-gnueabihf/4.9.0/adalib/../adainclude -I/home/ed/gnu/x/arm-linux-gnueabihf-linux64/lib/gcc/arm-linux-gnueabihf/4.9.0/adalib/ -I. -I/home/ed/gnu/x/gcc-4.9-20131208/gcc/ada -g -O2 -W -Wall -gnatpg -gnata -I- /home/ed/gnu/x/gcc-4.9-20131208/gcc/ada/makeutl.adb


arm-linux-gnueabihf-gcc -c -I./ -I/home/ed/gnu/x/arm-linux-gnueabihf-linux64/lib/gcc/arm-linux-gnueabihf/4.9.0/adalib/../adainclude -I/home/ed/gnu/x/arm-linux-gnueabihf-linux64/lib/gcc/arm-linux-gnueabihf/4.9.0/adalib/ -I. -I/home/ed/gnu/x/gcc-4.9-20131208/gcc/ada -g -O2 -W -Wall -gnatpg -gnata -I- /home/ed/gnu/x/gcc-4.9-20131208/gcc/ada/prj-env.adb



/home/ed/gnu/x/arm-linux-gnueabihf-linux64: where the build=host target=arm-linux-gnueabihf compiler is installed.


Bernd.
Eric Botcazou Dec. 12, 2013, 3:23 p.m. UTC | #7
> Darwin doesn't have gettext in libSystem, I build it as a convenience
> library, but it still needs to refer to a system framework. For this to
> link the gnattools I need:
> 
> LDFLAGS="-L/path/to/my/convenience/lib -framework CoreFoundation"

OK, I'll add $(LDFLAGS).  It was actually already passed in the native case...
diff mbox

Patch

Index: gnattools/Makefile.in
===================================================================
--- gnattools/Makefile.in	(revision 205881)
+++ gnattools/Makefile.in	(working copy)
@@ -24,6 +24,8 @@  srcdir = @srcdir@
 libdir = @libdir@
 build = @build@
 target = @target@
+host = @host@
+host_alias= @host_alias@
 prefix = @prefix@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -92,6 +94,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)" \
@@ -105,6 +108,22 @@  TOOLS_FLAGS_TO_PASS_RE= \
 	"TOOLSCASE=cross"
 
 # Variables for gnattools, cross
+ifeq ($(build), $(host))
+  GNATMAKE_FOR_HOST=gnatmake
+  GNATLINK_FOR_HOST=gnatlink
+  GNATBIND_FOR_HOST=gnatbind
+  GNATLS_FOR_HOST=gnatls
+else
+  GNATMAKE_FOR_HOST=$(host_alias)-gnatmake
+  GNATLINK_FOR_HOST=$(host_alias)-gnatlink
+  GNATBIND_FOR_HOST=$(host_alias)-gnatbind
+  GNATLS_FOR_HOST=$(host_alias)-gnatls
+endif
+
+# Put the host RTS dir first in the PATH to hide the default runtime
+# files that are among the sources
+RTS_DIR:=$(strip $(subst \,/,$(shell $(GNATLS_FOR_HOST) -v | grep adalib )))
+
 TOOLS_FLAGS_TO_PASS_CROSS= \
 	"CC=$(CC)" \
 	"CXX=$(CXX)" \
@@ -117,9 +136,9 @@  TOOLS_FLAGS_TO_PASS_CROSS= \
 	"exeext=$(exeext)" \
 	"fsrcdir=$(fsrcdir)" \
 	"srcdir=$(fsrcdir)" \
-	"GNATMAKE=gnatmake" \
-	"GNATLINK=gnatlink" \
-	"GNATBIND=gnatbind" \
+	"GNATMAKE=$(GNATMAKE_FOR_HOST)" \
+	"GNATLINK=$(GNATLINK_FOR_HOST)" \
+	"GNATBIND=$(GNATBIND_FOR_HOST)" \
 	"TOOLSCASE=cross" \
 	"LIBGNAT="
 
@@ -188,11 +207,6 @@  regnattools: $(GCC_DIR)/stamp-gnatlib-rt
 	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
 	  $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools
 
-# For cross builds of gnattools,
-# 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.
-RTS_DIR:=$(strip $(subst \,/,$(shell gnatls -v | grep adalib )))
 gnattools-cross: $(GCC_DIR)/stamp-tools
 	# gnattools1-re
 	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
Index: gcc/ada/gcc-interface/Make-lang.in
===================================================================
--- gcc/ada/gcc-interface/Make-lang.in	(revision 205881)
+++ gcc/ada/gcc-interface/Make-lang.in	(working copy)
@@ -658,7 +658,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 -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