mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
ab541a0560
commit
4d1cecdee8
4 changed files with 61 additions and 19 deletions
|
|
@ -24,6 +24,7 @@ var (
|
|||
SymABIs = flag.Bool("gensymabis", false, "write symbol ABI information to output file, don't assemble")
|
||||
Importpath = flag.String("p", "", "set expected package import to path")
|
||||
Spectre = flag.String("spectre", "", "enable spectre mitigations in `list` (all, ret)")
|
||||
CompilingRuntime = flag.Bool("compilingRuntime", false, "source to be compiled is part of the Go runtime")
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ func main() {
|
|||
case "all", "ret":
|
||||
ctxt.Retpoline = true
|
||||
}
|
||||
compilingRuntime := objabi.IsRuntimePackagePath(*flags.Importpath)
|
||||
|
||||
ctxt.Bso = bufio.NewWriter(os.Stdout)
|
||||
defer ctxt.Bso.Flush()
|
||||
|
|
@ -75,7 +74,8 @@ func main() {
|
|||
var failedFile string
|
||||
for _, f := range flag.Args() {
|
||||
lexer := lex.NewLexer(f)
|
||||
parser := asm.NewParser(ctxt, architecture, lexer, compilingRuntime)
|
||||
parser := asm.NewParser(ctxt, architecture, lexer,
|
||||
*flags.CompilingRuntime)
|
||||
ctxt.DiagFunc = func(format string, args ...interface{}) {
|
||||
diag = true
|
||||
log.Printf(format, args...)
|
||||
|
|
|
|||
35
src/cmd/dist/build.go
vendored
35
src/cmd/dist/build.go
vendored
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -292,15 +292,21 @@ func asmArgs(a *Action, p *load.Package) []interface{} {
|
|||
}
|
||||
}
|
||||
}
|
||||
if p.ImportPath == "runtime" && objabi.Regabi_enabled != 0 {
|
||||
if objabi.IsRuntimePackagePath(pkgpath) {
|
||||
args = append(args, "-compilingRuntime")
|
||||
if 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.
|
||||
//
|
||||
// Note: a similar change also appears in
|
||||
// cmd/dist/build.go.
|
||||
//
|
||||
// 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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue