1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // RaceDetectorSupported reports whether goos/goarch supports the race
8 // detector. There is a copy of this function in cmd/dist/test.go.
9 // Race detector only supports 48-bit VMA on arm64. But it will always
10 // return true for arm64, because we don't have VMA size information during
12 func RaceDetectorSupported(goos, goarch string) bool {
15 return goarch == "amd64" || goarch == "ppc64le" || goarch == "arm64" || goarch == "s390x"
17 return goarch == "amd64" || goarch == "arm64"
18 case "freebsd", "netbsd", "openbsd", "windows":
19 return goarch == "amd64"
25 // MSanSupported reports whether goos/goarch supports the memory
27 func MSanSupported(goos, goarch string) bool {
30 return goarch == "amd64" || goarch == "arm64"
32 return goarch == "amd64"
38 // ASanSupported reports whether goos/goarch supports the address
40 func ASanSupported(goos, goarch string) bool {
43 return goarch == "arm64" || goarch == "amd64" || goarch == "riscv64" || goarch == "ppc64le"
49 // FuzzSupported reports whether goos/goarch supports fuzzing
50 // ('go test -fuzz=.').
51 func FuzzSupported(goos, goarch string) bool {
53 case "darwin", "freebsd", "linux", "windows":
60 // FuzzInstrumented reports whether fuzzing on goos/goarch uses coverage
61 // instrumentation. (FuzzInstrumented implies FuzzSupported.)
62 func FuzzInstrumented(goos, goarch string) bool {
64 case "amd64", "arm64":
65 // TODO(#14565): support more architectures.
66 return FuzzSupported(goos, goarch)
72 // MustLinkExternal reports whether goos/goarch requires external linking
73 // with or without cgo dependencies.
74 func MustLinkExternal(goos, goarch string, withCgo bool) bool {
78 "mips", "mipsle", "mips64", "mips64le",
80 // Internally linking cgo is incomplete on some architectures.
81 // https://go.dev/issue/14449
84 if goos == "windows" {
85 // windows/arm64 internal linking is not implemented.
89 // Big Endian PPC64 cgo internal linking is not implemented for aix or linux.
90 // https://go.dev/issue/8912
98 // It seems that on Dragonfly thread local storage is
99 // set up by the dynamic linker, so internal cgo linking
100 // doesn't work. Test case is "go test runtime/cgo".
107 if goarch != "arm64" {
111 if goarch == "arm64" {
118 // BuildModeSupported reports whether goos/goarch supports the given build mode
119 // using the given compiler.
120 // There is a copy of this function in cmd/dist/test.go.
121 func BuildModeSupported(compiler, buildmode, goos, goarch string) bool {
122 if compiler == "gccgo" {
126 platform := goos + "/" + goarch
127 if _, ok := osArchSupportsCgo[platform]; !ok {
128 return false // platform unrecognized
137 case "aix", "darwin", "ios", "windows":
141 case "386", "amd64", "arm", "armbe", "arm64", "arm64be", "loong64", "ppc64le", "riscv64", "s390x":
142 // linux/ppc64 not supported because it does
143 // not support external linking mode yet.
146 // Other targets do not support -shared,
148 // cmd/compile/internal/base/flag.go.
149 // For c-archive the Go tool passes -shared,
150 // so that the result is suitable for inclusion
151 // in a PIE or shared library.
155 return goarch == "amd64"
161 case "linux/amd64", "linux/arm", "linux/arm64", "linux/loong64", "linux/386", "linux/ppc64le", "linux/riscv64", "linux/s390x",
162 "android/amd64", "android/arm", "android/arm64", "android/386",
164 "darwin/amd64", "darwin/arm64",
165 "windows/amd64", "windows/386", "windows/arm64":
178 case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/loong64", "linux/ppc64le", "linux/riscv64", "linux/s390x",
179 "android/amd64", "android/arm", "android/arm64", "android/386",
181 "darwin/amd64", "darwin/arm64",
182 "ios/amd64", "ios/arm64",
184 "windows/386", "windows/amd64", "windows/arm", "windows/arm64":
191 case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x":
198 case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x", "linux/ppc64le",
199 "android/amd64", "android/386",
200 "darwin/amd64", "darwin/arm64",
211 func InternalLinkPIESupported(goos, goarch string) bool {
212 switch goos + "/" + goarch {
213 case "android/arm64",
214 "darwin/amd64", "darwin/arm64",
215 "linux/amd64", "linux/arm64", "linux/ppc64le",
216 "windows/386", "windows/amd64", "windows/arm", "windows/arm64":
222 // DefaultPIE reports whether goos/goarch produces a PIE binary when using the
223 // "default" buildmode. On Windows this is affected by -race,
224 // so force the caller to pass that in to centralize that choice.
225 func DefaultPIE(goos, goarch string, isRace bool) bool {
227 case "android", "ios":
231 // PIE is not supported with -race on windows;
232 // see https://go.dev/cl/416174.
237 return goarch == "arm64"
242 // CgoSupported reports whether goos/goarch supports cgo.
243 func CgoSupported(goos, goarch string) bool {
244 return osArchSupportsCgo[goos+"/"+goarch]
247 // ExecutableHasDWARF reports whether the linked executable includes DWARF
248 // symbols on goos/goarch.
249 func ExecutableHasDWARF(goos, goarch string) bool {