1
0
mirror of https://github.com/golang/go synced 2024-11-26 16:57:14 -07:00

cmd/compile: explicitly disallow mixing -iexport={false,true}

flagiexport currently controls not just whether to use the indexed
export format when writing out package data, but also how symbol
import logic works. In particular, it enables lazy loading logic that
currently doesn't work with packages imported via bimport.

We could change the import logic to base decisions on the export data
format used by the packages that individual symbols were loaded from,
but since we expect to deprecate and remove bimport anyway and there's
no need for mixing bimport and iimport, it's simpler to just disallow
mixing them.

Change-Id: I02dbac45062e9dd85a1a647ee46bfa0efbb67e9d
Reviewed-on: https://go-review.googlesource.com/110715
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Matthew Dempsky 2018-05-01 12:42:11 -07:00
parent c2366b27ab
commit eec8fb5ef3

View File

@ -1115,10 +1115,21 @@ func importfile(f *Val) *types.Pkg {
errorexit()
}
// New indexed format is distinguished by an 'i' byte,
// whereas old export format always starts with 'c', 'd', or 'v'.
if c == 'i' {
if !flagiexport {
yyerror("import %s: cannot import package compiled with -iexport=true", file)
errorexit()
}
iimport(importpkg, imp)
} else {
// Old export format always starts with 'c', 'd', or 'v'.
if flagiexport {
yyerror("import %s: cannot import package compiled with -iexport=false", file)
errorexit()
}
imp.UnreadByte()
Import(importpkg, imp.Reader)
}