blob: dd1327ad1fe20f2eeba8040271f47c14c8ab6248 [file] [log] [blame]
Andrew Gerrand7cb21a72012-01-19 11:24:54 +11001<!--{
2 "Title": "Contributing to the gccgo frontend"
3}-->
Ian Lance Taylor2528f332009-11-06 14:15:41 -08004
5<h2>Introduction</h2>
6
7<p>
Ian Lance Taylor253c1392012-02-18 11:15:52 -08008These are some notes on contributing to the gccgo frontend for GCC.
9For information on contributing to parts of Go other than gccgo,
Andrew Gerrandf78d50c2012-03-05 14:31:27 +110010see <a href="/doc/contribute.html">Contributing to the Go project</a>. For
Ian Lance Taylor253c1392012-02-18 11:15:52 -080011information on building gccgo for yourself,
Andrew Gerrandf78d50c2012-03-05 14:31:27 +110012see <a href="/doc/gccgo_install.html">Setting up and using gccgo</a>.
Ian Lance Taylorffde4972013-06-20 14:49:15 -070013For more of the gritty details on the process of doing development
14with the gccgo frontend,
15see <a href="https://code.google.com/p/gofrontend/source/browse/HACKING">the
16file HACKING</a> in the gofrontend repository.
Ian Lance Taylor2528f332009-11-06 14:15:41 -080017</p>
18
19<h2>Legal Prerequisites</h2>
20
21<p>
Andrew Gerrandf78d50c2012-03-05 14:31:27 +110022You must follow the <a href="/doc/contribute.html#copyright">Go copyright
Ian Lance Taylor253c1392012-02-18 11:15:52 -080023rules</a> for all changes to the gccgo frontend and the associated
24libgo library. Code that is part of GCC rather than gccgo must follow
25the general <a href="http://gcc.gnu.org/contribute.html">GCC
26contribution rules</a>.
Ian Lance Taylor2528f332009-11-06 14:15:41 -080027</p>
28
29<h2>Code</h2>
30
31<p>
Ian Lance Taylor253c1392012-02-18 11:15:52 -080032The master sources for the gccgo frontend may be found at
Ian Lance Taylor8668ac02015-06-15 11:13:57 -070033<a href="http://go.googlesource.com/gofrontend">http://go.googlesource.com/gofrontend</a>.
34They are mirrored
35at <a href="http://github.com/golang/gofrontend">http://github.com/golang/gofrontend</a>.
Ian Lance Taylor253c1392012-02-18 11:15:52 -080036The master sources are not buildable by themselves, but only in
37conjunction with GCC (in the future, other compilers may be
38supported). Changes made to the gccgo frontend are also applied to
39the GCC source code repository hosted at <code>gcc.gnu.org</code>. In
40the <code>gofrontend</code> repository, the <code>go</code> directory
41is mirrored to the <code>gcc/go/gofrontend</code> directory in the GCC
42repository, and the <code>gofrontend</code> <code>libgo</code>
43directory is mirrored to the GCC <code>libgo</code> directory. In
44addition, the <code>test</code> directory
Péter Surányi9b6ccb12015-02-06 21:44:39 +090045from <a href="//go.googlesource.com/go">the main Go repository</a>
Ian Lance Taylor253c1392012-02-18 11:15:52 -080046is mirrored to the <code>gcc/testsuite/go.test/test</code> directory
47in the GCC repository.
Ian Lance Taylor2528f332009-11-06 14:15:41 -080048</p>
49
50<p>
Ian Lance Taylor253c1392012-02-18 11:15:52 -080051Changes to these directories always flow from the master sources to
52the GCC repository. The files should never be changed in the GCC
53repository except by changing them in the master sources and mirroring
54them.
55</p>
56
57<p>
Ian Lance Taylor8668ac02015-06-15 11:13:57 -070058The gccgo frontend is written in C++.
59It follows the GNU and GCC coding standards for C++.
60In writing code for the frontend, follow the formatting of the
61surrounding code.
62Almost all GCC-specific code is not in the frontend proper and is
63instead in the GCC sources in the <code>gcc/go</code> directory.
Ian Lance Taylor253c1392012-02-18 11:15:52 -080064</p>
65
66<p>
67The run-time library for gccgo is mostly the same as the library
Péter Surányi9b6ccb12015-02-06 21:44:39 +090068in <a href="//go.googlesource.com/go">the main Go repository</a>.
Ian Lance Taylor253c1392012-02-18 11:15:52 -080069The library code in the Go repository is periodically merged into
70the <code>libgo/go</code> directory of the <code>gofrontend</code> and
71then the GCC repositories, using the shell
72script <code>libgo/merge.sh</code>. Accordingly, most library changes
73should be made in the main Go repository. The files outside
74of <code>libgo/go</code> are gccgo-specific; that said, some of the
75files in <code>libgo/runtime</code> are based on files
Russ Cox220a6de2014-09-08 00:06:45 -040076in <code>src/runtime</code> in the main Go repository.
Ian Lance Taylor2528f332009-11-06 14:15:41 -080077</p>
78
79<h2>Testing</h2>
80
81<p>
Ian Lance Taylor253c1392012-02-18 11:15:52 -080082All patches must be tested. A patch that introduces new failures is
83not acceptable.
Ian Lance Taylor2528f332009-11-06 14:15:41 -080084</p>
85
86<p>
Ian Lance Taylor253c1392012-02-18 11:15:52 -080087To run the gccgo test suite, run <code>make check-go</code> in your
88build directory. This will run various tests
89under <code>gcc/testsuite/go.*</code> and will also run
90the <code>libgo</code> testsuite. This copy of the tests from the
Rob Pikea9c69522013-04-16 14:20:06 -070091main Go repository is run using the DejaGNU script found
Ian Lance Taylor253c1392012-02-18 11:15:52 -080092in <code>gcc/testsuite/go.test/go-test.exp</code>.
Ian Lance Taylor2528f332009-11-06 14:15:41 -080093</p>
94
95<p>
Ian Lance Taylor253c1392012-02-18 11:15:52 -080096Most new tests should be submitted to the main Go repository for later
97mirroring into the GCC repository. If there is a need for specific
98tests for gccgo, they should go in
Ian Lance Taylor2528f332009-11-06 14:15:41 -080099the <code>gcc/testsuite/go.go-torture</code>
Ian Lance Taylor253c1392012-02-18 11:15:52 -0800100or <code>gcc/testsuite/go.dg</code> directories in the GCC repository.
Ian Lance Taylor2528f332009-11-06 14:15:41 -0800101</p>
102
103<h2>Submitting Changes</h2>
104
105<p>
Ian Lance Taylor8653acb2010-01-29 16:37:20 -0800106Changes to the Go frontend should follow the same process as for the
Shenghou Mad251fc32013-02-19 19:20:44 +0800107main Go repository, only for the <code>gofrontend</code> project and
Emil Hessmanddb24da2014-12-19 08:37:52 +0100108the <code>gofrontend-dev@googlegroups.com</code> mailing list
Shenghou Mad251fc32013-02-19 19:20:44 +0800109rather than the <code>go</code> project and the
110<code>golang-dev@googlegroups.com</code> mailing list. Those changes
111will then be merged into the GCC sources.
Ian Lance Taylor2528f332009-11-06 14:15:41 -0800112</p>