mirror of
https://github.com/golang/go
synced 2024-10-05 01:21:21 -06:00
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/22392 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
parent
9e3c68f1e0
commit
d224e98d9a
@ -196,6 +196,13 @@ func (d *deadcodepass) mark(s, parent *LSym) {
|
|||||||
if s.Attr.ReflectMethod() {
|
if s.Attr.ReflectMethod() {
|
||||||
d.reflectMethod = true
|
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.Attr |= AttrReachable
|
||||||
s.Reachparent = parent
|
s.Reachparent = parent
|
||||||
d.markQueue = append(d.markQueue, s)
|
d.markQueue = append(d.markQueue, s)
|
||||||
|
@ -196,6 +196,7 @@ var (
|
|||||||
Funcalign int
|
Funcalign int
|
||||||
iscgo bool
|
iscgo bool
|
||||||
elfglobalsymndx int
|
elfglobalsymndx int
|
||||||
|
flag_dumpdep bool
|
||||||
flag_installsuffix string
|
flag_installsuffix string
|
||||||
flag_race int
|
flag_race int
|
||||||
flag_msan int
|
flag_msan int
|
||||||
|
@ -90,6 +90,7 @@ func Ldmain() {
|
|||||||
flag.Var(&Buildmode, "buildmode", "set build `mode`")
|
flag.Var(&Buildmode, "buildmode", "set build `mode`")
|
||||||
obj.Flagcount("c", "dump call graph", &Debug['c'])
|
obj.Flagcount("c", "dump call graph", &Debug['c'])
|
||||||
obj.Flagcount("d", "disable dynamic executable", &Debug['d'])
|
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("extar", "archive program for buildmode=c-archive", &extar)
|
||||||
obj.Flagstr("extld", "use `linker` when linking in external mode", &extld)
|
obj.Flagstr("extld", "use `linker` when linking in external mode", &extld)
|
||||||
obj.Flagstr("extldflags", "pass `flags` to external linker", &extldflags)
|
obj.Flagstr("extldflags", "pass `flags` to external linker", &extldflags)
|
||||||
|
Loading…
Reference in New Issue
Block a user