This is an archive of the discontinued LLVM Phabricator instance.

[llgo] llgoi: Fix type identity for imported binary packages.
ClosedPublic

Authored by pcc on Mar 18 2015, 12:40 AM.

Details

Summary

go/loader creates a fresh package map for each source package it imports. In
llgoi this caused binary imported packages to be imported anew for every
input line, resulting in spurious type errors and panics in go/ssa when
encountering previously imported types. Fix this by ignoring the provided
package map completely in the importer wrapper and using our own.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc updated this revision to Diff 22162.Mar 18 2015, 12:40 AM
pcc retitled this revision from to [llgo] llgoi: Fix type identity for imported binary packages..
pcc updated this object.
pcc edited the test plan for this revision. (Show Details)
pcc added a reviewer: axw.
pcc added a subscriber: Unknown Object (MLST).
axw added inline comments.Mar 18 2015, 12:59 AM
cmd/llgoi/llgoi.go
101 ↗(On Diff #22162)

I'd prefer if we stuck to the contract of go/types.Importer (as before), and instead just set go/types.Config.Packages to the same map each time. I understand that the package map is only read/updated by the importer currently, but I'm not sure if that's guaranteed to be the case forever. Perhaps I'm being paranoid?

pcc updated this revision to Diff 22165.Mar 18 2015, 1:23 AM
  • Set types.Config.Packages instead of overriding the package map
cmd/llgoi/llgoi.go
101 ↗(On Diff #22162)

Seems reasonable, done.

axw accepted this revision.Mar 18 2015, 1:31 AM
axw edited edge metadata.

LGTM, thanks.

This revision is now accepted and ready to land.Mar 18 2015, 1:31 AM
This revision was automatically updated to reflect the committed changes.