mirror of
https://github.com/golang/go
synced 2024-11-21 22:44:40 -07:00
cmd/dist, cmd/go: move CGO_ENABLED from 'go tool dist env' to 'go env'
So that we don't duplicate knowledge about which OS/ARCH combination supports cgo. Also updated src/run.bash and src/sudo.bash to use 'go env'. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5792055
This commit is contained in:
parent
1e374502f4
commit
6d4da06d36
18
src/cmd/dist/build.c
vendored
18
src/cmd/dist/build.c
vendored
@ -52,19 +52,6 @@ static char *okgoos[] = {
|
||||
"windows",
|
||||
};
|
||||
|
||||
// The known cgo-enabled combinations.
|
||||
// This list is also known to ../../pkg/go/build/build.go.
|
||||
static char *okcgo[] = {
|
||||
"darwin/386",
|
||||
"darwin/amd64",
|
||||
"linux/386",
|
||||
"linux/amd64",
|
||||
"freebsd/386",
|
||||
"freebsd/amd64",
|
||||
"windows/386",
|
||||
"windows/amd64",
|
||||
};
|
||||
|
||||
static void rmworkdir(void);
|
||||
|
||||
// find reports the first index of p in l[0:n], or else -1.
|
||||
@ -1321,11 +1308,6 @@ cmdenv(int argc, char **argv)
|
||||
xprintf(format, "GOTOOLDIR", tooldir);
|
||||
xprintf(format, "GOCHAR", gochar);
|
||||
|
||||
if(find(bprintf(&b, "%s/%s", goos, goarch), okcgo, nelem(okcgo)) >= 0)
|
||||
xprintf(format, "CGO_ENABLED", "1");
|
||||
else
|
||||
xprintf(format, "CGO_ENABLED", "0");
|
||||
|
||||
if(pflag) {
|
||||
sep = ":";
|
||||
if(streq(gohostos, "windows"))
|
||||
|
@ -45,6 +45,12 @@ func mkEnv() []envVar {
|
||||
{"GOGCCFLAGS", strings.Join(b.gccCmd(".")[3:], " ")},
|
||||
}
|
||||
|
||||
if buildContext.CgoEnabled {
|
||||
env = append(env, envVar{"CGO_ENABLED", "1"})
|
||||
} else {
|
||||
env = append(env, envVar{"CGO_ENABLED", "0"})
|
||||
}
|
||||
|
||||
return env
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
eval $(go tool dist env)
|
||||
eval $(go env)
|
||||
|
||||
unset CDPATH # in case user has it set
|
||||
|
||||
|
@ -17,7 +17,7 @@ if [[ ! -d /usr/local/bin ]]; then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
eval $(go tool dist env)
|
||||
eval $(go env)
|
||||
cd $(dirname $0)
|
||||
for i in prof cov
|
||||
do
|
||||
|
Loading…
Reference in New Issue
Block a user