]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: don't write pos info for builtin packages
authorRobert Griesemer <gri@golang.org>
Wed, 27 Apr 2016 05:31:02 +0000 (22:31 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 27 Apr 2016 15:19:37 +0000 (15:19 +0000)
TestBuiltin will fail if run on Windows and builtin.go was generated
on a non-Windows machine (or vice versa) because path names have
different separators. Avoid problem altogether by not writing pos
info for builtin packages. It's not needed.

Affects -newexport only.

Change-Id: I8944f343452faebaea9a08b5fb62829bed77c148
Reviewed-on: https://go-review.googlesource.com/22498
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/bexport.go

index 5c9a2734d4e51609fb524bc794d53c0af7ebe1b2..b3ee9b8054abfcdcee6964e94228fb1b434deb9d 100644 (file)
@@ -112,10 +112,6 @@ import (
 // (suspected) format errors, and whenever a change is made to the format.
 const debugFormat = false // default: false
 
-// If posInfoFormat is set, position information (file, lineno) is written
-// for each exported object, including methods and struct fields.
-const posInfoFormat = true // default: true
-
 // TODO(gri) remove eventually
 const forceNewExport = false // force new export format - do NOT submit with this flag set
 
@@ -144,8 +140,9 @@ type exporter struct {
        funcList []*Func
 
        // position encoding
-       prevFile string
-       prevLine int
+       posInfoFormat bool
+       prevFile      string
+       prevLine      int
 
        // debugging support
        written int // bytes written
@@ -160,7 +157,11 @@ func export(out *bufio.Writer, trace bool) int {
                strIndex: map[string]int{"": 0}, // empty string is mapped to 0
                pkgIndex: make(map[*Pkg]int),
                typIndex: make(map[*Type]int),
-               trace:    trace,
+               // don't emit pos info for builtin packages
+               // (not needed and avoids path name diffs in builtin.go between
+               // Windows and non-Windows machines, exposed via builtin_test.go)
+               posInfoFormat: Debug['A'] == 0,
+               trace:         trace,
        }
 
        // first byte indicates low-level encoding format
@@ -171,7 +172,7 @@ func export(out *bufio.Writer, trace bool) int {
        p.rawByte(format)
 
        // posInfo exported or not?
-       p.bool(posInfoFormat)
+       p.bool(p.posInfoFormat)
 
        // --- generic export data ---
 
@@ -506,7 +507,7 @@ func (p *exporter) obj(sym *Sym) {
 }
 
 func (p *exporter) pos(n *Node) {
-       if !posInfoFormat {
+       if !p.posInfoFormat {
                return
        }