Commit d224e98d authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

cmd/link: add -dumpdep flag to dump linker dependency graph

This is what led to https://golang.org/cl/20763 and
https://golang.org/cl/20765 to shrink binary sizes.

Change-Id: Id360d474e6153cfe32a525b0a720810fd113195b
Reviewed-on: https://go-review.googlesource.com/22392Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
parent 9e3c68f1
......@@ -196,6 +196,13 @@ func (d *deadcodepass) mark(s, parent *LSym) {
if s.Attr.ReflectMethod() {
d.reflectMethod = true
}
if flag_dumpdep {
p := "_"
if parent != nil {
p = parent.Name
}
fmt.Printf("%s -> %s\n", p, s.Name)
}
s.Attr |= AttrReachable
s.Reachparent = parent
d.markQueue = append(d.markQueue, s)
......
......@@ -196,6 +196,7 @@ var (
Funcalign int
iscgo bool
elfglobalsymndx int
flag_dumpdep bool
flag_installsuffix string
flag_race int
flag_msan int
......
......@@ -90,6 +90,7 @@ func Ldmain() {
flag.Var(&Buildmode, "buildmode", "set build `mode`")
obj.Flagcount("c", "dump call graph", &Debug['c'])
obj.Flagcount("d", "disable dynamic executable", &Debug['d'])
flag.BoolVar(&flag_dumpdep, "dumpdep", false, "dump symbol dependency graph")
obj.Flagstr("extar", "archive program for buildmode=c-archive", &extar)
obj.Flagstr("extld", "use `linker` when linking in external mode", &extld)
obj.Flagstr("extldflags", "pass `flags` to external linker", &extldflags)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment