Or does it just make more sense to leave the optimization until you use the library, or is it when you link the library you are already past the point where the compiler can optimize the library?
views:
249answers:
2
+1
A:
If you want the code in the library optimised, you have to provide the optimisation flags when you compile the library, not when you link with it.
anon
2010-01-27 19:04:28
some of the gnu documentation suggests that you can get optimizations at link time too, which is what confuses me
ldog
2010-01-27 19:07:58
@gmatt The linker may be able to perform some very specialised optimisations, but the main ones (things like loop unrolling) need to be performed at compile time.
anon
2010-01-27 19:22:39
+2
A:
Code optimization happens primarily at compile time. So if you want your static library optimized, you need to do that when you build your library.
There are some optimizations that can happen at link time (although I'm not sure if the GNU linker implements them). But they are additional optimizations, so even if you wanted to use them, you would still want to compile time optimization.
R Samuel Klatchko
2010-01-27 19:04:30