Commit 007ee631 authored by Shenghou Ma's avatar Shenghou Ma Committed by Minux Ma

cmd/go: given better error when -race is used without cgo

Fixes #12844.

Change-Id: Id51b24aae239fd2e1fb1cd0bc9fe443186301044
Reviewed-on: https://go-review.googlesource.com/15440Reviewed-by: default avatarAndrew Gerrand <adg@golang.org>
parent 5ae12e9c
...@@ -3341,6 +3341,10 @@ func raceInit() { ...@@ -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]) 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) 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") buildGcflags = append(buildGcflags, "-race")
buildLdflags = append(buildLdflags, "-race") buildLdflags = append(buildLdflags, "-race")
if buildContext.InstallSuffix != "" { if buildContext.InstallSuffix != "" {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment