]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: given better error when -race is used without cgo
authorShenghou Ma <minux@golang.org>
Tue, 6 Oct 2015 02:32:19 +0000 (22:32 -0400)
committerMinux Ma <minux@golang.org>
Tue, 6 Oct 2015 06:59:42 +0000 (06:59 +0000)
Fixes #12844.

Change-Id: Id51b24aae239fd2e1fb1cd0bc9fe443186301044
Reviewed-on: https://go-review.googlesource.com/15440
Reviewed-by: Andrew Gerrand <adg@golang.org>
src/cmd/go/build.go

index 54b655287a890aec51058f832cbb7b8feff4dcbb..0166e9126ba19cf93815d3994e92cb7852cc6ce4 100644 (file)
@@ -3341,6 +3341,10 @@ func raceInit() {
                fmt.Fprintf(os.Stderr, "go %s: -race is only supported on linux/amd64, freebsd/amd64, darwin/amd64 and windows/amd64\n", flag.Args()[0])
                os.Exit(2)
        }
+       if !buildContext.CgoEnabled {
+               fmt.Fprintf(os.Stderr, "go %s: -race requires cgo; enable cgo by setting CGO_ENABLED=1\n", flag.Args()[0])
+               os.Exit(2)
+       }
        buildGcflags = append(buildGcflags, "-race")
        buildLdflags = append(buildLdflags, "-race")
        if buildContext.InstallSuffix != "" {