]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove global bout variable
authorMatthew Dempsky <mdempsky@google.com>
Thu, 31 Aug 2017 00:43:19 +0000 (17:43 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 5 Sep 2017 19:59:21 +0000 (19:59 +0000)
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>
src/cmd/compile/internal/gc/export.go
src/cmd/compile/internal/gc/go.go
src/cmd/compile/internal/gc/obj.go

index 7ca79ba9c715b7bd59d9a15842f8dc6a4bfcab1f..32a90a7b851465ff17d8ec6bf9c6feef486f01fb 100644 (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)
index b1ead93c346cda7d101427e7021a801be31031e3..07895a7fccf8db71645c10add8fa021f2be14b33 100644 (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
index 83e64e728e957ab9928973f114edb9628a60e983..e9cd6a2c4eec1d1bc049f69a63349ad6ef079bc5 100644 (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 {