github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/internal/sys/supported.go (about) 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. 4 5 package sys 6 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 11 // the compile time. 12 func RaceDetectorSupported(goos, goarch string) bool { 13 switch goos { 14 case "linux": 15 return goarch == "amd64" || goarch == "ppc64le" || goarch == "arm64" 16 case "darwin", "freebsd", "netbsd", "windows": 17 return goarch == "amd64" 18 default: 19 return false 20 } 21 } 22 23 // MSanSupported reports whether goos/goarch supports the memory 24 // sanitizer option. There is a copy of this function in cmd/dist/test.go. 25 func MSanSupported(goos, goarch string) bool { 26 switch goos { 27 case "linux": 28 return goarch == "amd64" || goarch == "arm64" 29 default: 30 return false 31 } 32 } 33 34 // MustLinkExternal reports whether goos/goarch requires external linking. 35 func MustLinkExternal(goos, goarch string) bool { 36 switch goos { 37 case "android": 38 return true 39 case "darwin": 40 if goarch == "arm" || goarch == "arm64" { 41 return true 42 } 43 } 44 return false 45 } 46 47 // BuildModeSupported reports whether goos/goarch supports the given build mode 48 // using the given compiler. 49 func BuildModeSupported(compiler, buildmode, goos, goarch string) bool { 50 if compiler == "gccgo" { 51 return true 52 } 53 54 platform := goos + "/" + goarch 55 56 switch buildmode { 57 case "archive": 58 return true 59 60 case "c-archive": 61 // TODO(bcmills): This seems dubious. 62 // Do we really support c-archive mode on js/wasm‽ 63 return platform != "linux/ppc64" 64 65 case "c-shared": 66 switch platform { 67 case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/ppc64le", "linux/s390x", 68 "android/amd64", "android/arm", "android/arm64", "android/386", 69 "freebsd/amd64", 70 "darwin/amd64", "darwin/386", 71 "windows/amd64", "windows/386": 72 return true 73 } 74 return false 75 76 case "default": 77 return true 78 79 case "exe": 80 return true 81 82 case "pie": 83 switch platform { 84 case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x", 85 "android/amd64", "android/arm", "android/arm64", "android/386", 86 "freebsd/amd64", 87 "darwin/amd64", 88 "aix/ppc64": 89 return true 90 } 91 return false 92 93 case "shared": 94 switch platform { 95 case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x": 96 return true 97 } 98 return false 99 100 case "plugin": 101 switch platform { 102 case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x", "linux/ppc64le", 103 "android/amd64", "android/arm", "android/arm64", "android/386", 104 "darwin/amd64", 105 "freebsd/amd64": 106 return true 107 } 108 return false 109 110 default: 111 return false 112 } 113 }