supported.go 2.9 KB

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