Compile GO source code with go

1)I’ve succesfully compiled the C version of go with $GOBIN=~/go.old.binaries
go1.4-bootstrap-20161024.tar.gz
so that I’ve the 2 binaries (go / gofmt) in ~/go.old.binaries
and I temporary set $PATH to find them from anywhere
having “which go” : ~/go.old.binaries/go

Now I clone the go source code (written in go).
Which is supposed to be the command to compile with my new fresh go version of step 1)

should it still be ./all.bash
or make -f Make.dist verbose ?

You need to set $GOROOT_BOOTSTRAP to your 1.4 bootstrap environment, then compile newer Go as usual. This is all fully documented here: https://golang.org/doc/install/source

Thanks.
Yes, I read that page and even followed those steps, still I consider those instructions misleading
and not clearing say what to do if you want to keep up-to-date your go version every, say, 2 days
with a normal “git pull”.
It would seem that on each “git pull” you need to have 2-full-separate-“go tree” the “active/running/
(old) bootstrap version” and the new cloned source repo. Once the new go is compiled you must
overwrite the previous “bootstrap” and so on.

Doing like that, I can have what I wanted. But it seems overkilling what I was expecting to be as simple as:

  1. git pull # retrieve last commits
  2. cd ./src && ./all.bash # recompile everything (using binaries in ~/go/)
  3. cp …/bin/* ~/go/ # replace binaries in ~/go/

You’re doing something different than that page is describing. To summarize, what you need to do if you just want to keep up to date with the source continuously;

  • Get one binary version of Go as a bootstrap. This could be the latest 1.4 or the latest 1.7 or the 1.8 beta - it doesn’t matter as long as it’s a Go compiler. Extract it into, for example, /usr/local/go1.7.4.
  • Download the source (or git clone it) into, for example, /usr/local/go-tip.

You now have one binary version of Go, and the source. Now compile the source with the bootstrap compiler:

$ export GOROOT_BOOTSTRAP=/usr/local/go1.7.4
$ cd /usr/local/go-tip/src
$ ./all.bash

That’s all. The procedure is the same after a git pull. There is no need to rebuild the bootstrap compiler, and it won’t rebuild more than necessary.

Add /usr/local/go-tip/bin to your $PATH or symlink the binaries to somewhere. Do not set $GOROOT.

3 Likes

Ok, thank you very much

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.