aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShenghou Ma <minux@golang.org>2015-10-05 22:32:19 -0400
committerMinux Ma <minux@golang.org>2015-10-06 06:59:42 +0000
commit007ee631d6e0fa27973fd9f40f8fbae98547181a (patch)
treebce665a129826200d89926ce9fba8271ad629907 /src
parent5ae12e9c718b2f64289bd260c6d77f601f6254c3 (diff)
downloadgo-007ee631d6e0fa27973fd9f40f8fbae98547181a.tar.xz
cmd/go: given better error when -race is used without cgo
Fixes #12844. Change-Id: Id51b24aae239fd2e1fb1cd0bc9fe443186301044 Reviewed-on: https://go-review.googlesource.com/15440 Reviewed-by: Andrew Gerrand <adg@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/build.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go
index 54b655287a..0166e9126b 100644
--- a/src/cmd/go/build.go
+++ b/src/cmd/go/build.go
@@ -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 != "" {