Skip to content

Commit 6d4da06

Browse files
committed
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
1 parent 1e37450 commit 6d4da06

4 files changed

Lines changed: 8 additions & 20 deletions

File tree

src/cmd/dist/build.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,6 @@ static char *okgoos[] = {
5252
"windows",
5353
};
5454

55-
// The known cgo-enabled combinations.
56-
// This list is also known to ../../pkg/go/build/build.go.
57-
static char *okcgo[] = {
58-
"darwin/386",
59-
"darwin/amd64",
60-
"linux/386",
61-
"linux/amd64",
62-
"freebsd/386",
63-
"freebsd/amd64",
64-
"windows/386",
65-
"windows/amd64",
66-
};
67-
6855
static void rmworkdir(void);
6956

7057
// find reports the first index of p in l[0:n], or else -1.
@@ -1321,11 +1308,6 @@ cmdenv(int argc, char **argv)
13211308
xprintf(format, "GOTOOLDIR", tooldir);
13221309
xprintf(format, "GOCHAR", gochar);
13231310

1324-
if(find(bprintf(&b, "%s/%s", goos, goarch), okcgo, nelem(okcgo)) >= 0)
1325-
xprintf(format, "CGO_ENABLED", "1");
1326-
else
1327-
xprintf(format, "CGO_ENABLED", "0");
1328-
13291311
if(pflag) {
13301312
sep = ":";
13311313
if(streq(gohostos, "windows"))

src/cmd/go/env.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ func mkEnv() []envVar {
4545
{"GOGCCFLAGS", strings.Join(b.gccCmd(".")[3:], " ")},
4646
}
4747

48+
if buildContext.CgoEnabled {
49+
env = append(env, envVar{"CGO_ENABLED", "1"})
50+
} else {
51+
env = append(env, envVar{"CGO_ENABLED", "0"})
52+
}
53+
4854
return env
4955
}
5056

src/run.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
set -e
77

8-
eval $(go tool dist env)
8+
eval $(go env)
99

1010
unset CDPATH # in case user has it set
1111

src/sudo.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if [[ ! -d /usr/local/bin ]]; then
1717
exit 2
1818
fi
1919

20-
eval $(go tool dist env)
20+
eval $(go env)
2121
cd $(dirname $0)
2222
for i in prof cov
2323
do

0 commit comments

Comments
 (0)