]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: explicitly disallow mixing -iexport={false,true}
authorMatthew Dempsky <mdempsky@google.com>
Tue, 1 May 2018 19:42:11 +0000 (12:42 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 1 May 2018 22:31:24 +0000 (22:31 +0000)
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>
src/cmd/compile/internal/gc/main.go

index 809910d7b2aeffdaa6cff1de31f0df79665b07c5..203903d10e94a4ad58b99fc778c12a25c20dc0e6 100644 (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)
                }