mirror of
https://github.com/golang/go
synced 2024-11-17 04:34:46 -07:00
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: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
29f0984a35
commit
575a871662
@ -153,7 +153,13 @@ const debugFormat = false // default: false
|
||||
// TODO(gri) disable and remove once there is only one export format again
|
||||
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
|
||||
// dependencies. The compiler should work w/o any loss of functionality with
|
||||
@ -727,6 +733,14 @@ func (p *exporter) typ(t *Type) {
|
||||
p.paramList(sig.Params(), 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
|
||||
if inlineable {
|
||||
f = mfn.Func
|
||||
|
@ -21,8 +21,9 @@ import (
|
||||
// changes to bimport.go and bexport.go.
|
||||
|
||||
type importer struct {
|
||||
in *bufio.Reader
|
||||
buf []byte // reused for reading strings
|
||||
in *bufio.Reader
|
||||
buf []byte // reused for reading strings
|
||||
version string
|
||||
|
||||
// object lists, in order of deserialization
|
||||
strList []string
|
||||
@ -67,8 +68,9 @@ func Import(in *bufio.Reader) {
|
||||
|
||||
// --- generic export data ---
|
||||
|
||||
if v := p.string(); v != exportVersion {
|
||||
Fatalf("importer: unknown export data version: %s", v)
|
||||
p.version = p.string()
|
||||
if p.version != exportVersion0 && p.version != exportVersion1 {
|
||||
Fatalf("importer: unknown export data version: %s", p.version)
|
||||
}
|
||||
|
||||
// populate typList with predeclared "known" types
|
||||
@ -432,10 +434,15 @@ func (p *importer) typ() *Type {
|
||||
params := p.paramList()
|
||||
result := p.paramList()
|
||||
|
||||
nointerface := false
|
||||
if p.version == exportVersion1 {
|
||||
nointerface = p.bool()
|
||||
}
|
||||
|
||||
n := methodname1(newname(sym), recv[0].Right)
|
||||
n.Type = functype(recv[0], params, result)
|
||||
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)
|
||||
importlist = append(importlist, n)
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
package gc
|
||||
|
||||
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" +
|
||||
"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" +
|
||||
@ -105,6 +105,6 @@ const runtimeimport = "" +
|
||||
"\x01\x02\v\x00\x01\x00\n$$\n"
|
||||
|
||||
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\x00\n$$\n"
|
||||
|
@ -2006,7 +2006,8 @@ func (p *parser) hidden_fndcl() *Node {
|
||||
ss.Type = functype(s2[0], s6, s8)
|
||||
|
||||
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)
|
||||
|
||||
// inl.C's inlnode in on a dotmeth node expects to find the inlineable body as
|
||||
|
@ -21,6 +21,7 @@ type importer struct {
|
||||
data []byte
|
||||
path string
|
||||
buf []byte // for reading strings
|
||||
version string
|
||||
|
||||
// object lists
|
||||
strList []string // in order of appearance
|
||||
@ -66,8 +67,9 @@ func BImportData(imports map[string]*types.Package, data []byte, path string) (i
|
||||
|
||||
// --- generic export data ---
|
||||
|
||||
if v := p.string(); v != "v0" {
|
||||
return p.read, nil, fmt.Errorf("unknown export data version: %s", v)
|
||||
p.version = p.string()
|
||||
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
|
||||
@ -304,6 +306,10 @@ func (p *importer) typ(parent *types.Package) types.Type {
|
||||
params, isddd := p.paramList()
|
||||
result, _ := p.paramList()
|
||||
|
||||
if p.version == "v1" {
|
||||
p.int() // nointerface flag - discarded
|
||||
}
|
||||
|
||||
sig := types.NewSignature(recv.At(0), params, result, isddd)
|
||||
t0.AddMethod(types.NewFunc(token.NoPos, parent, name, sig))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user