public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Patch RFA: Support for building Go tools
@ 2015-01-14 19:30 Uros Bizjak
  2015-01-15 22:18 ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: Uros Bizjak @ 2015-01-14 19:30 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ian Taylor, gofrontend-dev

Hello!

> This patch adds support to the GCC tree for building tools that are
> used with Go.  There are two external used tools (go, gofmt) and one
> tool used internally by go (cgo).  This patch is pure machinery, with
> no source code.  The tools are not built by default, only when go is
> enabled using --enable-languages.  For the moment the tools are also
> not built when building a cross-compiler, although I hope to change
> that when I figure out what is needed.

Attached is the patch that enables gotools on alpha/linux.

Tested on alpha-linux-gnu, cgo, go and gofmt executables run without problems.

Uros.

--cut here--
Index: go/go/build/build.go
===================================================================
--- go/go/build/build.go        (revision 219515)
+++ go/go/build/build.go        (working copy)
@@ -266,6 +266,7 @@ var cgoEnabled = map[string]bool{
        "freebsd/amd64":   true,
        "freebsd/arm":     true,
        "linux/386":       true,
+       "linux/alpha":     true,
        "linux/amd64":     true,
        "linux/arm":       true,
        "linux/ppc64":     true,
--cut here--

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patch RFA: Support for building Go tools
  2015-01-14 19:30 Patch RFA: Support for building Go tools Uros Bizjak
@ 2015-01-15 22:18 ` Ian Lance Taylor
  0 siblings, 0 replies; 10+ messages in thread
From: Ian Lance Taylor @ 2015-01-15 22:18 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches, gofrontend-dev

On Wed, Jan 14, 2015 at 11:07 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>
>> This patch adds support to the GCC tree for building tools that are
>> used with Go.  There are two external used tools (go, gofmt) and one
>> tool used internally by go (cgo).  This patch is pure machinery, with
>> no source code.  The tools are not built by default, only when go is
>> enabled using --enable-languages.  For the moment the tools are also
>> not built when building a cross-compiler, although I hope to change
>> that when I figure out what is needed.
>
> Attached is the patch that enables gotools on alpha/linux.
>
> Tested on alpha-linux-gnu, cgo, go and gofmt executables run without problems.

Thanks.  Committed.

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patch RFA: Support for building Go tools
  2015-01-09 21:24       ` Ian Lance Taylor
@ 2015-01-09 21:29         ` Ian Lance Taylor
  0 siblings, 0 replies; 10+ messages in thread
From: Ian Lance Taylor @ 2015-01-09 21:29 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gcc-patches, gofrontend-dev, Lynn Boger

Committed initial gotools patch with following ChangeLog entries:

./:

2015-01-09  Ian Lance Taylor  <iant@google.com>

	* configure.ac (host_tools): Add gotools.
	* Makefile.def (host_modules): Add gotools.
	(dependencies): Add dependency of all-gotools on all-target-libgo.

gcc/go/:

2015-01-09  Ian Lance Taylor  <iant@google.com>

	* config-lang.in (lang_dirs): Define.

gotools/:

2015-01-09  Ian Lance Taylor  <iant@google.com>

	* Initial implementation.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patch RFA: Support for building Go tools
  2015-01-09 15:51     ` Paolo Bonzini
@ 2015-01-09 21:24       ` Ian Lance Taylor
  2015-01-09 21:29         ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: Ian Lance Taylor @ 2015-01-09 21:24 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gcc-patches, gofrontend-dev, Lynn Boger

On Fri, Jan 9, 2015 at 7:40 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
>
>
> On 09/01/2015 15:24, Ian Lance Taylor wrote:
>>> >
>>> > This should work automatically, the only difference is that you must
>>> > omit $(LIBGODEP) from the dependencies.
>> What will happen if there is no installed gccgo at the right version?
>
> Compilation fails.
>
>> What should happen?
>
> Compilation fails. :)
>
>> I haven't been keeping track--will the build machinery now build a
>> build-x-host Go compiler?
>
> No, but the build machinery should point the Makefile variables to a
> build-x-host tool from the PATH.  If it doesn't, you need to modify the
> toplevel configure.ac and Makefile.tpl.

I forgot: there is another problem with using the build-x-host
compiler to build the tools.  That will build them with the host
version of the go/build package, which will set the default values for
the architecture and OS to be that of the host, not the target.  They
should really be the target.  We can fix this, but it will require
some thought.

I plan to commit the version that does not do anything when building a
cross-compiler in order to proceed.  The situation will not be worse
than it is today.

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patch RFA: Support for building Go tools
  2015-01-09 14:28   ` Ian Lance Taylor
@ 2015-01-09 15:51     ` Paolo Bonzini
  2015-01-09 21:24       ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: Paolo Bonzini @ 2015-01-09 15:51 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-patches, gofrontend-dev, Lynn Boger



On 09/01/2015 15:24, Ian Lance Taylor wrote:
>> >
>> > This should work automatically, the only difference is that you must
>> > omit $(LIBGODEP) from the dependencies.
> What will happen if there is no installed gccgo at the right version?

Compilation fails.

> What should happen?

Compilation fails. :)

> I haven't been keeping track--will the build machinery now build a
> build-x-host Go compiler?

No, but the build machinery should point the Makefile variables to a
build-x-host tool from the PATH.  If it doesn't, you need to modify the
toplevel configure.ac and Makefile.tpl.

Paolo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patch RFA: Support for building Go tools
  2015-01-09  8:54 ` Paolo Bonzini
  2015-01-09  9:10   ` Paolo Bonzini
@ 2015-01-09 14:28   ` Ian Lance Taylor
  2015-01-09 15:51     ` Paolo Bonzini
  1 sibling, 1 reply; 10+ messages in thread
From: Ian Lance Taylor @ 2015-01-09 14:28 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gcc-patches, gofrontend-dev, Lynn Boger

On Fri, Jan 9, 2015 at 12:54 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
>
>> +
>> +# For a non-native build we have to build the programs using a
>> +# previously built host (or build -> host) Go compiler.  We should
>> +# only do this if such a compiler is available.  Figure this out
>> +# later.
>> +
>> +endif
>
> This should work automatically, the only difference is that you must
> omit $(LIBGODEP) from the dependencies.

What will happen if there is no installed gccgo at the right version?
What should happen?

I haven't been keeping track--will the build machinery now build a
build-x-host Go compiler?

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patch RFA: Support for building Go tools
  2015-01-09  8:54 ` Paolo Bonzini
@ 2015-01-09  9:10   ` Paolo Bonzini
  2015-01-09 14:28   ` Ian Lance Taylor
  1 sibling, 0 replies; 10+ messages in thread
From: Paolo Bonzini @ 2015-01-09  9:10 UTC (permalink / raw)
  To: gcc-patches; +Cc: Lynn Boger



On 08/01/2015 22:35, Ian Lance Taylor wrote:
> 
> +if NATIVE
> +
> +# For a native build we build the programs using the newly built libgo
> +# and install them as regular programs.
> +
> +bin_PROGRAMS = go$(EXEEXT) gofmt$(EXEEXT)
> +libexecsub_PROGRAMS = cgo$(EXEEXT)
> +
> +go$(EXEEXT): $(go_cmd_go_files) zdefaultcc.go $(LIBGODEP)
> +	$(GOLINK) $(go_cmd_go_files) zdefaultcc.go
> +gofmt$(EXEEXT): $(go_cmd_gofmt_files) $(LIBGODEP)
> +	$(GOLINK) $(go_cmd_gofmt_files)
> +cgo$(EXEEXT): $(go_cmd_cgo_files) zdefaultcc.go $(LIBGODEP)
> +	$(GOLINK) $(go_cmd_cgo_files) zdefaultcc.go
> +
> +else
> +
> +# For a non-native build we have to build the programs using a
> +# previously built host (or build -> host) Go compiler.  We should
> +# only do this if such a compiler is available.  Figure this out
> +# later.
> +
> +endif

This should work automatically, the only difference is that you must
omit $(LIBGODEP) from the dependencies.

> +AC_PROG_CC
> +AC_PROG_GO
> +
> +AM_CONDITIONAL(NATIVE, test "$host_noncanonical" = "$target_noncanonical")

Can you check $cross_compiling = no instead?

Looks good apart for these two nits.

Paolo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patch RFA: Support for building Go tools
  2015-01-08 21:35 Ian Lance Taylor
  2015-01-08 21:51 ` pinskia
@ 2015-01-09  8:54 ` Paolo Bonzini
  2015-01-09  9:10   ` Paolo Bonzini
  2015-01-09 14:28   ` Ian Lance Taylor
  1 sibling, 2 replies; 10+ messages in thread
From: Paolo Bonzini @ 2015-01-09  8:54 UTC (permalink / raw)
  To: Ian Lance Taylor, gcc-patches, gofrontend-dev; +Cc: Lynn Boger



On 08/01/2015 22:35, Ian Lance Taylor wrote:
> 
> +if NATIVE
> +
> +# For a native build we build the programs using the newly built libgo
> +# and install them as regular programs.
> +
> +bin_PROGRAMS = go$(EXEEXT) gofmt$(EXEEXT)
> +libexecsub_PROGRAMS = cgo$(EXEEXT)
> +
> +go$(EXEEXT): $(go_cmd_go_files) zdefaultcc.go $(LIBGODEP)
> +	$(GOLINK) $(go_cmd_go_files) zdefaultcc.go
> +gofmt$(EXEEXT): $(go_cmd_gofmt_files) $(LIBGODEP)
> +	$(GOLINK) $(go_cmd_gofmt_files)
> +cgo$(EXEEXT): $(go_cmd_cgo_files) zdefaultcc.go $(LIBGODEP)
> +	$(GOLINK) $(go_cmd_cgo_files) zdefaultcc.go
> +
> +else
> +
> +# For a non-native build we have to build the programs using a
> +# previously built host (or build -> host) Go compiler.  We should
> +# only do this if such a compiler is available.  Figure this out
> +# later.
> +
> +endif

This should work automatically, the only difference is that you must
omit $(LIBGODEP) from the dependencies.

> +AC_PROG_CC
> +AC_PROG_GO
> +
> +AM_CONDITIONAL(NATIVE, test "$host_noncanonical" = "$target_noncanonical")

Can you check $cross_compiling = no instead?

Looks good apart for these two nits.

Paolo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patch RFA: Support for building Go tools
  2015-01-08 21:35 Ian Lance Taylor
@ 2015-01-08 21:51 ` pinskia
  2015-01-09  8:54 ` Paolo Bonzini
  1 sibling, 0 replies; 10+ messages in thread
From: pinskia @ 2015-01-08 21:51 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-patches, gofrontend-dev, Lynn Boger





> On Jan 8, 2015, at 1:35 PM, Ian Lance Taylor <iant@golang.org> wrote:
> 
> This patch adds support to the GCC tree for building tools that are
> used with Go.  There are two external used tools (go, gofmt) and one
> tool used internally by go (cgo).  This patch is pure machinery, with
> no source code.  The tools are not built by default, only when go is
> enabled using --enable-languages.  For the moment the tools are also
> not built when building a cross-compiler, although I hope to change
> that when I figure out what is needed.

When you add support for cross, please also make sure that Canadian cross works too. 

Thanks,
Andrew

> 
> The tools work just as they do when built for the gc compiler, only
> they use gccgo instead of gc.  For documentation on these tools and
> what they do see http://golang.org/cmd/go ,
> http://golang.org/cmd/gofmt , http://golang.org/cmd/cgo .
> 
> This patch parallels the mechanism used in the existing gnattools
> directory for building Ada tools.
> 
> Could the build machinery maintainers please take a look and let me
> know if this is OK?  Thanks.
> 
> Lynn, please also take a look and see if this works for you.
> 
> The first attachment is the real changes for review.  The second
> attachment is a compressed patch for the generated files, for
> convenience for anybody who wants to try this out.
> 
> Ian
> <foo.txt>
> <foo1.txt.bz2>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Patch RFA: Support for building Go tools
@ 2015-01-08 21:35 Ian Lance Taylor
  2015-01-08 21:51 ` pinskia
  2015-01-09  8:54 ` Paolo Bonzini
  0 siblings, 2 replies; 10+ messages in thread
From: Ian Lance Taylor @ 2015-01-08 21:35 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev; +Cc: Lynn Boger

[-- Attachment #1: Type: text/plain, Size: 1136 bytes --]

This patch adds support to the GCC tree for building tools that are
used with Go.  There are two external used tools (go, gofmt) and one
tool used internally by go (cgo).  This patch is pure machinery, with
no source code.  The tools are not built by default, only when go is
enabled using --enable-languages.  For the moment the tools are also
not built when building a cross-compiler, although I hope to change
that when I figure out what is needed.

The tools work just as they do when built for the gc compiler, only
they use gccgo instead of gc.  For documentation on these tools and
what they do see http://golang.org/cmd/go ,
http://golang.org/cmd/gofmt , http://golang.org/cmd/cgo .

This patch parallels the mechanism used in the existing gnattools
directory for building Ada tools.

Could the build machinery maintainers please take a look and let me
know if this is OK?  Thanks.

Lynn, please also take a look and see if this works for you.

The first attachment is the real changes for review.  The second
attachment is a compressed patch for the generated files, for
convenience for anybody who wants to try this out.

Ian

[-- Attachment #2: foo.txt --]
[-- Type: text/plain, Size: 11398 bytes --]

Index: Makefile.def
===================================================================
--- Makefile.def	(revision 219358)
+++ Makefile.def	(working copy)
@@ -120,6 +120,7 @@ host_modules= { module= lto-plugin; boot
 		extra_configure_flags='--enable-shared @extra_linker_plugin_flags@ @extra_linker_plugin_configure_flags@';
 		extra_make_flags='@extra_linker_plugin_flags@'; };
 host_modules= { module= libcc1; extra_configure_flags=--enable-shared; };
+host_modules= { module= gotools; };
 
 target_modules = { module= libstdc++-v3;
 		   bootstrap=true;
@@ -363,6 +364,8 @@ dependencies = { module=all-lto-plugin;
 dependencies = { module=configure-libcc1; on=configure-gcc; };
 dependencies = { module=all-libcc1; on=all-gcc; };
 
+dependencies = { module=all-gotools; on=all-target-libgo; };
+
 dependencies = { module=all-utils; on=all-libiberty; };
 
 dependencies = { module=configure-mpfr; on=all-gmp; };
Index: configure.ac
===================================================================
--- configure.ac	(revision 219358)
+++ configure.ac	(working copy)
@@ -140,7 +140,7 @@ host_libs="intl libiberty opcodes bfd re
 # binutils, gas and ld appear in that order because it makes sense to run
 # "make check" in that particular order.
 # If --enable-gold is used, "gold" may replace "ld".
-host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1"
+host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gotools"
 
 # libgcj represents the runtime libraries only used by gcj.
 libgcj="target-libffi \
Index: gcc/go/config-lang.in
===================================================================
--- gcc/go/config-lang.in	(revision 219358)
+++ gcc/go/config-lang.in	(working copy)
@@ -29,6 +29,7 @@ language="go"
 compilers="go1\$(exeext)"
 
 target_libs="target-libgo target-libffi target-libbacktrace"
+lang_dirs="gotools"
 
 # The Go frontend is written in C++, so we need to build the C++
 # compiler during stage 1.
Index: gotools/Makefile.am
===================================================================
--- gotools/Makefile.am	(revision 0)
+++ gotools/Makefile.am	(working copy)
@@ -0,0 +1,114 @@
+# Makefile for gotools
+#   Copyright 2015 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+ACLOCAL_AMFLAGS = -I ./config -I ../config
+
+gcc_version := $(shell $(GCC_FOR_TARGET) -dumpversion)
+
+libexecsubdir = $(libexecdir)/gcc/$(target_noncanonical)/$(gcc_version)
+
+mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
+PWD_COMMAND = $${PWDCMD-pwd}
+STAMP = echo timestamp >
+
+libgodir = ../$(target_noncanonical)/libgo
+LIBGODEP = $(libgodir)/libgo.la
+
+GOCFLAGS = $(CFLAGS_FOR_TARGET)
+GOCOMPILE = $(GOC) $(GOCFLAGS)
+
+AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs -static-libgo
+GOLINK = $(GOC) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
+
+cmdsrcdir = $(srcdir)/../libgo/go/cmd
+
+go_cmd_go_files = \
+	$(cmdsrcdir)/go/build.go \
+	$(cmdsrcdir)/go/clean.go \
+	$(cmdsrcdir)/go/main.go \
+	$(cmdsrcdir)/go/signal.go \
+	$(cmdsrcdir)/go/version.go \
+	$(cmdsrcdir)/go/env.go \
+	$(cmdsrcdir)/go/help.go \
+	$(cmdsrcdir)/go/run.go \
+	$(cmdsrcdir)/go/tool.go \
+	$(cmdsrcdir)/go/vet.go \
+	$(cmdsrcdir)/go/context.go \
+	$(cmdsrcdir)/go/fix.go \
+	$(cmdsrcdir)/go/get.go \
+	$(cmdsrcdir)/go/http.go \
+	$(cmdsrcdir)/go/signal_unix.go \
+	$(cmdsrcdir)/go/vcs.go \
+	$(cmdsrcdir)/go/discovery.go \
+	$(cmdsrcdir)/go/fmt.go \
+	$(cmdsrcdir)/go/go11.go \
+	$(cmdsrcdir)/go/list.go \
+	$(cmdsrcdir)/go/pkg.go \
+	$(cmdsrcdir)/go/test.go \
+	$(cmdsrcdir)/go/testflag.go
+
+go_cmd_gofmt_files = \
+	$(cmdsrcdir)/gofmt/doc.go \
+	$(cmdsrcdir)/gofmt/gofmt.go \
+	$(cmdsrcdir)/gofmt/rewrite.go \
+	$(cmdsrcdir)/gofmt/simplify.go
+
+go_cmd_cgo_files = \
+	$(cmdsrcdir)/cgo/ast.go \
+	$(cmdsrcdir)/cgo/doc.go \
+	$(cmdsrcdir)/cgo/gcc.go \
+	$(cmdsrcdir)/cgo/godefs.go \
+	$(cmdsrcdir)/cgo/main.go \
+	$(cmdsrcdir)/cgo/out.go \
+	$(cmdsrcdir)/cgo/util.go
+
+GOC_INSTALL_NAME := $(shell echo gccgo|sed '$(program_transform_name)')
+GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
+GXX_INSTALL_NAME := $(shell echo g++|sed '$(program_transform_name)')
+
+zdefaultcc.go: s-zdefaultcc; @true
+s-zdefaultcc: Makefile
+	echo 'package main' > zdefaultcc.go.tmp
+	echo 'const defaultGOC = "$(bindir)/$(GOC_INSTALL_NAME)"' >> zdefaultcc.go.tmp
+	echo 'const defaultCC = "$(bindir)/$(GCC_INSTALL_NAME)"' >> zdefaultcc.go.tmp
+	echo 'const defaultCXX = "$(bindir)/$(GXX_INSTALL_NAME)"' >> zdefaultcc.go.tmp
+	$(SHELL) $(srcdir)/../move-if-change zdefaultcc.go.tmp zdefaultcc.go
+	$(STAMP) $@ 
+
+if NATIVE
+
+# For a native build we build the programs using the newly built libgo
+# and install them as regular programs.
+
+bin_PROGRAMS = go$(EXEEXT) gofmt$(EXEEXT)
+libexecsub_PROGRAMS = cgo$(EXEEXT)
+
+go$(EXEEXT): $(go_cmd_go_files) zdefaultcc.go $(LIBGODEP)
+	$(GOLINK) $(go_cmd_go_files) zdefaultcc.go
+gofmt$(EXEEXT): $(go_cmd_gofmt_files) $(LIBGODEP)
+	$(GOLINK) $(go_cmd_gofmt_files)
+cgo$(EXEEXT): $(go_cmd_cgo_files) zdefaultcc.go $(LIBGODEP)
+	$(GOLINK) $(go_cmd_cgo_files) zdefaultcc.go
+
+else
+
+# For a non-native build we have to build the programs using a
+# previously built host (or build -> host) Go compiler.  We should
+# only do this if such a compiler is available.  Figure this out
+# later.
+
+endif
Index: gotools/config/go.m4
===================================================================
--- gotools/config/go.m4	(revision 0)
+++ gotools/config/go.m4	(working copy)
@@ -0,0 +1,92 @@
+dnl acinclude.m4 -- configure macros
+
+dnl Copyright 2009 The Go Authors. All rights reserved.
+dnl Use of this source code is governed by a BSD-style
+dnl license that can be found in the LICENSE file.
+
+dnl Go support--this could be in autoconf.
+dnl This version is probably autoconf 2.64 specific.
+
+AC_LANG_DEFINE([Go], [go], [GO], [],
+[ac_ext=go
+ac_compile='$GOC -c $GOCFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
+ac_link='$GOC -o conftest$ac_exeext $GOCFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
+ac_compile_gnu=yes
+])
+
+AU_DEFUN([AC_LANG_GO], [AC_LANG(Go)])
+
+m4_define([AC_LANG_PROGRAM(Go)],
+[package main
+$1
+func main() {
+$2
+}])
+
+m4_define([_AC_LANG_IO_PROGRAM(Go)],
+[AC_LANG_PROGRAM([import "os"],
+[if f, err := os.Create("conftest.out"), err != nil {
+	os.Exit(1);
+ }
+ if err := f.Close(); err != nil {
+	os.Exit(1);
+ }
+ os.Exit(0);
+])])
+
+m4_define([AC_LANG_CALL(Go)],
+[AC_LANG_PROGRAM([$1
+m4_if([$2], [main], ,
+[func $2();])],[$2();])])
+
+m4_define([AC_LANG_FUNC_LINK_TRY(Go)],
+[AC_LANG_PROGRAM(
+[func $1() int;
+var f := $1;
+], [return f();])])
+
+m4_define([AC_LANG_BOOL_COMPILE_TRY(Go)],
+[AC_LANG_PROGRAM([$1], [var test_array @<:@1 - 2 * !($2)@:>@;
+test_array @<:@0@:>@ = 0
+])])
+
+m4_define([AC_LANG_INT_SAVE(Go)],
+[AC_LANG_PROGRAM([$1
+import os
+func longval() long { return $2 }
+func ulongval() ulong { return $2 }],
+[panic("unimplemented")])])
+
+AC_DEFUN([AC_LANG_COMPILER(Go)],
+[AC_REQUIRE([AC_PROG_GO])])
+
+AN_MAKEVAR([GOC], [AC_PROG_GO])
+AN_PROGRAM([gccgo], [AC_PROG_GO])
+AC_DEFUN([AC_PROG_GO],
+[AC_LANG_PUSH(Go)dnl
+AC_ARG_VAR([GOC],   [Go compiler command])dnl
+AC_ARG_VAR([GOCFLAGS], [Go compiler flags])dnl
+_AC_ARG_VAR_LDFLAGS()dnl
+m4_ifval([$1],
+      [AC_CHECK_TOOLS(GOC, [$1])],
+[AC_CHECK_TOOL(GOC, gccgo)
+if test -z "$GOC"; then
+  if test -n "$ac_tool_prefix"; then
+    AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [$ac_tool_prefix}gccgo])
+  fi
+fi
+if test -z "$GOC"; then
+  AC_CHECK_PROG(GOC, gccgo, gccgo, , , gccgo)
+fi
+])
+
+# Provide some information about the compiler.
+_AS_ECHO_LOG([checking for _AC_LANG compiler version])
+set X $ac_compile
+ac_compiler=$[2]
+_AC_DO_LIMIT([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
+m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
+m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
+GOCFLAGS="-g -O2"
+AC_LANG_POP(Go)dnl
+])# AC_PROG_GO
Index: gotools/configure.ac
===================================================================
--- gotools/configure.ac	(revision 0)
+++ gotools/configure.ac	(working copy)
@@ -0,0 +1,53 @@
+# Configure script for gotools.
+#   Copyright 2015 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+AC_INIT(package-unused, version-unused,, gotools)
+AC_PREREQ(2.64)
+AC_CONFIG_SRCDIR(Makefile.am)
+
+m4_include([config/go.m4])
+
+# Determine the noncanonical names used for directories.
+ACX_NONCANONICAL_BUILD
+ACX_NONCANONICAL_HOST
+ACX_NONCANONICAL_TARGET
+
+dnl Autoconf 2.5x and later will set a default program prefix if
+dnl --target was used, even if it was the same as --host.  Disable
+dnl that behavior.  This must be done before AC_CANONICAL_SYSTEM
+dnl to take effect.
+test "$host_noncanonical" = "$target_noncanonical" &&
+  test "$program_prefix$program_suffix$program_transform_name" = \
+    NONENONEs,x,x, &&
+  program_transform_name=s,y,y,
+
+AC_CANONICAL_SYSTEM
+AC_ARG_PROGRAM
+
+AM_INIT_AUTOMAKE([1.9.3 no-define foreign no-dist -Wall -Wno-portability])
+AM_MAINTAINER_MODE
+
+AC_PROG_INSTALL
+
+AC_PROG_CC
+AC_PROG_GO
+
+AM_CONDITIONAL(NATIVE, test "$host_noncanonical" = "$target_noncanonical")
+
+AC_CONFIG_FILES(Makefile)
+
+AC_OUTPUT
Index: gotools/README
===================================================================
--- gotools/README	(revision 0)
+++ gotools/README	(working copy)
@@ -0,0 +1,13 @@
+This directory builds tools used by people working in the Go language.
+The source code for these tools lives in libgo/go/cmd, where it is
+copied from the master gofrontend repository.  This directory contains
+only the configure/Makefile instructions required to build the tools.
+
+This directory builds two programs for general use: go and gofmt.  It
+also builds one program for internal use by the go tool: cgo.  For
+more information on these tools see the doc.go files in the relevant
+source code, which can also be seen hosted at golang.org:
+
+http://golang.org/cmd/go
+http://golang.org/cmd/gofmt
+http://golang.org/cmd/cgo

[-- Attachment #3: foo1.txt.bz2 --]
[-- Type: application/x-bzip2, Size: 46919 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-01-15 22:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-14 19:30 Patch RFA: Support for building Go tools Uros Bizjak
2015-01-15 22:18 ` Ian Lance Taylor
  -- strict thread matches above, loose matches on Subject: below --
2015-01-08 21:35 Ian Lance Taylor
2015-01-08 21:51 ` pinskia
2015-01-09  8:54 ` Paolo Bonzini
2015-01-09  9:10   ` Paolo Bonzini
2015-01-09 14:28   ` Ian Lance Taylor
2015-01-09 15:51     ` Paolo Bonzini
2015-01-09 21:24       ` Ian Lance Taylor
2015-01-09 21:29         ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).