How well does gcc support cross compile?

H. J. Lu hjl@lucon.org
Mon Apr 28 01:36:00 GMT 2003


On Sun, Apr 27, 2003 at 08:44:03AM -0700, Anthony Green wrote:
> On Sat, 2003-04-26 at 21:31, H. J. Lu wrote:
> > I wish I were wrong. My impression is libraries in the current gcc
> > do not support cross compiling to Linux very well.
> 
> There's a brand new pending patch that improves the situation for
> libgcj.  It includes some discussion of the problems:
> 
> http://gcc.gnu.org/ml/java-patches/2003-q2/msg00111.html
> 
> I'm sure feedback would be welcome.
> 

I am glad that people are working on it. I tried it for gcc 2.96. One
of my patches:

2002-09-17  H.J. Lu <hjl@gnu.org>

	* Makefile.am: Updated.

2002-07-03  H.J. Lu <hjl@gnu.org>

	* Makefile.am (ZIP): Fix Canadian cross.
	(GCJH): Likewise.
	* Makefile.in: Regenerated.

	* configure.in: Support none-newlib Canadian cross.
	* configure: Regenerated.

--- libjava/Makefile.am.cross	Tue Sep 17 08:34:41 2002
+++ libjava/Makefile.am	Tue Sep 17 09:55:53 2002
@@ -55,13 +55,13 @@ bin_SCRIPTS = addr2name.awk
 ## the tools from the path.
 if CANADIAN
 if NULL_TARGET
+ZIP = jar
+else
 ## In this case, gcj is found outside the build tree.  However, zip is
 ## found in the build tree.
 ZIP = $(MULTIBUILDTOP)../$(COMPPATH)/fastjar/jar
-else
-ZIP = jar
 endif
-GCJH = gcjh
+GCJH = $(host_alias)-gcjh
 else # CANADIAN
 GCJH = $(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh
 ZIP = $(MULTIBUILDTOP)../$(COMPPATH)/fastjar/jar
--- libjava/configure.in.cross	Tue Sep 17 08:34:41 2002
+++ libjava/configure.in	Tue Sep 17 09:53:26 2002
@@ -494,10 +494,10 @@ if test "x${with_newlib}" = "xyes"; then
    # If Canadian cross, then don't pick up tools from the build
    # directory.
    if test x"$build" != x"$with_cross_host" \
-        && test x"$build" != x"$target"; then
+        && test x"$build" != x"$host"; then
       CANADIAN=yes
       GCC_UNWIND_INCLUDE=
-      GCJ="${target_alias}-gcj"
+      GCJ="${host_alias}-gcj"
    fi
    NATIVE=no
 else
@@ -726,7 +726,14 @@ changequote(<<,>>)
       builddotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`
 changequote([,])
    fi
-   if test -x "${builddotdot}/../../gcc/gcj"; then
+
+   # If Canadian cross, then don't pick up tools from the build
+   # directory.
+   if test x"$build" != x"$with_cross_host" && test x"$build" != x"$host"; then
+      CANADIAN=yes
+      NULL_TARGET=yes
+      GCJ="${host_alias}-gcj"
+   elif test -x "${builddotdot}/../../gcc/gcj"; then
       dir="`cd ${builddotdot}/../../gcc && ${PWDCMD-pwd}`"
       GCJ="$dir/gcj -B`${PWDCMD-pwd}`/ -B$dir/"
    else
   
looks similar to what is proposed now. For canadian cross, I prefer
${host_alias} instead of ${target_alias}. Although they are the same,
${host_alias} is clearer to people that which host the generated
binaries are for.


H.J.



More information about the Gcc mailing list