功能级链接(VC ++中的/ Gy开关) - 它有什么好处? [英] Function-Level Linking (/Gy switch in VC++) - What is it good for?

查看:229
本文介绍了功能级链接(VC ++中的/ Gy开关) - 它有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在大型VS解决方案(200个VC项目)中使用此开关可以获得什么?



根据我的理解,这主要影响大小生成的二进制文件;但是除了更小的二进制文件,FLL还能帮助减少项目之间的依赖关系吗?



FLL通常如何影响构建时间?


$ b $我也喜欢在VC中有关FLL的教育性解释。 MSDN 的解释非常简短。 p>

解决方案

因为你链接MSDN的解释,你知道/ Gy确保所有函数都打包在自己的COMDAT。这样做的主要优点是,如果你有相同的功能,链接器可以将它们全部折叠成一个实际的代码段(COMDAT折叠)。当你有很多相同的函数时,这可能有非常大的影响,这通常是写你现在的C ++在模板上很重的情况。



除了较小的大小生成的可执行文件由于COMDAT折叠和消除未引用的COMDAT,没有其他效果/ Gy。具体来说,它不能帮助减少项目间的依赖关系。



代价是编译时间稍微增加(类似于其他优化器标志)。通常不是你会注意到的东西。


What is there to gain from the use of this switch in a large VS solution (200 VC projects)?

From what I understand this mainly affects the size of the resulting binaries; but aside from smaller binaries, could FLL also help in reducing dependencies between projects?

How does FLL usually affect build times?

I'd also appreciate an educated explanation on FLL in VC. MSDN's explanation is pretty brief.

解决方案

Since you linked MSDN's explanation, you know that /Gy ensures that all functions are packaged in their own COMDAT. The main advantage of this is that if you have identical functions the linker can collapse them all down into one actual piece of code ("COMDAT folding"). This can have very large impacts when you have many identical functions, which is often the case when you write modern C++ that is heavy on templates.

Aside from the smaller size of the resulting executable due to COMDAT folding and elimination of unreferenced COMDATs, there's no other effect of /Gy. To be specific, it doesn't help in reducing interproject dependencies.

The cost is a slight increase in compilation time (similar to other optimizer flags). Usually not something you'll notice.

这篇关于功能级链接(VC ++中的/ Gy开关) - 它有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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