1
0
mirror of https://github.com/golang/go synced 2024-11-19 17:04:41 -07:00

cmd/compile: remove global bout variable

Change-Id: I7054bbec080708c3a11ed62d7f6594e82aa33747
Reviewed-on: https://go-review.googlesource.com/61691
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
Matthew Dempsky 2017-08-30 17:43:19 -07:00
parent 34db5f0c4d
commit 0fb82fbcce
3 changed files with 7 additions and 11 deletions

View File

@ -19,7 +19,7 @@ var (
Debug_export int // if set, print debugging information about export data
)
func exportf(format string, args ...interface{}) {
func exportf(bout *bio.Writer, format string, args ...interface{}) {
fmt.Fprintf(bout, format, args...)
if Debug_export != 0 {
fmt.Printf(format, args...)
@ -222,14 +222,14 @@ func (x methodbyname) Len() int { return len(x) }
func (x methodbyname) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
func (x methodbyname) Less(i, j int) bool { return x[i].Sym.Name < x[j].Sym.Name }
func dumpexport() {
func dumpexport(bout *bio.Writer) {
if buildid != "" {
exportf("build id %q\n", buildid)
exportf(bout, "build id %q\n", buildid)
}
size := 0 // size of export section without enclosing markers
// The linker also looks for the $$ marker - use char after $$ to distinguish format.
exportf("\n$$B\n") // indicate binary export format
exportf(bout, "\n$$B\n") // indicate binary export format
if debugFormat {
// save a copy of the export data
var copy bytes.Buffer
@ -253,7 +253,7 @@ func dumpexport() {
} else {
size = export(bout.Writer, Debug_export != 0)
}
exportf("\n$$\n")
exportf(bout, "\n$$\n")
if Debug_export != 0 {
fmt.Printf("export data size = %d bytes\n", size)

View File

@ -7,7 +7,6 @@ package gc
import (
"cmd/compile/internal/ssa"
"cmd/compile/internal/types"
"cmd/internal/bio"
"cmd/internal/obj"
"cmd/internal/src"
"sync"
@ -85,8 +84,6 @@ var outfile string
var linkobj string
var dolinkobj bool
var bout *bio.Writer
// nerrors is the number of compiler errors reported
// since the last call to saveerrors.
var nerrors int

View File

@ -56,8 +56,7 @@ func dumpobj() {
}
func dumpobj1(outfile string, mode int) {
var err error
bout, err = bio.Create(outfile)
bout, err := bio.Create(outfile)
if err != nil {
flusherrors()
fmt.Printf("can't create %s: %v\n", outfile, err)
@ -92,7 +91,7 @@ func dumpobj1(outfile string, mode int) {
printheader()
if mode&modeCompilerObj != 0 {
dumpexport()
dumpexport(bout)
}
if writearchive {