aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/dist
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2020-12-23 19:49:39 -0800
committerMatthew Dempsky <mdempsky@google.com>2021-03-11 21:43:04 +0000
commit7fc638d6f1679f2e35862555531bf479c3e5b99c (patch)
tree70360705cea1ab8adf672605f5ba2f4724b9b6de /src/cmd/dist
parentb3896fc331c36a539f825f1f656cef3f9cdffd3f (diff)
downloadgo-7fc638d6f1679f2e35862555531bf479c3e5b99c.tar.gz
go-7fc638d6f1679f2e35862555531bf479c3e5b99c.zip
cmd: move GOEXPERIMENT knob from make.bash to cmd/go
This CL changes GOEXPERIMENT to act like other GO[CONFIG] environment variables. Namely, that it can be set at make.bash time to provide a default value used by the toolchain, but then can be manually set when running either cmd/go or the individual tools (compiler, assembler, linker). For example, it's now possible to test rsc.io/tmp/fieldtrack by simply running: GOEXPERIMENT=fieldtrack go test -gcflags=-l rsc.io/tmp/fieldtrack \ -ldflags=-k=rsc.io/tmp/fieldtrack.tracked without needing to re-run make.bash. (-gcflags=-l is needed because the compiler's inlining abilities have improved, so calling a function with a for loop is no longer sufficient to suppress inlining.) Fixes #42681. Change-Id: I2cf8995d5d0d05f6785a2ee1d3b54b2cfb3331ca Reviewed-on: https://go-review.googlesource.com/c/go/+/300991 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/dist')
-rw-r--r--src/cmd/dist/build.go16
-rw-r--r--src/cmd/dist/buildruntime.go6
2 files changed, 6 insertions, 16 deletions
diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
index 158cedbadc..b2d13e7db4 100644
--- a/src/cmd/dist/build.go
+++ b/src/cmd/dist/build.go
@@ -39,6 +39,7 @@ var (
goextlinkenabled string
gogcflags string // For running built compiler
goldflags string
+ goexperiment string
workdir string
tooldir string
oldgoos string
@@ -194,6 +195,9 @@ func xinit() {
goextlinkenabled = b
}
+ goexperiment = os.Getenv("GOEXPERIMENT")
+ // TODO(mdempsky): Validate known experiments?
+
gogcflags = os.Getenv("BOOT_GO_GCFLAGS")
goldflags = os.Getenv("BOOT_GO_LDFLAGS")
@@ -834,18 +838,6 @@ func runInstall(pkg string, ch chan struct{}) {
goasmh := pathf("%s/go_asm.h", workdir)
if IsRuntimePackagePath(pkg) {
asmArgs = append(asmArgs, "-compiling-runtime")
- if os.Getenv("GOEXPERIMENT") == "regabi" {
- // In order to make it easier to port runtime assembly
- // to the register ABI, we introduce a macro
- // indicating the experiment is enabled.
- //
- // Note: a similar change also appears in
- // cmd/go/internal/work/gc.go.
- //
- // TODO(austin): Remove this once we commit to the
- // register ABI (#40724).
- asmArgs = append(asmArgs, "-D=GOEXPERIMENT_REGABI=1")
- }
}
// Collect symabis from assembly code.
diff --git a/src/cmd/dist/buildruntime.go b/src/cmd/dist/buildruntime.go
index 2744951597..e0a101a353 100644
--- a/src/cmd/dist/buildruntime.go
+++ b/src/cmd/dist/buildruntime.go
@@ -20,7 +20,6 @@ import (
// package sys
//
// const TheVersion = <version>
-// const Goexperiment = <goexperiment>
// const StackGuardMultiplier = <multiplier value>
//
func mkzversion(dir, file string) {
@@ -30,7 +29,6 @@ func mkzversion(dir, file string) {
fmt.Fprintf(&buf, "package sys\n")
fmt.Fprintln(&buf)
fmt.Fprintf(&buf, "const TheVersion = `%s`\n", findgoversion())
- fmt.Fprintf(&buf, "const Goexperiment = `%s`\n", os.Getenv("GOEXPERIMENT"))
fmt.Fprintf(&buf, "const StackGuardMultiplierDefault = %d\n", stackGuardMultiplierDefault())
writefile(buf.String(), file, writeSkipSame)
@@ -48,10 +46,10 @@ func mkzversion(dir, file string) {
// const defaultGOPPC64 = <goppc64>
// const defaultGOOS = runtime.GOOS
// const defaultGOARCH = runtime.GOARCH
+// const defaultGOEXPERIMENT = <goexperiment>
// const defaultGO_EXTLINK_ENABLED = <goextlinkenabled>
// const version = <version>
// const stackGuardMultiplierDefault = <multiplier value>
-// const goexperiment = <goexperiment>
//
// The use of runtime.GOOS and runtime.GOARCH makes sure that
// a cross-compiled compiler expects to compile for its own target
@@ -77,11 +75,11 @@ func mkzbootstrap(file string) {
fmt.Fprintf(&buf, "const defaultGOPPC64 = `%s`\n", goppc64)
fmt.Fprintf(&buf, "const defaultGOOS = runtime.GOOS\n")
fmt.Fprintf(&buf, "const defaultGOARCH = runtime.GOARCH\n")
+ fmt.Fprintf(&buf, "const defaultGOEXPERIMENT = `%s`\n", goexperiment)
fmt.Fprintf(&buf, "const defaultGO_EXTLINK_ENABLED = `%s`\n", goextlinkenabled)
fmt.Fprintf(&buf, "const defaultGO_LDSO = `%s`\n", defaultldso)
fmt.Fprintf(&buf, "const version = `%s`\n", findgoversion())
fmt.Fprintf(&buf, "const stackGuardMultiplierDefault = %d\n", stackGuardMultiplierDefault())
- fmt.Fprintf(&buf, "const goexperiment = `%s`\n", os.Getenv("GOEXPERIMENT"))
writefile(buf.String(), file, writeSkipSame)
}