compiler: include transitive imports in the type descriptor list

In CL 179598, we were using Gogo::packages_, when compiling the
main package, as the list of packages of which we need to
register the type descriptors. This is not complete. It only
includes main's direct import and one-level indirect imports. It
does not include all the packages transitively imported.

To fix that, we need to track all the transitive imports. We
have almost already done that, for init functions. However, there
may be packages that don't need init functions but do need to
register type descriptors. For them, we add a dummy init function
to its export data. So when we compile the main package we will
see all the transitive imports. The dummy init functions are not
real functions and are not called.

Fixes golang/go#32901.

Change-Id: I683045273fb1b2ac7cf41617e641d8b4340b85a9
Reviewed-by: Ian Lance Taylor <>
4 files changed