如何提高VS2005中大型C ++应用程序的链接性能 [英] How to improve link performance for a large C++ application in VS2005

查看:179
本文介绍了如何提高VS2005中大型C ++应用程序的链接性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有相当大的C ++应用程序,它由Visual Studio 2005中的大约60个项目组成。目前需要7分钟链接到发布模式,我想尝试减少时间。是否有任何改进链接时间的提示?



大多数项目都编译为静态库,这使得测试更容易,因为每个项目都有一组相关的单元测试。看起来静态库的使用防止VS2005使用增量链接,所以即使增量链接开启,它每次都会完全链接。



将使用DLL作为子项目有什么区别?我真的不想通过所有的标题,并添加宏导出符号(即使使用脚本),但如果它会做一些减少7分钟的链接时间,我一定会考虑它。



由于某种原因,使用nmake从命令行稍快,在Linux(与GCC)上链接相同的应用程序要快得多。




  • Visual Studio IDE 7分钟

  • Visual C ++使用nmake命令行 - 5分钟

  • 如果您使用的是 .microsoft.com / en-us / library / 0zza0de8.aspx> / GL 标志启用全程序优化(WPO) http://msdn.microsoft.com/en-us/library/xbf3tbeh.aspx> / LTCG 标志以启用链接时间代码生成,翻转



    此外,如果您使用的是 / Z7 标记将调试符号放入 .obj 文件,你的静态库可能是巨大的。使用 / Zi 创建单独的 .pdb 文件可能有助于防止链接器从磁盘读取所有调试符号。我不知道它是否真的有帮助,因为我没有基准。


    We have fairly large C++ application which is composed of about 60 projects in Visual Studio 2005. It currently takes 7 minutes to link in Release mode and I would like to try to reduce the time. Are there any tips for improving the link time?

    Most of the projects compile to static libraries, this makes testing easier since each one also has a set of associated unit tests. It seems the use of static libraries prevents VS2005 from using incremental linking, so even with incremental linking turned on it does a full link every time.

    Would using DLLs for the sub projects make any difference? I don't really want to go through all the headers and add macros to export the symbols (even using a script) but if it would do something to reduce the 7 minute link time I will certainly consider it.

    For some reason using nmake from the command line is slightly faster and linking the same application on Linux (with GCC) is much faster.

    • Visual Studio IDE 7 minutes
    • Visual C++ using nmake from the command line - 5 minutes
    • GCC on Linux 34 seconds

    解决方案

    If you're using the /GL flag to enable Whole Program Optimization (WPO) or the /LTCG flag to enable Link Time Code Generation, turning them off will improve link times significantly, at the expense of some optimizations.

    Also, if you're using the /Z7 flag to put debug symbols in the .obj files, your static libraries are probably huge. Using /Zi to create separate .pdb files might help if it prevents the linker from reading all of the debug symbols from disk. I'm not sure if it actually does help because I have not benchmarked it.

    这篇关于如何提高VS2005中大型C ++应用程序的链接性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆