> -----Original Message-----
> From: John Seghers [mailto:
johnse@...]
> My point was not about how much those specific functions impacted
> the final product. My point was more about granularity in general.
> Function-level linkers handle this on a function-by-function basis
> whether the code is in a library or not.
As far as I'm aware redundant code is not present in the final binary with
optimisation >0. Certainly unreferenced data is removed and on the odd
occasion I've been confused by 'missing' code in my final roms which turned
out to be a typo resulting in code which did nothing.
> This becomes even more important with template libraries, since by
> definition the template class must be in the compilation unit where it
> is used. If you have 10 functions (each of similar complexity) to provide
> the implementation of the template, and your code uses the template
> to instantiate a class, but only uses 2 of those functions, you're stuck
> with code for all 10 being compiled.
This is something I have little experience with - I tend to avoid template
libraries like the plague since they seldom seem to have any consideration
for console platforms. The gcc linker should, given my experience with the
optimization of redundant code, remove unreferenced functions regardless of
the object file granularity.
> A linker that includes everything from a compilation unit in the final
> product will include all of this dead code. A linker that performs
> function-level linking will strip it out.
>
> The specific answer came that newlib is pretty granular--generally
> one function per file--which is good. The GCC tool chain developers,
> however, (whenever I've seen this issue debated) have basically said
> that if you want function-level linking, you have to do it manually--and
I'm not entirely convinced that this is necessary - it certainly warrants a
little research. It does seem to me that this will reduce compile & link
time by reducing the ammount of redundant material present in the object
files but since it appears to me that such material is removed from the
final binary in any case there would be little point in worrying about where
it happens.
Dave