github.com/kidsbmilk/gofronted_all@v0.0.0-20220701224323-6479d5976c5d/HACKING (about) 1 Some notes on development of the Go frontend 2 Ian Lance Taylor 3 iant@golang.org 4 5 The Go frontend currently only works with GCC. I want to make it more 6 portable, but that work is not complete. 7 8 9 Go frontend as part of GCC 10 -------------------------- 11 12 There is a copy of the Go frontend in the GCC source code. However, 13 the Go frontend source code repository is not the GCC source code 14 repository. This means that if you want to modify the Go frontend, 15 you need to do some setup. This is how I do it. 16 17 The Go frontend sources are stored using Git hosted at 18 go.googlesource.com, and mirrored on github.com. To check out the 19 source code: 20 21 git clone https://go.googlesource.com/gofrontend 22 23 (or use the mirror on github: git clone https://github.com/golang/gofrontend) 24 25 That gives you the frontend only. Now you need a copy of the GCC 26 source code. See https://gcc.gnu.org/git.html for details, or simply: 27 28 git clone git://gcc.gnu.org/git/gcc 29 30 The GCC source code will have a copy of the Go frontend, but because 31 you want to change the Go frontend, you will need to replace that copy 32 with your own. I do this using symlinks. Symlinking the Go frontend 33 proper is trivial. Symlinking libgo is a bit harder, because 34 convenient use of automake and autoconf requires that they be able to 35 see the sources in top level of the GCC repository. So this is what I 36 do: 37 38 rm -rf gcc/go/gofrontend 39 ln -s GOFRONTEND/go gcc/go/gofrontend 40 rm -rf libgo 41 mkdir libgo 42 for f in GOFRONTEND/libgo/*; do ln -s $f libgo/`basename $f`; done 43 44 You can then build GCC as usual, with --enable-languages=go. The 45 build will use the Go frontend in your Git repository. 46 47 This is all you need to build gccgo yourself and develop your own 48 patches. To get your patch committed, send them in using "git 49 codereview mail" as described at 50 https://golang.org/doc/gccgo_contribute.html ; it's the same process as 51 changes for the regular Go repository. 52 53 At present I am the only person who commits changes to the Go frontend 54 repository. Because the GCC repository has a copy of the Go frontend, 55 I need to commit changes to both repositories. To do this, I use a 56 script that copies changes from the Git repository to GCC's SVN 57 repository. This script uses a file MERGE that exists only in the GCC 58 repository. This is the script: 59 60 ================================================== 61 #!/bin/sh 62 63 set -e 64 65 merge="/home/iant/gcc/trunk/gcc/go/gofrontend/MERGE" 66 current=`head -1 $merge` 67 next=`git log ${current}.. | grep '^commit' | tail -1 | sed -e 's/^[^ ]* //'` 68 69 if test "$next" = ""; then 70 echo "gosync: already up to date" 71 exit 0 72 fi 73 74 if 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) 79 else 80 echo "gosync: no relevant files in change $next" 81 fi 82 83 (echo ${next}; sed -ne '2,$p' $merge) > ${merge}.tmp 84 mv ${merge}.tmp ${merge} 85 ================================================== 86 87 (When I'm working with a GCC release branch, I have variants which do 88 the same thing with my copy of the GCC release branch.) 89 90 Now every time I submit a change to the gofrontend repository, I run 91 gosync to copy the change to my copy of the GCC repository, and the 92 commit message is stored in svn-commit.tmp in the GCC repository. I 93 don't automatically commit to both git and svn at once because some 94 gofrontend changes require changes to other parts of GCC, and an 95 automatic commit to GCC would mean that GCC was temporarily broken. 96 So instead after pushing the submit button on 97 go-review.googlesource.com I run "gosync; svn commit". GCC rules 98 require that all GCC patches be sent to the mailing list 99 gcc-patches@gcc.gnu.org with an explanation, so I do that as well when 100 I run "svn commit". 101 102 In summary, there are three steps to every change to the gofrontend: 103 1) git submit 104 2) svn commit 105 3) send e-mail to gcc-patches@gcc.gnu.org 106 107 For the convenience of people who want to use gccgo without waiting 108 for a release and without living on tip, I maintain a gccgo branch of 109 GCC. This lives at svn://gcc.gnu.org/svn/gcc/branches/gccgo. I maintain 110 it using the general GCC branch policies described at 111 https://gcc.gnu.org/wiki/SvnBranch .