Commit 889c0a66 authored by Robert Griesemer's avatar Robert Griesemer

cmd/compile: don't export pos info in new export format for now

Exporting filenames as part of the position information can lead
to different object files which breaks tests.

Change-Id: Ia678ab64293ebf04bf83601e6ba72919d05762a4
Reviewed-on: https://go-review.googlesource.com/22385Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
parent f7d19672
...@@ -112,6 +112,14 @@ import ( ...@@ -112,6 +112,14 @@ 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. Currently
// disabled because it may lead to different object files depending on which
// directory they are built under, which causes tests checking for hermetic
// builds to fail (e.g. TestCgoConsistentResults for cmd/go).
// TODO(gri) determine what to do here.
const posInfoFormat = false
// 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
...@@ -160,6 +168,9 @@ func export(out *bufio.Writer, trace bool) int { ...@@ -160,6 +168,9 @@ func export(out *bufio.Writer, trace bool) int {
} }
p.rawByte(format) p.rawByte(format)
// posInfo exported or not?
p.bool(posInfoFormat)
// --- generic export data --- // --- generic export data ---
if p.trace { if p.trace {
...@@ -493,6 +504,10 @@ func (p *exporter) obj(sym *Sym) { ...@@ -493,6 +504,10 @@ func (p *exporter) obj(sym *Sym) {
} }
func (p *exporter) pos(n *Node) { func (p *exporter) pos(n *Node) {
if !posInfoFormat {
return
}
var file string var file string
var line int var line int
if n != nil { if n != nil {
......
...@@ -30,8 +30,9 @@ type importer struct { ...@@ -30,8 +30,9 @@ type importer struct {
funcList []*Node // nil entry means already declared funcList []*Node // nil entry means already declared
// position encoding // position encoding
prevFile string posInfoFormat bool
prevLine int prevFile string
prevLine int
// debugging support // debugging support
debugFormat bool debugFormat bool
...@@ -55,6 +56,8 @@ func Import(in *bufio.Reader) { ...@@ -55,6 +56,8 @@ func Import(in *bufio.Reader) {
Fatalf("importer: invalid encoding format in export data: got %q; want 'c' or 'd'", format) Fatalf("importer: invalid encoding format in export data: got %q; want 'c' or 'd'", format)
} }
p.posInfoFormat = p.bool()
// --- generic export data --- // --- generic export data ---
if v := p.string(); v != exportVersion { if v := p.string(); v != exportVersion {
...@@ -279,6 +282,10 @@ func (p *importer) obj(tag int) { ...@@ -279,6 +282,10 @@ func (p *importer) obj(tag int) {
} }
func (p *importer) pos() { func (p *importer) pos() {
if !p.posInfoFormat {
return
}
file := p.prevFile file := p.prevFile
line := p.prevLine line := p.prevLine
......
...@@ -27,8 +27,9 @@ type importer struct { ...@@ -27,8 +27,9 @@ type importer struct {
typList []types.Type // in order of appearance typList []types.Type // in order of appearance
// position encoding // position encoding
prevFile string posInfoFormat bool
prevLine int prevFile string
prevLine int
// debugging support // debugging support
debugFormat bool debugFormat bool
...@@ -57,6 +58,8 @@ func BImportData(imports map[string]*types.Package, data []byte, path string) (i ...@@ -57,6 +58,8 @@ func BImportData(imports map[string]*types.Package, data []byte, path string) (i
return p.read, nil, fmt.Errorf("invalid encoding format in export data: got %q; want 'c' or 'd'", format) return p.read, nil, fmt.Errorf("invalid encoding format in export data: got %q; want 'c' or 'd'", format)
} }
p.posInfoFormat = p.int() != 0
// --- generic export data --- // --- generic export data ---
if v := p.string(); v != "v0" { if v := p.string(); v != "v0" {
...@@ -194,6 +197,10 @@ func (p *importer) obj(tag int) { ...@@ -194,6 +197,10 @@ func (p *importer) obj(tag int) {
} }
func (p *importer) pos() { func (p *importer) pos() {
if !p.posInfoFormat {
return
}
file := p.prevFile file := p.prevFile
line := p.prevLine line := p.prevLine
......
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