Commit b90cb3f4 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

cmd/go: fail with nice error message on bad GOOS/GOARCH pair

Fixes #12272

Change-Id: I2115ec62ed4061084c482eb385a583a1c1909888
Reviewed-on: https://go-review.googlesource.com/22838Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Reviewed-by: default avatarMinux Ma <minux@golang.org>
parent 30bfafc3
......@@ -26,6 +26,7 @@ misc/cgo/stdio/run.out
misc/cgo/testso/main
src/cmd/cgo/zdefaultcc.go
src/cmd/go/zdefaultcc.go
src/cmd/go/zosarch.go
src/cmd/internal/obj/zbootstrap.go
src/go/build/zcgo.go
src/go/doc/headscan
......
......@@ -464,6 +464,7 @@ var deptab = []struct {
}{
{"cmd/go", []string{
"zdefaultcc.go",
"zosarch.go",
}},
{"runtime/internal/sys", []string{
"zversion.go",
......@@ -485,6 +486,7 @@ var gentab = []struct {
gen func(string, string)
}{
{"zdefaultcc.go", mkzdefaultcc},
{"zosarch.go", mkzosarch},
{"zversion.go", mkzversion},
{"zcgo.go", mkzcgo},
......
......@@ -23,9 +23,7 @@ import (
// It is invoked to write cmd/go/zdefaultcc.go
// but we also write cmd/cgo/zdefaultcc.go
func mkzdefaultcc(dir, file string) {
var out string
out = fmt.Sprintf(
out := fmt.Sprintf(
"// auto generated by go tool dist\n"+
"\n"+
"package main\n"+
......@@ -42,7 +40,16 @@ func mkzdefaultcc(dir, file string) {
writefile(out, file, writeSkipSame)
}
// mkzcgo writes zcgo.go for go/build package:
// mkzcgo writes zosarch.go for cmd/go.
func mkzosarch(dir, file string) {
var buf bytes.Buffer
buf.WriteString("// auto generated by go tool dist\n\n")
buf.WriteString("package main\n\n")
fmt.Fprintf(&buf, "var osArchSupportsCgo = %#v", cgoEnabled)
writefile(buf.String(), file, writeSkipSame)
}
// mkzcgo writes zcgo.go for the go/build package:
//
// package build
// var cgoEnabled = map[string]bool{}
......
......@@ -669,6 +669,12 @@ var (
func init() {
goarch = buildContext.GOARCH
goos = buildContext.GOOS
if _, ok := osArchSupportsCgo[goos+"/"+goarch]; !ok {
fmt.Fprintf(os.Stderr, "cmd/go: unsupported GOOS/GOARCH pair %s/%s\n", goos, goarch)
os.Exit(2)
}
if goos == "windows" {
exeSuffix = ".exe"
}
......
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