blob: f6e5dd90205a0c66a5f86c1d54b374a7d111dc2d [file] [log] [blame]
Ian Lance Taylor6b1ed1f2013-06-20 13:21:55 -07001Some notes on development of the Go frontend
2Ian Lance Taylor
3iant@golang.org
4
5The Go frontend currently only works with GCC. I want to make it more
6portable, but that work is not complete.
7
8
9Go frontend as part of GCC
10--------------------------
11
12There is a copy of the Go frontend in the GCC source code. However,
13the Go frontend source code repository is not the GCC source code
14repository. This means that if you want to modify the Go frontend,
15you need to do some setup. This is how I do it.
16
Ian Lance Taylor8eeba3a2015-06-15 10:52:49 -070017The Go frontend sources are stored using Git hosted at
18go.googlesource.com, and mirrored on github.com. To check out the
19source code:
Ian Lance Taylor6b1ed1f2013-06-20 13:21:55 -070020
Ian Lance Taylor8eeba3a2015-06-15 10:52:49 -070021git clone https://go.googlesource.com/gofrontend
22
Tobias Klauser43f83e92020-06-25 16:56:24 +020023(or use the mirror on github: git clone https://github.com/golang/gofrontend)
Ian Lance Taylor6b1ed1f2013-06-20 13:21:55 -070024
25That gives you the frontend only. Now you need a copy of the GCC
Tobias Klauser43f83e92020-06-25 16:56:24 +020026source code. See https://gcc.gnu.org/git.html for details, or simply:
Ian Lance Taylor6b1ed1f2013-06-20 13:21:55 -070027
Tobias Klauserd65e5a22020-06-15 13:36:49 +020028git clone git://gcc.gnu.org/git/gcc
Ian Lance Taylor6b1ed1f2013-06-20 13:21:55 -070029
30The GCC source code will have a copy of the Go frontend, but because
31you want to change the Go frontend, you will need to replace that copy
32with your own. I do this using symlinks. Symlinking the Go frontend
33proper is trivial. Symlinking libgo is a bit harder, because
34convenient use of automake and autoconf requires that they be able to
35see the sources in top level of the GCC repository. So this is what I
36do:
37
38rm -rf gcc/go/gofrontend
39ln -s GOFRONTEND/go gcc/go/gofrontend
40rm -rf libgo
Ian Lance Taylord3b961d2014-01-08 13:58:47 -080041mkdir libgo
42for f in GOFRONTEND/libgo/*; do ln -s $f libgo/`basename $f`; done
Ian Lance Taylor6b1ed1f2013-06-20 13:21:55 -070043
44You can then build GCC as usual, with --enable-languages=go. The
Ian Lance Taylor8eeba3a2015-06-15 10:52:49 -070045build will use the Go frontend in your Git repository.
Ian Lance Taylor6b1ed1f2013-06-20 13:21:55 -070046
47This is all you need to build gccgo yourself and develop your own
Ian Lance Taylor8eeba3a2015-06-15 10:52:49 -070048patches. To get your patch committed, send them in using "git
49codereview mail" as described at
Tobias Klauser43f83e92020-06-25 16:56:24 +020050https://golang.org/doc/gccgo_contribute.html ; it's the same process as
Ian Lance Taylor8eeba3a2015-06-15 10:52:49 -070051changes for the regular Go repository.
Ian Lance Taylor6b1ed1f2013-06-20 13:21:55 -070052
53At present I am the only person who commits changes to the Go frontend
54repository. Because the GCC repository has a copy of the Go frontend,
Ian Lance Taylor8eeba3a2015-06-15 10:52:49 -070055I need to commit changes to both repositories. To do this, I use a
56script that copies changes from the Git repository to GCC's SVN
57repository. This script uses a file MERGE that exists only in the GCC
58repository. This is the script:
Ian Lance Taylor6b1ed1f2013-06-20 13:21:55 -070059
Ian Lance Taylor8eeba3a2015-06-15 10:52:49 -070060==================================================
Ian Lance Taylor6b1ed1f2013-06-20 13:21:55 -070061#!/bin/sh
62
Ian Lance Taylor8eeba3a2015-06-15 10:52:49 -070063set -e
Ian Lance Taylor6b1ed1f2013-06-20 13:21:55 -070064
Ian Lance Taylor8eeba3a2015-06-15 10:52:49 -070065merge="/home/iant/gcc/trunk/gcc/go/gofrontend/MERGE"
66current=`head -1 $merge`
67next=`git log ${current}.. | grep '^commit' | tail -1 | sed -e 's/^[^ ]* //'`
68
69if test "$next" = ""; then
70 echo "gosync: already up to date"
71 exit 0
72fi
73
74if git show -p $next | grep -e '^\(---\|+++\)' | fgrep 'go/'; then
75 git log -1 $next > /home/iant/gcc/trunk/svn-commit.tmp
76 git show -p $next | \
77 sed -e 's|\(^[-+][-+][-+] [ab]\)/go|\1/gcc/go/gofrontend|' | \
78 (cd /home/iant/gcc/trunk && patch -p1)
79else
80 echo "gosync: no relevant files in change $next"
81fi
82
83(echo ${next}; sed -ne '2,$p' $merge) > ${merge}.tmp
84mv ${merge}.tmp ${merge}
85==================================================
Ian Lance Taylor6b1ed1f2013-06-20 13:21:55 -070086
87(When I'm working with a GCC release branch, I have variants which do
88the same thing with my copy of the GCC release branch.)
89
Ian Lance Taylor8eeba3a2015-06-15 10:52:49 -070090Now every time I submit a change to the gofrontend repository, I run
91gosync to copy the change to my copy of the GCC repository, and the
92commit message is stored in svn-commit.tmp in the GCC repository. I
93don't automatically commit to both git and svn at once because some
94gofrontend changes require changes to other parts of GCC, and an
95automatic commit to GCC would mean that GCC was temporarily broken.
96So instead after pushing the submit button on
97go-review.googlesource.com I run "gosync; svn commit". GCC rules
98require that all GCC patches be sent to the mailing list
Ian Lance Taylor6b1ed1f2013-06-20 13:21:55 -070099gcc-patches@gcc.gnu.org with an explanation, so I do that as well when
100I run "svn commit".
101
102In summary, there are three steps to every change to the gofrontend:
Ian Lance Taylor8eeba3a2015-06-15 10:52:49 -07001031) git submit
Ian Lance Taylor6b1ed1f2013-06-20 13:21:55 -07001042) svn commit
1053) send e-mail to gcc-patches@gcc.gnu.org
106
107For the convenience of people who want to use gccgo without waiting
108for a release and without living on tip, I maintain a gccgo branch of
Baokun Lee713c4612019-02-22 18:55:36 +0800109GCC. This lives at svn://gcc.gnu.org/svn/gcc/branches/gccgo. I maintain
110it using the general GCC branch policies described at
Tobias Klauser43f83e92020-06-25 16:56:24 +0200111https://gcc.gnu.org/wiki/SvnBranch .