From e6f3aa6c36aecbe48f278829827a30763067ed28 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 14 Mar 2011 13:22:34 -0400 Subject: [PATCH] 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 --- src/cmd/gc/export.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/cmd/gc/export.c b/src/cmd/gc/export.c index 09b963f271..014f0c5f07 100644 --- a/src/cmd/gc/export.c +++ b/src/cmd/gc/export.c @@ -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; ilink) + if(p->direct) + dumppkg(p); + for(l=exportlist; l; l=l->next) { lineno = l->n->lineno; dumpsym(l->n->sym); -- 2.48.1