You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example, internal/abi.(*SwissMapType).NeedKeyUpdate. It has a 3-instruction body and gets inlined everywhere. There is no reference to it from any code. But it still exists in the binary.
Probably this is because it is exported (starts with a capital letter), and the type *SwissMapType is reachable somehow.
Kind of anecdotal at the moment, but this may be the cause of part of the binary size increase since 1.23.
It would be easy to change cmd/compile/internal/noder/lex.go to respect //go:nointerface in runtime packages, and then mark the methods with //go:nointerface.
changed the title [-]cmd/link: unused functions aren't getting deadcoded from the binary[/-][+]cmd/link: unused runtime-internal exported methods aren't getting deadcoded[/+]on Dec 4, 2024
It would be easy to change cmd/compile/internal/noder/lex.go to respect //go:nointerface in runtime packages, and then mark the methods with //go:nointerface.
Sure, I just worry that
There might be a lot of them
People will forget to add that annotation as new methods/types are added
Activity
thanm commentedon Dec 4, 2024
Interesting problem. Output from "-ldflags=-dumpdep" seems to say
I wonder if we need a new "only exported within the runtime" flavor of "exported".
rsc commentedon Dec 4, 2024
It would be easy to change cmd/compile/internal/noder/lex.go to respect //go:nointerface in runtime packages, and then mark the methods with //go:nointerface.
[-]cmd/link: unused functions aren't getting deadcoded from the binary[/-][+]cmd/link: unused runtime-internal exported methods aren't getting deadcoded[/+]rsc commentedon Dec 4, 2024
(Or we could try to figure out why SwissMapType is used in an interface.)
randall77 commentedon Dec 4, 2024
Sure, I just worry that
rsc commentedon Dec 4, 2024
We could also try making all the runtime packages nointerface by default and see what breaks. :-)
nightlyone commentedon Feb 14, 2025
Or turn it from method into a function if it never needs to satisfy any interface.