Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/link: enable linker dead code pruning when using reflect #25081
Follow-up from https://groups.google.com/d/topic/golang-nuts/syC4LpVf7sw
The link-time optimisation to prune unused methods is disabled when reflect.Value.Call() is used anywhere within a program.
With large codebases with many vendored libraries, it's hard to avoid including something which calls reflect.Value.Call(), e.g. anything that uses text/template.
This problem is causing serious bloat on kubernetes and openshift binaries.
One improvement that might be feasible is to enable pruning of methods of a type where:
The intention is to be able to prune methods which are provably non-reachable from any reflect.Value.Call() callpoint.
Such an improvement may be complex but I believe the commensurate reduction in binary sizes for projects such as kubernetes make it highly worth considering.