简体   繁体   English

慢速连结阶段

[英]Slow linking stage

Ok guys, I'm having a really unexpected behavior here. 好的,我在这里有一个非常意外的行为 Working with a medium size legacy code project I've noticed that compilation was unreasonable slow. 我注意到使用中等大小的遗留代码项目时,编译的速度很慢。 Precompiled header is used but it's usefulness is questionable. 使用了预编译的头,但是它的有用性值得怀疑。 Anyway, it was fine util I decided to build the project in Release mode. 无论如何,这很好,我决定以发布模式构建项目。 Compilation lasted about 1.5 hours and then linking stage: ~2 hours with total RAM used by the linker ~1.3 GB. 编译持续了大约1.5个小时,然后是链接阶段: 〜2小时 ,链接器使用的总RAM约为1.3 GB。 Looking at generated *.obj files you can say that something went wrong — their sizes varied from 20 to 50 MB although actual processed files were relatively small. 查看生成的* .obj文件,您可以说出错了-尽管实际处理的文件相对较小,但是它们的大小在20到50 MB之间。 Verbose linker output doesn't say much: 详细的链接器输出内容不多:

Starting pass 1
Processed /DEFAULTLIB:msvcprt
Processed /DEFAULTLIB:uuid.lib
Processed /DEFAULTLIB:OLDNAMES
*prints nothing for a long time*
Processed /DEFAULTLIB:ws2_32.lib
Processed /DEFAULTLIB:mswsock.lib
*prints nothing for an hour*
...

So I have a couple of questions: 所以我有几个问题:

  • Can large *.obj files cause such slow linkage? 大型* .obj文件会导致这种缓慢的链接吗?
  • Could adding more headers into precompiled make compilation and linking faster? 可以在预编译中添加更多标头使编译和链接速度更快吗?
  • What else should I try? 我还应该尝试什么?

Any help would be greatly appreciated. 任何帮助将不胜感激。

Apparently gcc compiler treats "prefix" headers in a different way vc++ treats precompiled header. 显然,gcc编译器以vc ++对待预编译头的不同方式对待“前缀”头。 Just as I thought, adding more headers to precompiled increased it's size to almost 500 MB but generated object files became much smaller and compilation/linking became much faster (although linking duration is about 2-3 minutes now which is not optimal but not as bad as before). 就像我想的那样,向预编译添加更多的标头将其大小增加到将近500 MB,但是生成的目标文件变得更小,编译/链接变得更快(尽管链接持续时间现在约为2-3分钟,这不是最佳选择,但还不算太糟)像以前一样)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM