github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/buildcfg/cfg.go (about)

     1  // Copyright 2021 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 buildcfg provides access to the build configuration
     6  // described by the current environment. It is for use by build tools
     7  // such as cmd/go or cmd/compile and for setting up go/build's Default context.
     8  //
     9  // Note that it does NOT provide access to the build configuration used to
    10  // build the currently-running binary. For that, use runtime.GOOS etc
    11  // as well as internal/goexperiment.
    12  package buildcfg
    13  
    14  import (
    15  	"github.com/shogo82148/std/os"
    16  )
    17  
    18  var (
    19  	GOROOT    = os.Getenv("GOROOT")
    20  	GOARCH    = envOr("GOARCH", defaultGOARCH)
    21  	GOOS      = envOr("GOOS", defaultGOOS)
    22  	GO386     = envOr("GO386", defaultGO386)
    23  	GOAMD64   = goamd64()
    24  	GOARM     = goarm()
    25  	GOARM64   = goarm64()
    26  	GOMIPS    = gomips()
    27  	GOMIPS64  = gomips64()
    28  	GOPPC64   = goppc64()
    29  	GORISCV64 = goriscv64()
    30  	GOWASM    = gowasm()
    31  	ToolTags  = toolTags()
    32  	GO_LDSO   = defaultGO_LDSO
    33  	Version   = version
    34  )
    35  
    36  // Error is one of the errors found (if any) in the build configuration.
    37  var Error error
    38  
    39  // Check exits the program with a fatal error if Error is non-nil.
    40  func Check()
    41  
    42  type Goarm64Features struct {
    43  	Version string
    44  	// Large Systems Extension
    45  	LSE bool
    46  	// ARM v8.0 Cryptographic Extension. It includes the following features:
    47  	// * FEAT_AES, which includes the AESD and AESE instructions.
    48  	// * FEAT_PMULL, which includes the PMULL, PMULL2 instructions.
    49  	// * FEAT_SHA1, which includes the SHA1* instructions.
    50  	// * FEAT_SHA256, which includes the SHA256* instructions.
    51  	Crypto bool
    52  }
    53  
    54  func (g Goarm64Features) String() string
    55  
    56  func ParseGoarm64(v string) (g Goarm64Features, e error)
    57  
    58  // Returns true if g supports giving ARM64 ISA
    59  // Note that this function doesn't accept / test suffixes (like ",lse" or ",crypto")
    60  func (g Goarm64Features) Supports(s string) bool
    61  
    62  func Getgoextlinkenabled() string
    63  
    64  // GOGOARCH returns the name and value of the GO$GOARCH setting.
    65  // For example, if GOARCH is "amd64" it might return "GOAMD64", "v2".
    66  func GOGOARCH() (name, value string)