Kai
Unused functions should be discarded by the linker.
There's definitely a reason. It might be a bug, but it's a reason.
It would help us if you made a copy of your program and pulled
things out until those disappear, to get down to a minimal
program that exhibits the bug.
Thanks.
Russ
I think I agree that in this case Unused should be dropped.
However, you're very near the edge. If t were, say,
stored in an interface value, then the type information
for t would include Unused, because some other package
might check and see if t satisfies interface { Unused() }.
I suspect the reason that Unused is kept is that the
same type information we'd store in the interface is
being saved in the debug information describing t's type.
That wasn't what I intended, but I suppose it would
let you 'print t.Unused()' in a sufficiently Go-aware
debugger.
Russ
I can't speak for the compiler developers, but I think it's safe to
assume that diagnosing and correctly handling this issue is a
relatively low priority. For instance, the size of the final binary is
not as important (to most Go developers) as having a better garbage
collector.
Fortunately, Go is an open source project with a liberal licence.
Motivated parties are welcome to investigate (as you have done),
provide detailed diagnoses for, and, in the best case, fix issues as
they arise.
Cheers,
Andrew
#2 tending toward #1, but probably not soon.
Fixing the problem, assuming it is a problem, will
require changing the format of the debug information
passed along to the linker so that it does not contain
a list of methods. That's a loss in functionality.
We're also in the middle of making the debug information
available in a format that gdb understands and will
probably need to make changes for that too.
I intend to wait and see what changes gdb needs
and then probably fix this at the same time.
Russ
Because the debug info is the reference to otherwise
unused functions that is keeping them in the binary.
Russ