Black Lives Matter. Support the Equal Justice Initiative.

Source file src/cmd/internal/sys/supported.go

Documentation: cmd/internal/sys

     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":
    17  		return goarch == "amd64" || goarch == "arm64"
    18  	case "freebsd", "netbsd", "openbsd", "windows":
    19  		return goarch == "amd64"
    20  	default:
    21  		return false
    22  	}
    23  }
    24  
    25  // MSanSupported reports whether goos/goarch supports the memory
    26  // sanitizer option.
    27  // There is a copy of this function in misc/cgo/testsanitizers/cc_test.go.
    28  func MSanSupported(goos, goarch string) bool {
    29  	switch goos {
    30  	case "linux":
    31  		return goarch == "amd64" || goarch == "arm64"
    32  	default:
    33  		return false
    34  	}
    35  }
    36  
    37  // MustLinkExternal reports whether goos/goarch requires external linking.
    38  // (This is the opposite of internal/testenv.CanInternalLink. Keep them in sync.)
    39  func MustLinkExternal(goos, goarch string) bool {
    40  	switch goos {
    41  	case "android":
    42  		if goarch != "arm64" {
    43  			return true
    44  		}
    45  	case "ios":
    46  		if goarch == "arm64" {
    47  			return true
    48  		}
    49  	}
    50  	return false
    51  }
    52  
    53  // BuildModeSupported reports whether goos/goarch supports the given build mode
    54  // using the given compiler.
    55  func BuildModeSupported(compiler, buildmode, goos, goarch string) bool {
    56  	if compiler == "gccgo" {
    57  		return true
    58  	}
    59  
    60  	platform := goos + "/" + goarch
    61  
    62  	switch buildmode {
    63  	case "archive":
    64  		return true
    65  
    66  	case "c-archive":
    67  		// TODO(bcmills): This seems dubious.
    68  		// Do we really support c-archive mode on js/wasm‽
    69  		return platform != "linux/ppc64"
    70  
    71  	case "c-shared":
    72  		switch platform {
    73  		case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/ppc64le", "linux/s390x",
    74  			"android/amd64", "android/arm", "android/arm64", "android/386",
    75  			"freebsd/amd64",
    76  			"darwin/amd64", "darwin/arm64",
    77  			"windows/amd64", "windows/386", "windows/arm64":
    78  			return true
    79  		}
    80  		return false
    81  
    82  	case "default":
    83  		return true
    84  
    85  	case "exe":
    86  		return true
    87  
    88  	case "pie":
    89  		switch platform {
    90  		case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/riscv64", "linux/s390x",
    91  			"android/amd64", "android/arm", "android/arm64", "android/386",
    92  			"freebsd/amd64",
    93  			"darwin/amd64", "darwin/arm64",
    94  			"ios/amd64", "ios/arm64",
    95  			"aix/ppc64",
    96  			"windows/386", "windows/amd64", "windows/arm":
    97  			return true
    98  		}
    99  		return false
   100  
   101  	case "shared":
   102  		switch platform {
   103  		case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x":
   104  			return true
   105  		}
   106  		return false
   107  
   108  	case "plugin":
   109  		switch platform {
   110  		case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x", "linux/ppc64le",
   111  			"android/amd64", "android/arm", "android/arm64", "android/386",
   112  			"darwin/amd64", "darwin/arm64",
   113  			"freebsd/amd64":
   114  			return true
   115  		}
   116  		return false
   117  
   118  	default:
   119  		return false
   120  	}
   121  }
   122  
   123  func InternalLinkPIESupported(goos, goarch string) bool {
   124  	switch goos + "/" + goarch {
   125  	case "darwin/amd64", "darwin/arm64",
   126  		"linux/amd64", "linux/arm64",
   127  		"android/arm64",
   128  		"windows-amd64", "windows-386", "windows-arm":
   129  		return true
   130  	}
   131  	return false
   132  }
   133  

View as plain text