Commit 86c93c98 authored by Robert Griesemer's avatar Robert Griesemer

cmd/compile: don't write pos info for builtin packages

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: 's avatarMatthew Dempsky <mdempsky@google.com>
parent a19e60b2
...@@ -112,10 +112,6 @@ import ( ...@@ -112,10 +112,6 @@ import (
// (suspected) format errors, and whenever a change is made to the format. // (suspected) format errors, and whenever a change is made to the format.
const debugFormat = false // default: false 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 // TODO(gri) remove eventually
const forceNewExport = false // force new export format - do NOT submit with this flag set const forceNewExport = false // force new export format - do NOT submit with this flag set
...@@ -144,8 +140,9 @@ type exporter struct { ...@@ -144,8 +140,9 @@ type exporter struct {
funcList []*Func funcList []*Func
// position encoding // position encoding
prevFile string posInfoFormat bool
prevLine int prevFile string
prevLine int
// debugging support // debugging support
written int // bytes written written int // bytes written
...@@ -160,7 +157,11 @@ func export(out *bufio.Writer, trace bool) int { ...@@ -160,7 +157,11 @@ func export(out *bufio.Writer, trace bool) int {
strIndex: map[string]int{"": 0}, // empty string is mapped to 0 strIndex: map[string]int{"": 0}, // empty string is mapped to 0
pkgIndex: make(map[*Pkg]int), pkgIndex: make(map[*Pkg]int),
typIndex: make(map[*Type]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 // first byte indicates low-level encoding format
...@@ -171,7 +172,7 @@ func export(out *bufio.Writer, trace bool) int { ...@@ -171,7 +172,7 @@ func export(out *bufio.Writer, trace bool) int {
p.rawByte(format) p.rawByte(format)
// posInfo exported or not? // posInfo exported or not?
p.bool(posInfoFormat) p.bool(p.posInfoFormat)
// --- generic export data --- // --- generic export data ---
...@@ -506,7 +507,7 @@ func (p *exporter) obj(sym *Sym) { ...@@ -506,7 +507,7 @@ func (p *exporter) obj(sym *Sym) {
} }
func (p *exporter) pos(n *Node) { func (p *exporter) pos(n *Node) {
if !posInfoFormat { if !p.posInfoFormat {
return return
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment