Skip to content

Commit a538b59

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]>
1 parent 2b8b06e commit a538b59

File tree

1 file changed

+9
-0
lines changed
  • src/cmd/go/internal/work

1 file changed

+9
-0
lines changed

src/cmd/go/internal/work/gc.go

+9
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,15 @@ func asmArgs(a *Action, p *load.Package) []interface{} {
259259
}
260260
}
261261
}
262+
if p.ImportPath == "runtime" && objabi.Regabi_enabled != 0 {
263+
// In order to make it easier to port runtime assembly
264+
// to the register ABI, we introduce a macro
265+
// indicating the experiment is enabled.
266+
//
267+
// TODO(austin): Remove this once we commit to the
268+
// register ABI (#40724).
269+
args = append(args, "-D=GOEXPERIMENT_REGABI=1")
270+
}
262271

263272
if cfg.Goarch == "mips" || cfg.Goarch == "mipsle" {
264273
// Define GOMIPS_value from cfg.GOMIPS.

0 commit comments

Comments
 (0)