开发者

g++ does it make sense to add optimization flag when compiling static library

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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜