1
0
mirror of https://github.com/golang/go synced 2024-11-05 15:16:11 -07:00

cmd/go: add error for cross-compiled -race builds

Race builds require C dependencies, but setting up cross-compiled cgo
builds is more complicated than just setting CGO_ENABLED, so don't
suggest that.

Fixes #37021
This commit is contained in:
Keyan Pishdadian 2020-04-25 21:51:56 -07:00
parent 09630172d4
commit cbf43c1bbb

View File

@ -16,6 +16,7 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"strings"
)
@ -84,7 +85,12 @@ func instrumentInit() {
modeFlag := "-" + mode
if !cfg.BuildContext.CgoEnabled {
if runtime.GOOS != cfg.Goos || runtime.GOARCH != cfg.Goarch {
fmt.Fprintf(os.Stderr, "go %s: %s requires cgo\n", flag.Args()[0], modeFlag)
} else {
fmt.Fprintf(os.Stderr, "go %s: %s requires cgo; enable cgo by setting CGO_ENABLED=1\n", flag.Args()[0], modeFlag)
}
base.SetExitStatus(2)
base.Exit()
}