mirror of
https://github.com/golang/go
synced 2024-11-22 05:24:39 -07:00
gc: include all dependencies in export metadata
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
This commit is contained in:
parent
67077cc1ca
commit
e6f3aa6c36
@ -75,10 +75,15 @@ autoexport(Node *n, int ctxt)
|
||||
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
|
||||
@ -265,7 +270,8 @@ void
|
||||
dumpexport(void)
|
||||
{
|
||||
NodeList *l;
|
||||
int32 lno;
|
||||
int32 i, lno;
|
||||
Pkg *p;
|
||||
|
||||
lno = lineno;
|
||||
|
||||
@ -277,6 +283,11 @@ dumpexport(void)
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user