Commit 0ba3c607 authored by Russ Cox's avatar Russ Cox

cmd/dist, go/build: make CGO_ENABLED during make.bash sticky

Per discussion on #12808, it's a bit odd that if you do

	CGO_ENABLED=0 ./make.bash

then you get a toolchain that still tries to use cgo.
So make the CGO_ENABLED setting propagate into
the resulting toolchain as the default setting for that
environment variable, like we do with other variables
like CC and GOROOT.

No reasonable way to test automatically, but I did
test by hand that after the above command, 'go env'
shows CGO_ENABLED=0; before it showed CGO_ENABLED=1.

Fixes #12808.

Change-Id: I26a2fa6cc00e73bde8af7469270b27293392ed71
Reviewed-on: https://go-review.googlesource.com/31141
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 1e28dce8
......@@ -7,6 +7,7 @@ package main
import (
"bytes"
"fmt"
"os"
"sort"
)
......@@ -85,7 +86,8 @@ func mkzcgo(dir, file string) {
"\n"+
"package build\n"+
"\n"+
"var cgoEnabled = map[string]bool{\n")
"const defaultCGO_ENABLED = %q\n\n"+
"var cgoEnabled = map[string]bool{\n", os.Getenv("CGO_ENABLED"))
for _, plat := range list {
fmt.Fprintf(&buf, "\t%q: true,\n", plat)
}
......
......@@ -272,7 +272,11 @@ func defaultContext() Context {
// (perhaps it is the stub to use in that case) should say "+build !go1.x".
c.ReleaseTags = []string{"go1.1", "go1.2", "go1.3", "go1.4", "go1.5", "go1.6", "go1.7", "go1.8"}
switch os.Getenv("CGO_ENABLED") {
env := os.Getenv("CGO_ENABLED")
if env == "" {
env = defaultCGO_ENABLED
}
switch env {
case "1":
c.CgoEnabled = true
case "0":
......
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