aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2016-07-01 10:51:59 -0700
committerRobert Griesemer <gri@golang.org>2016-07-01 19:20:11 +0000
commit575a87166291e321745041944321002b3c0b72be (patch)
tree64de77a8803c1853d51c52d8929c5a4d4ecf69a7
parent29f0984a3558ef6e3e58a621791473a71b510365 (diff)
downloadgo-575a87166291e321745041944321002b3c0b72be.tar.gz
go-575a87166291e321745041944321002b3c0b72be.zip
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>
-rw-r--r--src/cmd/compile/internal/gc/bexport.go16
-rw-r--r--src/cmd/compile/internal/gc/bimport.go17
-rw-r--r--src/cmd/compile/internal/gc/builtin.go4
-rw-r--r--src/cmd/compile/internal/gc/parser.go3
-rw-r--r--src/go/internal/gcimporter/bimport.go10
5 files changed, 39 insertions, 11 deletions
diff --git a/src/cmd/compile/internal/gc/bexport.go b/src/cmd/compile/internal/gc/bexport.go
index c7be2deaa2..38e035edc8 100644
--- a/src/cmd/compile/internal/gc/bexport.go
+++ b/src/cmd/compile/internal/gc/bexport.go
@@ -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
diff --git a/src/cmd/compile/internal/gc/bimport.go b/src/cmd/compile/internal/gc/bimport.go
index 5a4d9a3c55..2b666cc21c 100644
--- a/src/cmd/compile/internal/gc/bimport.go
+++ b/src/cmd/compile/internal/gc/bimport.go
@@ -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)
diff --git a/src/cmd/compile/internal/gc/builtin.go b/src/cmd/compile/internal/gc/builtin.go
index b9010f4366..c1a641874e 100644
--- a/src/cmd/compile/internal/gc/builtin.go
+++ b/src/cmd/compile/internal/gc/builtin.go
@@ -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"
diff --git a/src/cmd/compile/internal/gc/parser.go b/src/cmd/compile/internal/gc/parser.go
index 7ffd42f83c..3897db955c 100644
--- a/src/cmd/compile/internal/gc/parser.go
+++ b/src/cmd/compile/internal/gc/parser.go
@@ -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
diff --git a/src/go/internal/gcimporter/bimport.go b/src/go/internal/gcimporter/bimport.go
index 341358287a..75c2d9123e 100644
--- a/src/go/internal/gcimporter/bimport.go
+++ b/src/go/internal/gcimporter/bimport.go
@@ -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))
}