* PATCH RFA: Build machinery: Autoconf support for Go
@ 2010-11-03 20:31 Ian Lance Taylor
2010-11-11 6:41 ` Ralf Wildenhues
0 siblings, 1 reply; 5+ messages in thread
From: Ian Lance Taylor @ 2010-11-03 20:31 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 722 bytes --]
This patch adds a new file config/go.m4, which provides autoconf support
for Go. This file is not used by anything at present, but it will be
used by the libgo library configure script when that is committed. A
version of this file has been proposed to the autoconf maintainers.
When gcc moves to a version of autoconf which includes Go support, this
file can be deleted. However, until that time, it is useful for libgo.
Putting it in a separate file means that the libgo configure script
itself most likely will not have to be changed when we move to a new
version of autoconf.
Bootstrapped on x86_64-unknown-linux-gnu. OK for mainline?
Ian
2010-11-03 Ian Lance Taylor <iant@google.com>
* go.m4: New file.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: go.m4 --]
[-- Type: text/x-diff, Size: 3283 bytes --]
Index: config/go.m4
===================================================================
--- config/go.m4 (revision 0)
+++ config/go.m4 (revision 0)
@@ -0,0 +1,105 @@
+# 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
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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 version is probably autoconf 2.64 specific.
+# This should be removed when we start using a version of autoconf
+# which includes this support.
+
+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.Open("conftest.out", os.O_WRONLY), 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH RFA: Build machinery: Autoconf support for Go
2010-11-03 20:31 PATCH RFA: Build machinery: Autoconf support for Go Ian Lance Taylor
@ 2010-11-11 6:41 ` Ralf Wildenhues
2010-11-11 23:32 ` Ian Lance Taylor
0 siblings, 1 reply; 5+ messages in thread
From: Ralf Wildenhues @ 2010-11-11 6:41 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: gcc-patches
Hello Ian,
* Ian Lance Taylor wrote on Wed, Nov 03, 2010 at 09:21:04PM CET:
> This patch adds a new file config/go.m4, which provides autoconf support
> for Go. This file is not used by anything at present, but it will be
> used by the libgo library configure script when that is committed. A
> version of this file has been proposed to the autoconf maintainers.
> When gcc moves to a version of autoconf which includes Go support, this
> file can be deleted. However, until that time, it is useful for libgo.
> Putting it in a separate file means that the libgo configure script
> itself most likely will not have to be changed when we move to a new
> version of autoconf.
>
> Bootstrapped on x86_64-unknown-linux-gnu. OK for mainline?
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 Makefile.in). OTOH
the size of this warrants a new file for clarity.
I'm assuming that the macro definitions here are in sync with those
posted on autoconf-patches.
Thanks,
Ralf
> 2010-11-03 Ian Lance Taylor <iant@google.com>
>
> * go.m4: New file.
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH RFA: Build machinery: Autoconf support for Go
2010-11-11 6:41 ` Ralf Wildenhues
@ 2010-11-11 23:32 ` Ian Lance Taylor
2010-11-12 0:40 ` Paolo Bonzini
0 siblings, 1 reply; 5+ messages in thread
From: Ian Lance Taylor @ 2010-11-11 23:32 UTC (permalink / raw)
To: Ralf Wildenhues; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1111 bytes --]
Ralf Wildenhues <Ralf.Wildenhues@gmx.de> 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 Makefile.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?
Ian
2010-11-11 Ian Lance Taylor <iant@google.com>
* go.m4: New file.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: go.m4 --]
[-- Type: text/x-diff, Size: 3294 bytes --]
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
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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_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.Open("conftest.out", os.O_WRONLY), 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
+
+])# m4_version_prereq
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH RFA: Build machinery: Autoconf support for Go
2010-11-11 23:32 ` Ian Lance Taylor
@ 2010-11-12 0:40 ` Paolo Bonzini
2010-11-12 21:22 ` Ian Lance Taylor
0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2010-11-12 0:40 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: Ralf Wildenhues, gcc-patches
On 11/12/2010 12:24 AM, Ian Lance Taylor wrote:
> Is this version of the patch OK for mainline?
>
Yes, thanks.
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH RFA: Build machinery: Autoconf support for Go
2010-11-12 0:40 ` Paolo Bonzini
@ 2010-11-12 21:22 ` Ian Lance Taylor
0 siblings, 0 replies; 5+ messages in thread
From: Ian Lance Taylor @ 2010-11-12 21:22 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Ralf Wildenhues, gcc-patches
Paolo Bonzini <bonzini@gnu.org> writes:
> On 11/12/2010 12:24 AM, Ian Lance Taylor wrote:
>> Is this version of the patch OK for mainline?
>>
>
> Yes, thanks.
Thanks, but I've decided to move the configury into libgo, so I'm
withdrawing this patch rather than committing it.
Ian
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-11-12 21:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-03 20:31 PATCH RFA: Build machinery: Autoconf support for Go Ian Lance Taylor
2010-11-11 6:41 ` Ralf Wildenhues
2010-11-11 23:32 ` Ian Lance Taylor
2010-11-12 0:40 ` Paolo Bonzini
2010-11-12 21:22 ` 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).