cmd/link: enable linker dead code pruning when using reflect #25081
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
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.
The text was updated successfully, but these errors were encountered: