Patchwork Committed Go frontend

mail settings
Submitter Ian Taylor
Date Dec. 3, 2010, 4:40 a.m.
Message ID <>
Download mbox | patch
Permalink /patch/74092/
State New
Headers show


Ian Taylor - Dec. 3, 2010, 4:40 a.m.
I have committed the Go frontend to mainline gcc.

I ran the following commands.  I won't show attach the many new files in
this message.

svn cp svn// gcc/
svn cp svn// ./
svn cp svn:// gcc/testsuite/
svn cp svn:// gcc/testsuite/
svn cp svn:// gcc/testsuite/

I also committed the appended patches.

Bootstrapped and tested on x86_64-unknown-linux-gnu.  Please let me know
about any problems.  The Go frontend is not built by default, so this
should not have a significant effect on most developers.

Please let me know about any problems.

I expect that I will use the gccgo branch going forward as a set of
tested sources for generating Go code.  In the next few days I will
complete the final items on the frontend checklist at , the ones after "If
the front end is added to the official GCC source repository."



2010-12-02  Ian Lance Taylor  <>

	* gcc.c (default_compilers): Add entry for ".go".
	* common.opt: Add -static-libgo as a driver option.
	* doc/install.texi (Configuration): Mention libgo as an option for
	--enable-shared.  Mention go as an option for --enable-languages.
	* doc/invoke.texi (Overall Options): Mention .go as a file name
	suffix.  Mention go as a -x option.
	* doc/frontends.texi (G++ and GCC): Mention Go as a supported
	* doc/sourcebuild.texi (Top Level): Mention libgo.
	* doc/standards.texi (Standards): Add section on Go language.
	Move references for other languages into their own section.
	* doc/contrib.texi (Contributors): Mention that I contributed the
	Go frontend.


2010-12-02  Ian Lance Taylor  <>

	* lib/go.exp: New file.
	* lib/go-dg.exp: New file.
	* lib/go-torture.exp: New file.
	* lib/target-supports.exp (check_compile): Match // Go.


Index: gcc/doc/sourcebuild.texi
--- gcc/doc/sourcebuild.texi	(revision 167405)
+++ gcc/doc/sourcebuild.texi	(working copy)
@@ -81,6 +81,10 @@  The GCC runtime library.
 @item libgfortran
 The Fortran runtime library.
+@item libgo
+The Go runtime library.  The bulk of this library is mirrored from the
+@uref{, master Go repository}.
 @item libgomp
 The GNU OpenMP runtime library.
Index: gcc/doc/standards.texi
--- gcc/doc/standards.texi	(revision 167405)
+++ gcc/doc/standards.texi	(working copy)
@@ -271,6 +271,18 @@  The authoritative manual on Objective-C 
 For more information concerning the history of Objective-C that is
 available online, see @uref{}
+@section Go language
+The Go language continues to evolve as of this writing; see the
+@uref{, current language
+specifications}.  At present there are no specific versions of Go, and
+there is no way to describe the language supported by GCC in terms of
+a specific version.  In general GCC tracks the evolving specification
+closely, and any given release will support the language as of the
+date that the release was frozen.
+@section References for other languages
 @xref{Top, GNAT Reference Manual, About This Guide, gnat_rm,
 GNAT Reference Manual}, for information on standard
 conformance and compatibility of the Ada compiler.
Index: gcc/doc/invoke.texi
--- gcc/doc/invoke.texi	(revision 167405)
+++ gcc/doc/invoke.texi	(working copy)
@@ -1070,6 +1070,9 @@  Free form Fortran source code which shou
 Free form Fortran source code which must be preprocessed (with the
 traditional preprocessor).
+@item @var{file}.go
+Go source code.
 @c FIXME: Descriptions of Java file types.
 @c @var{file}.java
 @c @var{file}.class
@@ -1123,6 +1126,7 @@  objective-c++ objective-c++-header objec
 assembler  assembler-with-cpp
 f77  f77-cpp-input f95  f95-cpp-input
 @end smallexample
Index: gcc/doc/contrib.texi
--- gcc/doc/contrib.texi	(revision 167405)
+++ gcc/doc/contrib.texi	(working copy)
@@ -900,8 +900,8 @@  Jeff Sturm for Java porting help, bug fi
 Shigeya Suzuki for this fixes for the bsdi platforms.
-Ian Lance Taylor for his mips16 work, general configury hacking,
-fixincludes, etc.
+Ian Lance Taylor for the Go frontend, the initial mips16 and mips64
+support, general configury hacking, fixincludes, etc.
 Holger Teutsch provided the support for the Clipper CPU@.
Index: gcc/doc/frontends.texi
--- gcc/doc/frontends.texi	(revision 167405)
+++ gcc/doc/frontends.texi	(working copy)
@@ -11,13 +11,14 @@ 
 @cindex GNU C Compiler
 @cindex Ada
 @cindex Fortran
+@cindex Go
 @cindex Java
 @cindex Objective-C
 @cindex Objective-C++
 GCC stands for ``GNU Compiler Collection''.  GCC is an integrated
 distribution of compilers for several major programming languages.  These
 languages currently include C, C++, Objective-C, Objective-C++, Java,
-Fortran, and Ada.
+Fortran, Ada, and Go.
 The abbreviation @dfn{GCC} has multiple meanings in common use.  The
 current official meaning is ``GNU Compiler Collection'', which refers
Index: gcc/doc/install.texi
--- gcc/doc/install.texi	(revision 167405)
+++ gcc/doc/install.texi	(working copy)
@@ -884,7 +884,7 @@  only for the listed packages.  For other
 will be built.  Package names currently recognized in the GCC tree are
 @samp{libgcc} (also known as @samp{gcc}), @samp{libstdc++} (not
 @samp{libstdc++-v3}), @samp{libffi}, @samp{zlib}, @samp{boehm-gc},
-@samp{ada}, @samp{libada}, @samp{libjava} and @samp{libobjc}.
+@samp{ada}, @samp{libada}, @samp{libjava}, @samp{libgo}, and @samp{libobjc}.
 Note @samp{libiberty} does not support shared libraries at all.
 Use @option{--disable-shared} to build only static libraries.  Note that
@@ -1305,15 +1305,12 @@  their runtime libraries should be built.
 grep language= */
 @end smallexample
 Currently, you can use any of the following:
-@code{all}, @code{ada}, @code{c}, @code{c++}, @code{fortran}, @code{java},
-@code{objc}, @code{obj-c++}.
+@code{all}, @code{ada}, @code{c}, @code{c++}, @code{fortran},
+@code{go}, @code{java}, @code{objc}, @code{obj-c++}.
 Building the Ada compiler has special requirements, see below.
 If you do not pass this flag, or specify the option @code{all}, then all
 default languages available in the @file{gcc} sub-tree will be configured.
-Ada and Objective-C++ are not default languages; the rest are.
-Re-defining @code{LANGUAGES} when calling @samp{make} @strong{does not}
-work anymore, as those language sub-directories might not have been
+Ada, Go and Objective-C++ are not default languages; the rest are.
 @item --enable-stage1-languages=@var{lang1},@var{lang2},@dots{}
 Specify that a particular subset of compilers and their runtime
Index: gcc/gcc.c
--- gcc/gcc.c	(revision 167405)
+++ gcc/gcc.c	(working copy)
@@ -896,6 +896,7 @@  static const struct compiler default_com
   {".p", "#Pascal", 0, 0, 0}, {".pas", "#Pascal", 0, 0, 0},
   {".java", "#Java", 0, 0, 0}, {".class", "#Java", 0, 0, 0},
   {".zip", "#Java", 0, 0, 0}, {".jar", "#Java", 0, 0, 0},
+  {".go", "#Go", 0, 1, 0},
   /* Next come the entries for C.  */
   {".c", "@c", 0, 0, 1},

Index: gcc/testsuite/lib/target-supports.exp
--- gcc/testsuite/lib/target-supports.exp	(revision 167405)
+++ gcc/testsuite/lib/target-supports.exp	(working copy)
@@ -34,7 +34,8 @@ 
 # "// C++" for c++,
 # "! Fortran" for Fortran code,
 # "/* ObjC", for ObjC
-# and "// ObjC++" for ObjC++
+# "// ObjC++" for ObjC++
+# and "// Go" for Go
 # If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to 
 # allow for ObjC/ObjC++ specific flags.
 proc check_compile {basename type contents args} {
@@ -51,6 +52,7 @@  proc check_compile {basename type conten
 	"*// C++*" { set src ${basename}[pid].cc }
 	"*// ObjC++*" { set src ${basename}[pid].mm }
 	"*/* ObjC*" { set src ${basename}[pid].m }
+	"*// Go*" { set src ${basename}[pid].go }
 	default {
 	    switch -- $tool {
 		"objc" { set src ${basename}[pid].m }

Index: gcc/common.opt
--- gcc/common.opt	(revision 167405)
+++ gcc/common.opt	(working copy)
@@ -2272,6 +2272,10 @@  Driver
+; Documented for Go, but always accepted by driver.