// Copyright 2021 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package buildcfgimport ()// Experiment contains the toolchain experiments enabled for the// current build.//// (This is not necessarily the set of experiments the compiler itself// was built with.)//// experimentBaseline specifies the experiment flags that are enabled by// default in the current toolchain. This is, in effect, the "control"// configuration and any variation from this is an experiment.varExperiment, experimentBaseline = func() (goexperiment.Flags, goexperiment.Flags) { , , := ParseGOEXPERIMENT(GOOS, GOARCH, envOr("GOEXPERIMENT", defaultGOEXPERIMENT))if != nil {Error = }return , }()constDefaultGOEXPERIMENT = defaultGOEXPERIMENT// FramePointerEnabled enables the use of platform conventions for// saving frame pointers.//// This used to be an experiment, but now it's always enabled on// platforms that support it.//// Note: must agree with runtime.framepointer_enabled.varFramePointerEnabled = GOARCH == "amd64" || GOARCH == "arm64"// ParseGOEXPERIMENT parses a (GOOS, GOARCH, GOEXPERIMENT)// configuration tuple and returns the enabled and baseline experiment// flag sets.//// TODO(mdempsky): Move to internal/goexperiment.func (, , string) (, goexperiment.Flags, error) { := falseswitch {case"amd64", "arm64", "ppc64le", "ppc64": = true } = goexperiment.Flags{RegabiWrappers: ,RegabiReflect: ,RegabiArgs: ,PacerRedesign: true, }// Start with the statically enabled set of experiments. = // Pick up any changes to the baseline configuration from the // GOEXPERIMENT environment. This can be set at make.bash time // and overridden at build time.if != "" {// Create a map of known experiment names. := make(map[string]func(bool)) := reflect.ValueOf(&).Elem() := .Type()for := 0; < .NumField(); ++ { := .Field() [strings.ToLower(.Field().Name)] = .SetBool }// "regabi" is an alias for all working regabi // subexperiments, and not an experiment itself. Doing // this as an alias make both "regabi" and "noregabi" // do the right thing. ["regabi"] = func( bool) { .RegabiWrappers = .RegabiReflect = .RegabiArgs = }// Parse names.for , := rangestrings.Split(, ",") {if == "" {continue }if == "none" {// GOEXPERIMENT=none disables all experiment flags. // This is used by cmd/dist, which doesn't know how // to build with any experiment flags. = goexperiment.Flags{}continue } := trueifstrings.HasPrefix(, "no") { , = [2:], false } , := []if ! { = fmt.Errorf("unknown GOEXPERIMENT %s", )return } () } }// regabi is always enabled on amd64.if == "amd64" { .RegabiWrappers = true .RegabiReflect = true .RegabiArgs = true }// regabi is only supported on amd64, arm64, ppc64 and ppc64le.if ! { .RegabiReflect = false .RegabiArgs = false }// Check regabi dependencies.if .RegabiArgs && !(.RegabiWrappers && .RegabiReflect) { = fmt.Errorf("GOEXPERIMENT regabiargs requires regabiwrappers,regabireflect") }return}// expList returns the list of lower-cased experiment names for// experiments that differ from base. base may be nil to indicate no// experiments. If all is true, then include all experiment flags,// regardless of base.func (, *goexperiment.Flags, bool) []string {var []string := reflect.ValueOf().Elem()varreflect.Valueif != nil { = reflect.ValueOf().Elem() } := .Type()for := 0; < .NumField(); ++ { := strings.ToLower(.Field().Name) := .Field().Bool() := falseif != nil { = .Field().Bool() }if || != {if { = append(, ) } else { = append(, "no"+) } } }return}// GOEXPERIMENT is a comma-separated list of enabled or disabled// experiments that differ from the baseline experiment configuration.// GOEXPERIMENT is exactly what a user would set on the command line// to get the set of enabled experiments.func () string { := strings.Join(expList(&Experiment, &experimentBaseline, false), ",")if == "" && DefaultGOEXPERIMENT != "" { = ","// non-empty to override DefaultGOEXPERIMENT }return}// EnabledExperiments returns a list of enabled experiments, as// lower-cased experiment names.func () []string {returnexpList(&Experiment, nil, false)}// AllExperiments returns a list of all experiment settings.// Disabled experiments appear in the list prefixed by "no".func () []string {returnexpList(&Experiment, nil, true)}// UpdateExperiments updates the Experiment global based on a new GOARCH value.// This is only required for cmd/go, which can change GOARCH after// program startup due to use of "go env -w".func (, , string) {varerrorExperiment, experimentBaseline, = ParseGOEXPERIMENT(, , )if != nil {Error = }}
The pages are generated with Goldsv0.4.9. (GOOS=linux GOARCH=amd64)