Rather than returning "", we now return "," (which is a no-op). This
ensures that the returned string always overrides DefaultGOEXPERIMENT.
This fixes a bootstrapping issue where GOROOT_BOOTSTRAP was built with
"GOEXPERIMENT=fieldtrack ./make.bash". cmd/dist sets GOEXPERIMENT=none
during bootstrapping, which was causing cmd/go to set GOEXPERIMENT=""
when executing cmd/compile; but then cmd/compile ignores the
environment variable (because it's empty) and instead uses
DefaultGOEXPERIMENT.
Fixes #47921.
Change-Id: I657ff6cdfb294a94f6a2f58c306ceed7f104416b
Reviewed-on: https://go-review.googlesource.com/c/go/+/344511
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
// GOEXPERIMENT is exactly what a user would set on the command line
// to get the set of enabled experiments.
func GOEXPERIMENT() string {
- return strings.Join(expList(&Experiment, &experimentBaseline, false), ",")
+ goexp := strings.Join(expList(&Experiment, &experimentBaseline, false), ",")
+ if goexp == "" && DefaultGOEXPERIMENT != "" {
+ goexp = "," // non-empty to override DefaultGOEXPERIMENT
+ }
+ return goexp
}
// EnabledExperiments returns a list of enabled experiments, as