This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Thoughts about static linking and reducing size of binaries


On Fri, Mar 16, 2001 at 12:25:16PM +1300, Bryce McKinlay wrote:
> Tom Tromey wrote:
> > 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.
> 
> I experimented with adding "-Wl,--gc-sections" to my static compilation
> line and it already makes the output a bit smaller. It looks like this is
> an ELF-only option though, so even if the compiler got better at emitting
> section-GCable output, it wouldn't be a portable solution (the situations
> that we really want small, static output are often not ELF targets?).
> Does it really work for virtual functions? Wouldn't java interface calls
> etc confuse it?

Just FYI:

You might want to take a look at libstdc++-v3/acinclude.m4's macro,
GLIBCPP_CHECK_LINKER_FEATURES.  It determines whether the GNU linker is
in use and whether its --gc-sections flag should be used (it's disabled on
debugging builds).  We wanted to use it in conjunction with the compiler's
-f*-sections flags to perform exactly this kind of optimization.

However, it doesn't work.  Last consensus was that the GC routines in the
linker were buggy.  We found that functions which do get called were being
incorrectly collected, and so we forced the acinclude.m4 macro to always
fail the test for the time being.  Someday, someday...


Phil

-- 
pedwards at disaster dot jaj dot com  |  pme at sources dot redhat dot com
devphil at several other less interesting addresses in various dot domains
The gods do not protect fools.  Fools are protected by more capable fools.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]