Some notes on development of the Go frontend Ian Lance Taylor iant@golang.org The Go frontend currently only works with GCC. I want to make it more portable, but that work is not complete. Go frontend as part of GCC -------------------------- There is a copy of the Go frontend in the GCC source code. However, the Go frontend source code repository is not the GCC source code repository. This means that if you want to modify the Go frontend, you need to do some setup. This is how I do it. The Go frontend sources are stored using Git hosted at go.googlesource.com, and mirrored on github.com. To check out the source code: git clone https://go.googlesource.com/gofrontend (or use the mirror on github: git clone https://github.com/golang/gofrontend) That gives you the frontend only. Now you need a copy of the GCC source code. See https://gcc.gnu.org/git.html for details, or simply: git clone git://gcc.gnu.org/git/gcc The GCC source code will have a copy of the Go frontend, but because you want to change the Go frontend, you will need to replace that copy with your own. I do this using symlinks. Symlinking the Go frontend proper is trivial. Symlinking libgo is a bit harder, because convenient use of automake and autoconf requires that they be able to see the sources in top level of the GCC repository. So this is what I do: rm -rf gcc/go/gofrontend ln -s GOFRONTEND/go gcc/go/gofrontend rm -rf libgo mkdir libgo for f in GOFRONTEND/libgo/*; do ln -s $f libgo/`basename $f`; done You can then build GCC as usual, with --enable-languages=go. The build will use the Go frontend in your Git repository. This is all you need to build gccgo yourself and develop your own patches. To get your patch committed, send them in using "git codereview mail" as described at https://golang.org/doc/gccgo_contribute.html ; it's the same process as changes for the regular Go repository. At present I am the only person who commits changes to the Go frontend repository. Because the GCC repository has a copy of the Go frontend, I need to commit changes to both repositories. To do this, I use a script that copies changes from the Git repository to GCC's SVN repository. This script uses a file MERGE that exists only in the GCC repository. This is the script: ================================================== #!/bin/sh set -e merge="/home/iant/gcc/trunk/gcc/go/gofrontend/MERGE" current=`head -1 $merge` next=`git log ${current}.. | grep '^commit' | tail -1 | sed -e 's/^[^ ]* //'` if test "$next" = ""; then echo "gosync: already up to date" exit 0 fi if git show -p $next | grep -e '^\(---\|+++\)' | fgrep 'go/'; then git log -1 $next > /home/iant/gcc/trunk/svn-commit.tmp git show -p $next | \ sed -e 's|\(^[-+][-+][-+] [ab]\)/go|\1/gcc/go/gofrontend|' | \ (cd /home/iant/gcc/trunk && patch -p1) else echo "gosync: no relevant files in change $next" fi (echo ${next}; sed -ne '2,$p' $merge) > ${merge}.tmp mv ${merge}.tmp ${merge} ================================================== (When I'm working with a GCC release branch, I have variants which do the same thing with my copy of the GCC release branch.) Now every time I submit a change to the gofrontend repository, I run gosync to copy the change to my copy of the GCC repository, and the commit message is stored in svn-commit.tmp in the GCC repository. I don't automatically commit to both git and svn at once because some gofrontend changes require changes to other parts of GCC, and an automatic commit to GCC would mean that GCC was temporarily broken. So instead after pushing the submit button on go-review.googlesource.com I run "gosync; svn commit". GCC rules require that all GCC patches be sent to the mailing list gcc-patches@gcc.gnu.org with an explanation, so I do that as well when I run "svn commit". In summary, there are three steps to every change to the gofrontend: 1) git submit 2) svn commit 3) send e-mail to gcc-patches@gcc.gnu.org For the convenience of people who want to use gccgo without waiting for a release and without living on tip, I maintain a gccgo branch of GCC. This lives at svn://gcc.gnu.org/svn/gcc/branches/gccgo. I maintain it using the general GCC branch policies described at https://gcc.gnu.org/wiki/SvnBranch .