From: Matthew Dempsky Date: Thu, 31 Aug 2017 00:43:19 +0000 (-0700) Subject: cmd/compile: remove global bout variable X-Git-Tag: go1.10beta1~1221 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0fb82fbcceb2639e76a2cdb46134d95c14bc13c9;p=gostls13.git cmd/compile: remove global bout variable Change-Id: I7054bbec080708c3a11ed62d7f6594e82aa33747 Reviewed-on: https://go-review.googlesource.com/61691 Run-TryBot: Matthew Dempsky TryBot-Result: Gobot Gobot Reviewed-by: Daniel Martí --- diff --git a/src/cmd/compile/internal/gc/export.go b/src/cmd/compile/internal/gc/export.go index 7ca79ba9c7..32a90a7b85 100644 --- a/src/cmd/compile/internal/gc/export.go +++ b/src/cmd/compile/internal/gc/export.go @@ -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) diff --git a/src/cmd/compile/internal/gc/go.go b/src/cmd/compile/internal/gc/go.go index b1ead93c34..07895a7fcc 100644 --- a/src/cmd/compile/internal/gc/go.go +++ b/src/cmd/compile/internal/gc/go.go @@ -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 diff --git a/src/cmd/compile/internal/gc/obj.go b/src/cmd/compile/internal/gc/obj.go index 83e64e728e..e9cd6a2c4e 100644 --- a/src/cmd/compile/internal/gc/obj.go +++ b/src/cmd/compile/internal/gc/obj.go @@ -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 {