]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist, cmd/go: move CGO_ENABLED from 'go tool dist env' to 'go env'
authorShenghou Ma <minux.ma@gmail.com>
Fri, 9 Mar 2012 19:42:23 +0000 (03:42 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Fri, 9 Mar 2012 19:42:23 +0000 (03:42 +0800)
        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

src/cmd/dist/build.c
src/cmd/go/env.go
src/run.bash
src/sudo.bash

index d5fcfbedb30143e7ac283e50b1893508a24a779e..acd7347aa89753f743c79173e20d080a4585e56d 100644 (file)
@@ -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"))
index 804dc8e63fde50af6bee5865e53b462c259dda0e..d5b0348096c325d08845c81a5717e2160783bf6c 100644 (file)
@@ -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
 }
 
index 0e4600b0adb5b829408a66daafd38b8ee516608f..430ee76dbae617a65a4b0a1df91027d4f8123416 100755 (executable)
@@ -5,7 +5,7 @@
 
 set -e
 
-eval $(go tool dist env)
+eval $(go env)
 
 unset CDPATH   # in case user has it set
 
index 78cdb0b8a775e9c5e6a55a110cd6c02ba699a155..cccebd34277354a43629d6359106263742f83c99 100755 (executable)
@@ -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