diff options
author | Dan Scales <danscales@google.com> | 2020-03-11 12:08:03 -0700 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2020-03-23 19:24:26 +0000 |
commit | 5113f5776620dfd0221bb876b9889c73d585371c (patch) | |
tree | 05d51bce9ea4d6ef4b8848228eec58a0d4650c9e /src/cmd/go/testdata/script/README | |
parent | 6aded2524cb77eeab907e64512c5f7c54b530756 (diff) | |
download | go-5113f5776620dfd0221bb876b9889c73d585371c.tar.gz go-5113f5776620dfd0221bb876b9889c73d585371c.zip |
cmd/go: define a build tag for any GOEXPERIMENT which is enabled.
For each experiment that has been enabled in the toolchain, define a build tag
with the same name (but prefixed by "goexperiment.") which can be used for
compiling alternative files for the experiment. This allows changes for the
experiment, like extra struct fields in the runtime, without affecting the base
non-experiment code at all.
I use this capability in my CL for static lock ranking
(https://go-review.googlesource.com/c/go/+/207619), so that static lock ranking
can be fully enabled as a GOEXPERIMENT, but there is no overhead in the runtime
when the experiment is not enabled.
I added a test in cmd/go/testdata/scripts to make sure the build tags are being
defined properly. In order to implement the test, I needed to provide environment
variable GOEXPSTRING to the test scripts (with its value set from
objabi.Expstring(), so that it can determine the experiments baked into the
toolchain.
I filed https://github.com/golang/go/issues/37937 to make a builder with
GOEXPERIMENT set to 'staticlockranking'. This builder will ensure another variant
of GOEXPERIMENT is being tested regularly for this change, as well as checking
static lock ranking in the runtime.
Change-Id: Ieb4b86107238febd105558c1e639d30cfe57ab5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/222925
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/testdata/script/README')
-rw-r--r-- | src/cmd/go/testdata/script/README | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/cmd/go/testdata/script/README b/src/cmd/go/testdata/script/README index 81b6d9d814..f4c92e65ab 100644 --- a/src/cmd/go/testdata/script/README +++ b/src/cmd/go/testdata/script/README @@ -29,6 +29,7 @@ Scripts also have access to these other environment variables: GOARCH=<target GOARCH> GOCACHE=<actual GOCACHE being used outside the test> GOEXE=<executable file suffix: .exe on Windows, empty on other systems> + GOEXPSTRING=<value of objabi.Expstring(), from GOEXPERIMENT when toolchain built> GOOS=<target GOOS> GOPATH=$WORK/gopath GOPROXY=<local module proxy serving from cmd/go/testdata/mod> |