]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: define an asm macro for GOEXPERIMENT=regabi
authorAustin Clements <austin@google.com>
Tue, 1 Sep 2020 15:21:50 +0000 (11:21 -0400)
committerAustin Clements <austin@google.com>
Thu, 3 Sep 2020 12:55:47 +0000 (12:55 +0000)
This defines a macro for the regabi GOEXPERIMENT when assembling
runtime assembly code.

In general, assembly code will be shielded from the calling convention
change, but there is a small amount of runtime assembly that is going
to have to change. By defining a macro, we can easily make the small
necessary changes. The other option is to use build tags, but that
would require duplicating nontrivial amounts of unaffected code,
leading to potential divergence issues. (And unlike Go code, assembly
code can't depend on the compiler optimizing away branches on a
feature constant.) We consider the macro preferable, especially since
this is expected to be temporary as we transition to the new calling
convention.

Updates #40724.

Change-Id: I73984065123968337ec10b47bb12c4a1cbc07dc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/252258
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/go/internal/work/gc.go

index f1d08e02686c7ed08b9d40999a4e95f908620bba..6031897f88f2154c9b446ad71b6601cd7fc0dbe9 100644 (file)
@@ -259,6 +259,15 @@ func asmArgs(a *Action, p *load.Package) []interface{} {
                        }
                }
        }
+       if p.ImportPath == "runtime" && objabi.Regabi_enabled != 0 {
+               // In order to make it easier to port runtime assembly
+               // to the register ABI, we introduce a macro
+               // indicating the experiment is enabled.
+               //
+               // TODO(austin): Remove this once we commit to the
+               // register ABI (#40724).
+               args = append(args, "-D=GOEXPERIMENT_REGABI=1")
+       }
 
        if cfg.Goarch == "mips" || cfg.Goarch == "mipsle" {
                // Define GOMIPS_value from cfg.GOMIPS.