|
func (t *tester) supportedBuildmode(mode string) bool { |
|
pair := goos + "-" + goarch |
|
switch mode { |
|
case "c-archive": |
|
if !t.extLink() { |
|
return false |
|
} |
|
switch pair { |
|
case "aix-ppc64", |
|
"darwin-amd64", "darwin-arm64", "ios-arm64", |
|
"linux-amd64", "linux-386", "linux-ppc64le", "linux-s390x", |
|
"freebsd-amd64", |
|
"windows-amd64", "windows-386": |
|
return true |
|
} |
|
return false |
|
case "c-shared": |
|
switch pair { |
|
case "linux-386", "linux-amd64", "linux-arm", "linux-arm64", "linux-ppc64le", "linux-s390x", |
|
"darwin-amd64", "darwin-arm64", |
|
"freebsd-amd64", |
|
"android-arm", "android-arm64", "android-386", |
|
"windows-amd64", "windows-386": |
|
return true |
|
} |
|
return false |
|
case "shared": |
|
switch pair { |
|
case "linux-386", "linux-amd64", "linux-arm", "linux-arm64", "linux-ppc64le", "linux-s390x": |
|
return true |
|
} |
|
return false |
|
case "plugin": |
|
// linux-arm64 is missing because it causes the external linker |
|
// to crash, see https://golang.org/issue/17138 |
|
switch pair { |
|
case "linux-386", "linux-amd64", "linux-arm", "linux-s390x", "linux-ppc64le": |
|
return true |
|
case "darwin-amd64", "darwin-arm64": |
|
return true |
|
case "freebsd-amd64": |
|
return true |
|
} |
|
return false |
|
case "pie": |
|
switch pair { |
|
case "aix/ppc64", |
|
"linux-386", "linux-amd64", "linux-arm", "linux-arm64", "linux-ppc64le", "linux-riscv64", "linux-s390x", |
|
"android-amd64", "android-arm", "android-arm64", "android-386": |
|
return true |
|
case "darwin-amd64", "darwin-arm64": |
|
return true |
|
case "windows-amd64", "windows-386", "windows-arm": |
|
return true |
|
} |
|
return false |
|
|
|
default: |
|
fatalf("internal error: unknown buildmode %s", mode) |
|
return false |
|
} |
|
} |
(*cmd/dist.tester).supportedBuildmodecontains a large switch that determines whether a given buildmode is supported for a givenGOOS/GOARCH:go/src/cmd/dist/test.go
Lines 977 to 1038 in fa90aac
That switch nearly exactly duplicates the one in
cmd/internal/sys.BuildModeSupported, which was itself extracted from a portion ofcmd/go/internal/work.buildModeInit.cmd/distshould be changed to use (instead of duplicating) the function fromcmd/internal/sys.