Commit a978b1e0 authored by Shenghou Ma's avatar Shenghou Ma

misc/dist: support building statically linked toolchain.

so that we don't need worry about specifying the required
libc version (note: as cmd/go will still be dynamically
linked to libc, we still need to perform the build on OSes
with an old enough libc. But as cmd/go doesn't rely on many
libc symbols, the situation should be significantly better).

Fixes #3564.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/14261043
parent 08570458
......@@ -38,6 +38,7 @@ var (
addLabel = flag.String("label", "", "additional label to apply to file when uploading")
includeRace = flag.Bool("race", true, "build race detector packages")
versionOverride = flag.String("version", "", "override version name")
staticToolchain = flag.Bool("static", true, "try to build statically linked toolchain (only supported on ELF targets)")
username, password string // for Google Code upload
)
......@@ -106,6 +107,15 @@ var raceAvailable = []string{
"windows-amd64",
}
// The OSes that support building statically linked toolchain
// Only ELF platforms are supported.
var staticLinkAvailable = []string{
"linux",
"freebsd",
"openbsd",
"netbsd",
}
var fileRe = regexp.MustCompile(
`^(go[a-z0-9-.]+)\.(src|([a-z0-9]+)-([a-z0-9]+)(?:-([a-z0-9.]))?)\.`)
......@@ -169,6 +179,13 @@ func main() {
}
}
}
if *staticToolchain {
for _, os := range staticLinkAvailable {
if b.OS == os {
b.static = true
}
}
}
}
if err := b.Do(); err != nil {
log.Printf("%s: %v", targ, err)
......@@ -184,6 +201,7 @@ type Build struct {
Label string
root string
gopath string
static bool // if true, build statically linked toolchain
}
func (b *Build) Do() error {
......@@ -582,6 +600,9 @@ func (b *Build) env() []string {
"GOROOT_FINAL="+final,
"GOPATH="+b.gopath,
)
if b.static {
env = append(env, "GO_DISTFLAGS=-s")
}
return env
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment