This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH RFA: Build machinery: Autoconf support for Go

Ralf Wildenhues <> writes:

> I cannot approve this (yet), but it looks OK except for a couple of
> nits: I'd wrap the contents in m4_version_prereq([2.69],, [...])
> so that they turn into a no-op once the code has been integrated into
> Autoconf (assuming for the moment that this will hapenn before 2.69),
> similarly to how we treat additions to config/override.m4.  You could
> also have added the code to that file, that would've avoided any further
> dependencies of generated aclocal.m4 and configure files (and in
> directories using AC_PROG_GO but not using automake the dependency on
> config/go.m4 will need to be tracked manually in  OTOH
> the size of this warrants a new file for clarity.

Thanks for the review.  Fixed per below.

> I'm assuming that the macro definitions here are in sync with those
> posted on autoconf-patches.

They are intended to be, yes, though of course the autoconf patches have
not been accepted as of yet.

Is this version of the patch OK for mainline?


2010-11-11  Ian Lance Taylor  <>

	* go.m4: New file.

Index: config/go.m4
--- config/go.m4	(revision 0)
+++ config/go.m4	(revision 0)
@@ -0,0 +1,109 @@
+# Autoconf support for Go.                       -*- Autoconf -*-
+# Copyright (C) 2010 Free Software Foundation, Inc.
+# This program 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
+# GNU General Public License for more details.
+# Under Section 7 of GPL version 3, you are granted additional
+# permissions described in the Autoconf Configure Script Exception,
+# version 3.0, as published by the Free Software Foundation.
+# Go support--there is a pending autoconf patch for this.
+# This should be removed when we start requiring a version of autoconf
+# which includes this support.
+m4_version_prereq([2.69],, [
+AC_LANG_DEFINE([Go], [go], [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'
+[package main
+func main() {
+[AC_LANG_PROGRAM([import "os"],
+[if f, err := os.Open("conftest.out", os.O_WRONLY), err != nil {
+	os.Exit(1);
+ }
+ if err := f.Close(); err != nil {
+	os.Exit(1);
+ }
+ os.Exit(0);
+m4_if([$2], [main], ,
+[func $2();])],[$2();])])
+[func $1() int;
+var f := $1;
+], [return f();])])
+[AC_LANG_PROGRAM([$1], [var test_array @<:@1 - 2 * !($2)@:>@;
+test_array @<:@0@:>@ = 0
+import os
+func longval() long { return $2 }
+func ulongval() ulong { return $2 }],
+AN_PROGRAM([gccgo], [AC_PROG_GO])
+AC_ARG_VAR([GOC],   [Go compiler command])dnl
+AC_ARG_VAR([GOCFLAGS], [Go compiler flags])dnl
+      [AC_CHECK_TOOLS(GOC, [$1])],
+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
+if test -z "$GOC"; then
+  AC_CHECK_PROG(GOC, gccgo, gccgo, , , gccgo)
+# Provide some information about the compiler.
+_AS_ECHO_LOG([checking for _AC_LANG compiler version])
+set X $ac_compile
+_AC_DO_LIMIT([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
+GOCFLAGS="-g -O2"
+])# m4_version_prereq

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]