Skip to content

Tips on building go

Yousong Zhou edited this page Feb 2, 2016 · 2 revisions

Facts about all.bash, make.bash, run.bash

  1. They are not supposed to be run standalone
  2. all.bash sources make.bash and runs run.bash
  3. Run ./all.bash --no-clean to do incremental rebuild

How to setup env manually for building go1.5

# build cmd/dist first
export GOROOT_BOOTSTRAP=~/git-repo/build-scripts/tests_dir/install/go/goroot-1.4.3
export GOROOT="$(cd .. && pwd)"
GOROOT="$GOROOT_BOOTSTRAP" GOOS="" GOARCH="" "$GOROOT_BOOTSTRAP/bin/go" build -o cmd/dist/dist ./cmd/dist

# eval env output (-p for PATH)
eval "$(./cmd/dist/dist env -p)"

# so we can do go tool dist
mkdir -p "$GOTOOLDIR"
mv cmd/dist/dist  "$GOTOOLDIR/dist"

# prepare
eval "$(go env)"
export GOROOT
export GOHOSTOS
export CC
unset GOPATH
unset CDPATH

How to do a fast rebuild

# without the -a flag (rebuild all)
go tool dist bootstrap
CC=$CC_FOR_TARGET "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std cmd

How to run a single test

# run a single test
# go tool dist test -h for info on arguments
go tool dist test --no-rebuild --run testcshared
Clone this wiki locally