Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: enable linker dead code pruning when using reflect #25081

jim-minter opened this issue Apr 25, 2018 · 1 comment


Copy link

@jim-minter jim-minter commented Apr 25, 2018

Follow-up from

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 set of packages which use that type is statically determinable (e.g., the type doesn't leak from the package set via an exported identifier), and
  • no packages in the set reference reflect.Value.Call()

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.


This comment has been minimized.

Copy link

@jim-minter jim-minter commented Apr 25, 2018

@crawshaw as author of most of /src/cmd/link/internal/ld/deadcode.go, what's your take on the above?

@smarterclayton fyi

@FiloSottile FiloSottile changed the title Enable linker dead code pruning when using reflect cmd/link: enable linker dead code pruning when using reflect Apr 25, 2018
@FiloSottile FiloSottile added this to the Unplanned milestone Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.