Before go supported buildmode=shared ·f symbols used to be defined
only when they were used. In order to solve #11480 the strategy
was changed to have these symbols defined on declaration which is
less efficient and generates many unneeded symbols.
With this change the best strategy is chosen for each situation,
improving static linking time:
name old s/op new s/op delta
LinkCmdCompile 0.27 ± 5% 0.25 ± 6% -8.22% (p=0.000 n=98+96)
LinkCmdGo 0.30 ± 6% 0.29 ± 8% -5.03% (p=0.000 n=95+99)
name old MaxRSS new MaxRSS delta
LinkCmdCompile 107k ± 2% 98k ± 3% -8.32% (p=0.000 n=99+100)
LinkCmdGo 106k ± 3% 104k ± 3% -1.94% (p=0.000 n=99+100)
Change-Id: I965eeee30541e724fd363804adcd6fda10f965a4
Reviewed-on: https://go-review.googlesource.com/31031
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
xfunc.Func.Nname.Name.Funcdepth = func_.Func.Depth
xfunc.Func.Depth = func_.Func.Depth
xfunc.Func.Endlineno = func_.Func.Endlineno
- makefuncsym(xfunc.Func.Nname.Sym)
+ if Ctxt.Flag_dynlink {
+ makefuncsym(xfunc.Func.Nname.Sym)
+ }
xfunc.Nbody.Set(func_.Nbody.Slice())
xfunc.Func.Dcl = append(func_.Func.Dcl, xfunc.Func.Dcl...)
Fatalf("funchdr: dclcontext = %d", dclcontext)
}
- if importpkg == nil && n.Func.Nname != nil {
+ if Ctxt.Flag_dynlink && importpkg == nil && n.Func.Nname != nil {
makefuncsym(n.Func.Nname.Sym)
}
}
s1 := Pkglookup(s.Name+"·f", s.Pkg)
+ if !Ctxt.Flag_dynlink && s1.Def == nil {
+ s1.Def = newfuncname(s1)
+ s1.Def.Func.Shortname = newname(s)
+ funcsyms = append(funcsyms, s1.Def)
+ }
s.Fsym = s1
return s1
}