diff mbox

fix gotools cross build

Message ID 554A0A5F.3060106@ubuntu.com
State New
Headers show

Commit Message

Matthias Klose May 6, 2015, 12:34 p.m. UTC
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.

Comments

Matthias Klose Oct. 10, 2015, 9:26 p.m. UTC | #1
still needed, both on the trunk and the branch.

On 06.05.2015 14:34, Matthias Klose 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,
>
Ian Lance Taylor Oct. 19, 2015, 4:43 p.m. UTC | #2
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
diff mbox

Patch

--- 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,