因为业务上的需求,架构师改了hack了一下golang的源码,放出一个patch文件,给源码打了patch之后,需要重新编译go源码,
我是用brew
安装的golang, 先用go env
看看
➜ ~ go env
GOARCH="amd64"
GOBIN="/Users/mac/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mac/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.7.5/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.7.5/libexec/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/w6/jggc8dbd719568_t2lfr2lbh0000gn/T/go-build024499459=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
锁定了源码的路径:/usr/local/Cellar/go/1.7.5/libexec
➜ ~ cd /usr/local/Cellar/go/1.7.5/libexec
➜ libexec ls
CONTRIBUTING.md PATENTS api doc goid.patch misc robots.txt test
CONTRIBUTORS VERSION bin favicon.ico lib pkg src
➜ libexec cd src
➜ src ./all.bash
##### Building Go bootstrap tool.
cmd/dist
ERROR: Cannot find /Users/mac/go1.4/bin/go.
Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.
Go从1.5版本开始实现“自举”(Bootstrap),也就是用Go来实现Go、用Go来编译Go,因此这里的意思是系统默认用go1.4来编译golang,
但是我的系统里面并没有go1.4,这里偷个懒
➜ cp -r /usr/local/Cellar/go/1.7.5/libexec /Users/mac/go1.4
➜ cd /usr/local/Cellar/go/1.7.5/libexec/src
➜ src ./all.bash
##### Building Go bootstrap tool.
cmd/dist
##### Building Go toolchain using /Users/mac/go1.4.
bootstrap/internal/sys
bootstrap/compile/internal/big
bootstrap/internal/bio
bootstrap/asm/internal/flags
bootstrap/internal/obj
bootstrap/internal/gcprog
bootstrap/internal/obj/arm
bootstrap/internal/obj/arm64
...
等待编译测试完成即可。
网友评论