diff --git a/src/cmd/internal/objabi/exp.go b/src/cmd/internal/objabi/exp.go index eaa8620807..48201ae5ea 100644 --- a/src/cmd/internal/objabi/exp.go +++ b/src/cmd/internal/objabi/exp.go @@ -18,7 +18,7 @@ import ( // // (This is not necessarily the set of experiments the compiler itself // was built with.) -var Experiment goexperiment.Flags +var Experiment goexperiment.Flags = parseExperiments() // FramePointerEnabled enables the use of platform conventions for // saving frame pointers. @@ -29,9 +29,9 @@ var Experiment goexperiment.Flags // Note: must agree with runtime.framepointer_enabled. var FramePointerEnabled = GOARCH == "amd64" || GOARCH == "arm64" -func init() { - // Start with the baseline configuration. - Experiment = goexperiment.BaselineFlags +func parseExperiments() goexperiment.Flags { + // Start with the statically enabled set of experiments. + flags := goexperiment.BaselineFlags // Pick up any changes to the baseline configuration from the // GOEXPERIMENT environment. This can be set at make.bash time @@ -41,7 +41,7 @@ func init() { if env != "" { // Create a map of known experiment names. names := make(map[string]reflect.Value) - rv := reflect.ValueOf(&Experiment).Elem() + rv := reflect.ValueOf(&flags).Elem() rt := rv.Type() for i := 0; i < rt.NumField(); i++ { field := rv.Field(i) @@ -56,7 +56,7 @@ func init() { if f == "none" { // GOEXPERIMENT=none restores the baseline configuration. // (This is useful for overriding make.bash-time settings.) - Experiment = goexperiment.BaselineFlags + flags = goexperiment.BaselineFlags continue } val := true @@ -74,29 +74,30 @@ func init() { // regabi is only supported on amd64. if GOARCH != "amd64" { - Experiment.Regabi = false - Experiment.RegabiWrappers = false - Experiment.RegabiG = false - Experiment.RegabiReflect = false - Experiment.RegabiDefer = false - Experiment.RegabiArgs = false + flags.Regabi = false + flags.RegabiWrappers = false + flags.RegabiG = false + flags.RegabiReflect = false + flags.RegabiDefer = false + flags.RegabiArgs = false } // Setting regabi sets working sub-experiments. - if Experiment.Regabi { - Experiment.RegabiWrappers = true - Experiment.RegabiG = true - Experiment.RegabiReflect = true - Experiment.RegabiDefer = true + if flags.Regabi { + flags.RegabiWrappers = true + flags.RegabiG = true + flags.RegabiReflect = true + flags.RegabiDefer = true // Not ready yet: - //Experiment.RegabiArgs = true + //flags.RegabiArgs = true } // Check regabi dependencies. - if Experiment.RegabiG && !Experiment.RegabiWrappers { + if flags.RegabiG && !flags.RegabiWrappers { panic("GOEXPERIMENT regabig requires regabiwrappers") } - if Experiment.RegabiArgs && !(Experiment.RegabiWrappers && Experiment.RegabiG && Experiment.RegabiReflect && Experiment.RegabiDefer) { + if flags.RegabiArgs && !(flags.RegabiWrappers && flags.RegabiG && flags.RegabiReflect && flags.RegabiDefer) { panic("GOEXPERIMENT regabiargs requires regabiwrappers,regabig,regabireflect,regabidefer") } + return flags } // expList returns the list of lower-cased experiment names for