mirror of
https://github.com/golang/go.git
synced 2025-05-29 03:11:26 +00: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() {
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user