Thoughts about static linking and reducing size of binaries
Tom Tromey
tromey@redhat.com
Wed Mar 14 21:43:00 GMT 2001
>>>>> "Bryce" == Bryce McKinlay <bryce@albatross.co.nz> writes:
Bryce> Is it possible to have the linker bring in only a given set of
Bryce> classes at link time, and treat other references as weak
Bryce> symbols? I'm sure this could be done at the compiler level, but
Bryce> we wouldn't want to have to recompile parts of libgcj just to
Bryce> re-link an application.
The GNU linker already has a "section GC" feature. The C++ compiler
can put every function (including virtual functions) into its own
section, and then let the linker only link in the minimal required
set.
We've wanted to implement this in gcj for a long time. However, it
has never been a priority. Also I believe implementing it is a lot of
work, though take this with a grain of salt since I have never looked
at it personally.
In addition to this we've occasionally discussed having some way to
configure libgcj itself according to some set of criteria. This is
sort of vague, but the idea is that the library builder could say "I
don't want java.net" or "I'll never use reflection", and then this
would change how libgcj is built. For instance, if we leave out
reflection then that would make the resulting library even smaller
than could be achieved via section GC (I think). For this feature
choosing the appropriate configuration points is hard, as is figuring
out how to actually implement it.
I'm not too concerned about requiring a libgcj rebuild in those cases
where a really drastic size reduction is required. I'm guessing that
those cases will be pretty rare, and that section GC will provide
enough for most people.
Tom
More information about the Java
mailing list