aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/dist
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2020-10-14 08:06:54 -0400
committerThan McIntosh <thanm@google.com>2020-10-19 19:27:54 +0000
commit4d1cecdee8360ef12a817c124d7a04c9d29741c3 (patch)
tree7322dd2ddc9be1716bed00a3f7fa176bdb2a75a9 /src/cmd/dist
parentab541a0560408999ac65d12bec2a3057994eda38 (diff)
downloadgo-4d1cecdee8360ef12a817c124d7a04c9d29741c3.tar.xz
cmd/dist,cmd/go: broaden use of asm macro GOEXPERIMENT_REGABI
This extends a change made in https://golang.org/cl/252258 to the go command (to define an asm macro when GOEXPERIMENT=regabi is in effect); we need this same macro during the bootstrap build in order to build the runtime correctly. In addition, expand the set of packages where the macro is applied to {runtime, reflect, syscall, runtime/internal/*}, and move the logic for deciding when something is a "runtime package" out of the assembler and into cmd/{go,dist}, introducing a new assembler command line flag instead. Updates #27539, #40724. Change-Id: Ifcc7f029f56873584de1e543c55b0d3e54ad6c49 Reviewed-on: https://go-review.googlesource.com/c/go/+/262317 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd/dist')
-rw-r--r--src/cmd/dist/build.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
index 398ed6bce1..11da38ebdf 100644
--- a/src/cmd/dist/build.go
+++ b/src/cmd/dist/build.go
@@ -832,6 +832,21 @@ func runInstall(pkg string, ch chan struct{}) {
asmArgs = append(asmArgs, "-D", "GOMIPS64_"+gomips64)
}
goasmh := pathf("%s/go_asm.h", workdir)
+ if IsRuntimePackagePath(pkg) {
+ asmArgs = append(asmArgs, "-compilingRuntime")
+ 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.
var symabis string
@@ -1733,3 +1748,23 @@ func cmdlist() {
fatalf("write failed: %v", err)
}
}
+
+// IsRuntimePackagePath examines 'pkgpath' and returns TRUE if it
+// belongs to the collection of "runtime-related" packages, including
+// "runtime" itself, "reflect", "syscall", and the
+// "runtime/internal/*" packages. See also the function of the same
+// name in cmd/internal/objabi/path.go.
+func IsRuntimePackagePath(pkgpath string) bool {
+ rval := false
+ switch pkgpath {
+ case "runtime":
+ rval = true
+ case "reflect":
+ rval = true
+ case "syscall":
+ rval = true
+ default:
+ rval = strings.HasPrefix(pkgpath, "runtime/internal")
+ }
+ return rval
+}