From a538b59fd2428ba4d13f296d7483febf2fc05f97 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 1 Sep 2020 11:21:50 -0400 Subject: [PATCH] cmd/go: define an asm macro for GOEXPERIMENT=regabi 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 TryBot-Result: Gobot Gobot Reviewed-by: Cherry Zhang --- src/cmd/go/internal/work/gc.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cmd/go/internal/work/gc.go b/src/cmd/go/internal/work/gc.go index f1d08e0268..6031897f88 100644 --- a/src/cmd/go/internal/work/gc.go +++ b/src/cmd/go/internal/work/gc.go @@ -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. -- 2.48.1