Commit 575a8716 authored by Robert Griesemer's avatar Robert Griesemer

cmd/compile: don't lose //go:nointerface pragma in export data

Fixes #16243.

Change-Id: I207d1e8aa48abe453a23c709ccf4f8e07368595b
Reviewed-on: https://go-review.googlesource.com/24648
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 29f0984a
...@@ -153,7 +153,13 @@ const debugFormat = false // default: false ...@@ -153,7 +153,13 @@ const debugFormat = false // default: false
// TODO(gri) disable and remove once there is only one export format again // TODO(gri) disable and remove once there is only one export format again
const forceObjFileStability = true const forceObjFileStability = true
const exportVersion = "v0" // Supported export format versions.
// TODO(gri) Make this more systematic (issue #16244).
const (
exportVersion0 = "v0"
exportVersion1 = "v1"
exportVersion = exportVersion1
)
// exportInlined enables the export of inlined function bodies and related // exportInlined enables the export of inlined function bodies and related
// dependencies. The compiler should work w/o any loss of functionality with // dependencies. The compiler should work w/o any loss of functionality with
...@@ -727,6 +733,14 @@ func (p *exporter) typ(t *Type) { ...@@ -727,6 +733,14 @@ func (p *exporter) typ(t *Type) {
p.paramList(sig.Params(), inlineable) p.paramList(sig.Params(), inlineable)
p.paramList(sig.Results(), inlineable) p.paramList(sig.Results(), inlineable)
// for issue #16243
// We make this conditional for 1.7 to avoid consistency problems
// with installed packages compiled with an older version.
// TODO(gri) Clean up after 1.7 is out (issue #16244)
if exportVersion == exportVersion1 {
p.bool(m.Nointerface)
}
var f *Func var f *Func
if inlineable { if inlineable {
f = mfn.Func f = mfn.Func
......
...@@ -21,8 +21,9 @@ import ( ...@@ -21,8 +21,9 @@ import (
// changes to bimport.go and bexport.go. // changes to bimport.go and bexport.go.
type importer struct { type importer struct {
in *bufio.Reader in *bufio.Reader
buf []byte // reused for reading strings buf []byte // reused for reading strings
version string
// object lists, in order of deserialization // object lists, in order of deserialization
strList []string strList []string
...@@ -67,8 +68,9 @@ func Import(in *bufio.Reader) { ...@@ -67,8 +68,9 @@ func Import(in *bufio.Reader) {
// --- generic export data --- // --- generic export data ---
if v := p.string(); v != exportVersion { p.version = p.string()
Fatalf("importer: unknown export data version: %s", v) if p.version != exportVersion0 && p.version != exportVersion1 {
Fatalf("importer: unknown export data version: %s", p.version)
} }
// populate typList with predeclared "known" types // populate typList with predeclared "known" types
...@@ -432,10 +434,15 @@ func (p *importer) typ() *Type { ...@@ -432,10 +434,15 @@ func (p *importer) typ() *Type {
params := p.paramList() params := p.paramList()
result := p.paramList() result := p.paramList()
nointerface := false
if p.version == exportVersion1 {
nointerface = p.bool()
}
n := methodname1(newname(sym), recv[0].Right) n := methodname1(newname(sym), recv[0].Right)
n.Type = functype(recv[0], params, result) n.Type = functype(recv[0], params, result)
checkwidth(n.Type) checkwidth(n.Type)
addmethod(sym, n.Type, tsym.Pkg, false, false) addmethod(sym, n.Type, tsym.Pkg, false, nointerface)
p.funcList = append(p.funcList, n) p.funcList = append(p.funcList, n)
importlist = append(importlist, n) importlist = append(importlist, n)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
package gc package gc
const runtimeimport = "" + const runtimeimport = "" +
"cn\x00\x03v0\x01\rruntime\x00\t\x11newobject\x00\x02\x17\"\vtyp·2\x00\x00" + "cn\x00\x03v1\x01\rruntime\x00\t\x11newobject\x00\x02\x17\"\vtyp·2\x00\x00" +
"\x01\x17:\x00\t\x13panicindex\x00\x00\x00\t\x13panicslice\x00\x00\x00\t\x15pani" + "\x01\x17:\x00\t\x13panicindex\x00\x00\x00\t\x13panicslice\x00\x00\x00\t\x15pani" +
"cdivide\x00\x00\x00\t\x15throwreturn\x00\x00\x00\t\x11throwinit\x00\x00\x00" + "cdivide\x00\x00\x00\t\x15throwreturn\x00\x00\x00\t\x11throwinit\x00\x00\x00" +
"\t\x11panicwrap\x00\x05 \x00 \x00 \x00\x00\t\rgopanic\x00\x01\x1b\x00\x00\x00\x00\t\x11go" + "\t\x11panicwrap\x00\x05 \x00 \x00 \x00\x00\t\rgopanic\x00\x01\x1b\x00\x00\x00\x00\t\x11go" +
...@@ -105,6 +105,6 @@ const runtimeimport = "" + ...@@ -105,6 +105,6 @@ const runtimeimport = "" +
"\x01\x02\v\x00\x01\x00\n$$\n" "\x01\x02\v\x00\x01\x00\n$$\n"
const unsafeimport = "" + const unsafeimport = "" +
"cn\x00\x03v0\x01\vunsafe\x00\x05\r\rPointer\x00\x16\x00\t\x0fOffsetof\x00\x01" + "cn\x00\x03v1\x01\vunsafe\x00\x05\r\rPointer\x00\x16\x00\t\x0fOffsetof\x00\x01" +
":\x00\x01\x16\x00\t\vSizeof\x00\x01:\x00\x01\x16\x00\t\rAlignof\x00\x01:\x00\x01\x16\x00\v\b\x00\v" + ":\x00\x01\x16\x00\t\vSizeof\x00\x01:\x00\x01\x16\x00\t\rAlignof\x00\x01:\x00\x01\x16\x00\v\b\x00\v" +
"\x00\x01\x00\n$$\n" "\x00\x01\x00\n$$\n"
...@@ -2006,7 +2006,8 @@ func (p *parser) hidden_fndcl() *Node { ...@@ -2006,7 +2006,8 @@ func (p *parser) hidden_fndcl() *Node {
ss.Type = functype(s2[0], s6, s8) ss.Type = functype(s2[0], s6, s8)
checkwidth(ss.Type) checkwidth(ss.Type)
addmethod(s4, ss.Type, p.structpkg, false, false) addmethod(s4, ss.Type, p.structpkg, false, p.pragma&Nointerface != 0)
p.pragma = 0
funchdr(ss) funchdr(ss)
// inl.C's inlnode in on a dotmeth node expects to find the inlineable body as // inl.C's inlnode in on a dotmeth node expects to find the inlineable body as
......
...@@ -21,6 +21,7 @@ type importer struct { ...@@ -21,6 +21,7 @@ type importer struct {
data []byte data []byte
path string path string
buf []byte // for reading strings buf []byte // for reading strings
version string
// object lists // object lists
strList []string // in order of appearance strList []string // in order of appearance
...@@ -66,8 +67,9 @@ func BImportData(imports map[string]*types.Package, data []byte, path string) (i ...@@ -66,8 +67,9 @@ func BImportData(imports map[string]*types.Package, data []byte, path string) (i
// --- generic export data --- // --- generic export data ---
if v := p.string(); v != "v0" { p.version = p.string()
return p.read, nil, fmt.Errorf("unknown export data version: %s", v) if p.version != "v0" && p.version != "v1" {
return p.read, nil, fmt.Errorf("unknown export data version: %s", p.version)
} }
// populate typList with predeclared "known" types // populate typList with predeclared "known" types
...@@ -304,6 +306,10 @@ func (p *importer) typ(parent *types.Package) types.Type { ...@@ -304,6 +306,10 @@ func (p *importer) typ(parent *types.Package) types.Type {
params, isddd := p.paramList() params, isddd := p.paramList()
result, _ := p.paramList() result, _ := p.paramList()
if p.version == "v1" {
p.int() // nointerface flag - discarded
}
sig := types.NewSignature(recv.At(0), params, result, isddd) sig := types.NewSignature(recv.At(0), params, result, isddd)
t0.AddMethod(types.NewFunc(token.NoPos, parent, name, sig)) t0.AddMethod(types.NewFunc(token.NoPos, parent, name, sig))
} }
......
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