简体   繁体   English

MSVS 编译器标志 /bigobj 的惩罚

[英]Penalty of the MSVS compiler flag /bigobj

The basic Google search bigobj issue shows that a lot of people are experiencing the Fatal Error C1128 : " number of sections exceeded object file format limit : compile with /bigobj ".基本的 Google 搜索bigobj 问题表明,很多人都遇到了致命错误 C1128 :“节数超出目标文件格式限制:使用 /bigobj 编译”。 The error has more chance to occur if one heavily uses a library of C++ templates, like Boost libraries or CGAL libraries .如果大量使用 C++ 模板(如Boost 库CGAL 库) ,则该错误发生的可能性更大。

That error is strange, because it gives the solution to itself: set the compiler flag /bigobj !这个错误很奇怪,因为它为自己提供了解决方案:设置编译器标志/bigobj

So here is my question: why is not that flag set by default?所以这是我的问题:为什么默认情况下不设置该标志? There must be a penalty of using that flag, otherwise it would be set by default.必须有使用该标志的惩罚,否则它会被默认设置。 That penalty is not documented in MSDN. MSDN 中没有记录这种惩罚。 Does anybody have a clue?有人有线索吗?

I ask the question because I wonder if the configuration system of CGAL should not set /bigobj by default.我问这个问题是因为我想知道CGAL的配置系统是否应该默认设置/bigobj

The documentation does mention an important drawback to /bigobj : 文档确实提到了/bigobj一个重要缺点:

Linkers that shipped prior to Visual C++ 2005 cannot read .obj files that were produced with /bigobj . 在Visual C ++ 2005之前发布的链接器无法读取使用/bigobj生成的.obj文件。

So, setting this option by default would restrict the number of linkers that can consume the resulting object files. 因此,默认情况下设置此选项会限制可以使用生成的对象文件的链接器数量。 Better to activate it on a need-to basis. 最好在需要的基础上激活它。

why is not that flag set by default?为什么默认情况下不设置该标志? There must be a penalty of using that flag, otherwise it would be set by default.必须有使用该标志的惩罚,否则它会被默认设置。

My quick informal experiment shows .obj files to be about 2% larger with /bigobj than without.我的快速非正式实验表明,使用/bigobj .obj 文件比不使用时大 2%。 So it's a small penalty but it's not zero.所以这是一个很小的惩罚,但不是零。

Someone submitted a feature request to make /bigobj the default;有人提交了一个功能请求,将/bigobj默认值; see https://developercommunity.visualstudio.com/t/Enable-bigobj-by-default/1031214 .请参阅https://developercommunity.visualstudio.com/t/Enable-bigobj-by-default/1031214

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

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