aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/dist/test.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2023-02-10 14:47:07 -0800
committerGopher Robot <gobot@golang.org>2023-02-13 19:16:13 +0000
commit505325cf3027f2f2c5be47426867183b935ac85e (patch)
treeee98abadba1067682aafe15ef10c4f17a0c59f4f /src/cmd/dist/test.go
parent261fe25c83a94fc3defe064baed3944cd3d16959 (diff)
downloadgo-505325cf3027f2f2c5be47426867183b935ac85e.tar.gz
go-505325cf3027f2f2c5be47426867183b935ac85e.zip
cmd/dist: use a copy of platform.BuildModeSupported
The dist tool already includes a similar duplicate of BuildModeSupported. Replace it with an exact copy, to make it easier to maintain going forward. Change-Id: Id14a6c5a48f92d843e02218d87cc62c6b001923b Reviewed-on: https://go-review.googlesource.com/c/go/+/467495 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/cmd/dist/test.go')
-rw-r--r--src/cmd/dist/test.go161
1 files changed, 93 insertions, 68 deletions
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index 4395d3a33b..bc58f0936b 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -1136,79 +1136,14 @@ func (t *tester) internalLinkPIE() bool {
// supportedBuildMode reports whether the given build mode is supported.
func (t *tester) supportedBuildmode(mode string) bool {
- pair := goos + "-" + goarch
switch mode {
- case "c-archive":
- if !t.extLink() {
- return false
- }
- switch goos {
- case "aix", "darwin", "ios", "windows":
- return true
- case "linux":
- switch goarch {
- case "386", "amd64", "arm", "armbe", "arm64", "arm64be", "ppc64", "ppc64le", "riscv64", "s390x":
- return true
- default:
- // Other targets do not support -shared,
- // per ParseFlags in
- // cmd/compile/internal/base/flag.go.
- // For c-archive the Go tool passes -shared,
- // so that the result is suitable for inclusion
- // in a PIE or shared library.
- return false
- }
- case "freebsd":
- return goarch == "amd64"
- }
- return false
- case "c-shared":
- switch pair {
- case "linux-386", "linux-amd64", "linux-arm", "linux-arm64", "linux-ppc64le", "linux-riscv64", "linux-s390x",
- "darwin-amd64", "darwin-arm64",
- "freebsd-amd64",
- "android-arm", "android-arm64", "android-386", "android-amd64",
- "windows-amd64", "windows-386", "windows-arm64":
- 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":
- switch pair {
- case "linux-386", "linux-amd64", "linux-arm", "linux-arm64", "linux-s390x", "linux-ppc64le":
- return true
- case "android-386", "android-amd64":
- 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", "ios-amd64", "ios-arm64":
- return true
- case "windows-amd64", "windows-386", "windows-arm", "windows-arm64":
- return true
- case "freebsd-amd64":
- return true
- }
- return false
-
+ case "c-archive", "c-shared", "shared", "plugin", "pie":
default:
fatalf("internal error: unknown buildmode %s", mode)
return false
}
+
+ return buildModeSupported("gc", mode, goos, goarch)
}
func (t *tester) registerCgoTests() {
@@ -1737,6 +1672,96 @@ func raceDetectorSupported(goos, goarch string) bool {
}
}
+// buildModeSupports is a copy of the function
+// internal/platform.BuildModeSupported, which can't be used here
+// because cmd/dist can not import internal packages during bootstrap.
+func buildModeSupported(compiler, buildmode, goos, goarch string) bool {
+ if compiler == "gccgo" {
+ return true
+ }
+
+ platform := goos + "/" + goarch
+
+ switch buildmode {
+ case "archive":
+ return true
+
+ case "c-archive":
+ switch goos {
+ case "aix", "darwin", "ios", "windows":
+ return true
+ case "linux":
+ switch goarch {
+ case "386", "amd64", "arm", "armbe", "arm64", "arm64be", "ppc64le", "riscv64", "s390x":
+ // linux/ppc64 not supported because it does
+ // not support external linking mode yet.
+ return true
+ default:
+ // Other targets do not support -shared,
+ // per ParseFlags in
+ // cmd/compile/internal/base/flag.go.
+ // For c-archive the Go tool passes -shared,
+ // so that the result is suitable for inclusion
+ // in a PIE or shared library.
+ return false
+ }
+ case "freebsd":
+ return goarch == "amd64"
+ }
+ return false
+
+ case "c-shared":
+ switch platform {
+ case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/ppc64le", "linux/riscv64", "linux/s390x",
+ "android/amd64", "android/arm", "android/arm64", "android/386",
+ "freebsd/amd64",
+ "darwin/amd64", "darwin/arm64",
+ "windows/amd64", "windows/386", "windows/arm64":
+ return true
+ }
+ return false
+
+ case "default":
+ return true
+
+ case "exe":
+ return true
+
+ case "pie":
+ switch platform {
+ case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/riscv64", "linux/s390x",
+ "android/amd64", "android/arm", "android/arm64", "android/386",
+ "freebsd/amd64",
+ "darwin/amd64", "darwin/arm64",
+ "ios/amd64", "ios/arm64",
+ "aix/ppc64",
+ "windows/386", "windows/amd64", "windows/arm", "windows/arm64":
+ return true
+ }
+ return false
+
+ case "shared":
+ switch platform {
+ case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x":
+ return true
+ }
+ return false
+
+ case "plugin":
+ switch platform {
+ case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x", "linux/ppc64le",
+ "android/amd64", "android/386",
+ "darwin/amd64", "darwin/arm64",
+ "freebsd/amd64":
+ return true
+ }
+ return false
+
+ default:
+ return false
+ }
+}
+
// isUnsupportedVMASize reports whether the failure is caused by an unsupported
// VMA for the race detector (for example, running the race detector on an
// arm64 machine configured with 39-bit VMA)