зеркало из https://github.com/CryptoPro/go.git
cmd/go: fail with nice error message on bad GOOS/GOARCH pair
Fixes #12272 Change-Id: I2115ec62ed4061084c482eb385a583a1c1909888 Reviewed-on: https://go-review.googlesource.com/22838 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Minux Ma <minux@golang.org>
This commit is contained in:
Родитель
30bfafc319
Коммит
b90cb3f471
|
@ -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"
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче