[patch] fix gotools cross build

Ian Lance Taylor iant@google.com
Mon Oct 19 16:44:00 GMT 2015


On Wed, May 6, 2015 at 5:34 AM, Matthias Klose <doko@ubuntu.com> wrote:
>
> Yes, it's documented that there is still some work to do for cross builds,
> however a cross build for gotools currently fails.
>
> The toplevel make always passes the GOC variable in the environment, overwriting
> anything configured in gotools own configure.ac. Fixed by explictly using @GOC@
> for GOCOMPILER.
>
> gotools is a host project, and the cross_compiling check always fails. Not sure
> if the $host != $target test is any better, but it works for me.
>
> Ok for the trunk and the gcc-5 branch?
>
>   Matthias
>
>         * Makefile.am: Use GOC configured in configure.ac for cross builds.
>         * configure.ac: Fix NATIVE conditional.
>         * Makefile.in, configure: Regenerate.
>
> --- gotools/Makefile.am
> +++ gotools/Makefile.am
> @@ -33,7 +33,7 @@
>  # Use the compiler we just built.
>  GOCOMPILER = $(GOC_FOR_TARGET)
>  else
> -GOCOMPILER = $(GOC)
> +GOCOMPILER = @GOC@
>  endif
>
>  GOCFLAGS = $(CFLAGS_FOR_TARGET)
> --- gotools/configure.ac
> +++ gotools/configure.ac
> @@ -46,7 +46,7 @@
>  AC_PROG_CC
>  AC_PROG_GO
>
> -AM_CONDITIONAL(NATIVE, test "$cross_compiling" = no)
> +AM_CONDITIONAL(NATIVE, test "$host" = "$target")
>
>  dnl Test for -lsocket and -lnsl.  Copied from libjava/configure.ac.
>  AC_CACHE_CHECK([for socket libraries], gotools_cv_lib_sockets,


I really apologize for never responding to this.  I keep meaning to
figure out the right thing to do, but I never have time to think about
it.

As far as I can see, both these suggested changes are wrong.  They may
avoid problems that exist today, but as far as I can see they don't do
it in the right way.

If GOC is not being set correctly by the top level Makefile, then the
fix is to set it correctly.  Overriding GOC in the gotools Makefile is
just going to lead us into more complexity and confusion over time.

The test for NATIVE currently tests whether we are building with a
cross-compiler.  You are suggesting changing it to be whether we are
building a cross-compiler.  Neither test is fully correct.  If we just
want to make things slightly more correct, we should that $build ==
$host (aka ! $cross_compiling) and that $host == $target.  If both
conditions are true, then we have a native build.  A change along
those lines is OK.

Sorry again for not responding to this.

Ian



More information about the Gcc-patches mailing list