This change records more metadata about what
influenced the creation of the object file.
Specifically, if a package imports, say, "fmt" but does not
need to describe any fmt types in its own export data,
that package's object file did not mention the dependency
on "fmt" before. Now it does.
Listing the import is purely informational.
It has no effect on which files are opened or consulted
when importing a package.
Import lines are marked indirect when they are needed
to explain the API but were not imported directly.
For example http imports crypto/tls and exports
a struct with a field of type tls.ConnectionState,
which contains an x509.Certificate. Since http does
not import x509 but needs to explain the x509.Certificate
type in its export data, the import of x509 is marked
as indirect. These import lines were always present;
marking them with the indirect comment makes clear
which were imported directly and which are incidental.
R=ken2
CC=golang-dev
https://golang.org/cl/
4295048
static void
dumppkg(Pkg *p)
{
+ char *suffix;
+
if(p == nil || p == localpkg || p->exported)
return;
p->exported = 1;
- Bprint(bout, "\timport %s \"%Z\"\n", p->name, p->path);
+ suffix = "";
+ if(!p->direct)
+ suffix = " // indirect";
+ Bprint(bout, "\timport %s \"%Z\"%s\n", p->name, p->path, suffix);
}
static void
dumpexport(void)
{
NodeList *l;
- int32 lno;
+ int32 i, lno;
+ Pkg *p;
lno = lineno;
Bprint(bout, " safe");
Bprint(bout, "\n");
+ for(i=0; i<nelem(phash); i++)
+ for(p=phash[i]; p; p=p->link)
+ if(p->direct)
+ dumppkg(p);
+
for(l=exportlist; l; l=l->next) {
lineno = l->n->lineno;
dumpsym(l->n->sym);