From: Matthew Dempsky Date: Mon, 23 Aug 2021 18:40:56 +0000 (-0700) Subject: internal/buildcfg: change GOEXPERIMENT to always return non-empty string X-Git-Tag: go1.18beta1~1658 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=fa34678c67;p=gostls13.git internal/buildcfg: change GOEXPERIMENT to always return non-empty string 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 TryBot-Result: Go Bot Trust: Matthew Dempsky Reviewed-by: Heschi Kreinick --- diff --git a/src/internal/buildcfg/exp.go b/src/internal/buildcfg/exp.go index 384f2f96af..3844e4f021 100644 --- a/src/internal/buildcfg/exp.go +++ b/src/internal/buildcfg/exp.go @@ -158,7 +158,11 @@ func expList(exp, base *goexperiment.Flags, all bool) []string { // 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