mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/asm, go/build: invoke cmd/asm only once per package
Prior to this CL, cmd/go invoked cmd/asm once for every assembly file. The exec and cmd/asm startup overhead dwarfed the actual time spent assembling. This CL adds support to cmd/asm to process multiple input files and uses it in cmd/go. This cuts 10% off the wall time for 'go build -a math'. Fixes #15680 Change-Id: I12d2ee2c817207954961dc8f37b8f2b09f835550 Reviewed-on: https://go-review.googlesource.com/27636 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
parent
9d4623fe43
commit
9741d83cea
3 changed files with 60 additions and 36 deletions
|
|
@ -54,22 +54,32 @@ func main() {
|
|||
fmt.Fprintf(buf, "go object %s %s %s\n", obj.Getgoos(), obj.Getgoarch(), obj.Getgoversion())
|
||||
fmt.Fprintf(buf, "!\n")
|
||||
|
||||
lexer := lex.NewLexer(flag.Arg(0), ctxt)
|
||||
parser := asm.NewParser(ctxt, architecture, lexer)
|
||||
diag := false
|
||||
ctxt.DiagFunc = func(format string, args ...interface{}) {
|
||||
diag = true
|
||||
log.Printf(format, args...)
|
||||
var ok, diag bool
|
||||
var failedFile string
|
||||
for _, f := range flag.Args() {
|
||||
lexer := lex.NewLexer(f, ctxt)
|
||||
parser := asm.NewParser(ctxt, architecture, lexer)
|
||||
ctxt.DiagFunc = func(format string, args ...interface{}) {
|
||||
diag = true
|
||||
log.Printf(format, args...)
|
||||
}
|
||||
pList := obj.Linknewplist(ctxt)
|
||||
pList.Firstpc, ok = parser.Parse()
|
||||
if !ok {
|
||||
failedFile = f
|
||||
break
|
||||
}
|
||||
}
|
||||
pList := obj.Linknewplist(ctxt)
|
||||
var ok bool
|
||||
pList.Firstpc, ok = parser.Parse()
|
||||
if ok {
|
||||
// reports errors to parser.Errorf
|
||||
obj.Writeobjdirect(ctxt, buf)
|
||||
}
|
||||
if !ok || diag {
|
||||
log.Printf("assembly of %s failed", flag.Arg(0))
|
||||
if failedFile != "" {
|
||||
log.Printf("assembly of %s failed", failedFile)
|
||||
} else {
|
||||
log.Print("assembly failed")
|
||||
}
|
||||
os.Remove(*flags.OutputFile)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue