GCC 相当于 MS 的/bigobj
我们正在大量使用 boost::serialization
和一般的模板.一切似乎都很顺利.
We are making heavy use of boost::serialization
and templates in general. All seems to be going well.
除此之外,我们在 Windows 版本上遇到了障碍.这似乎会导致目标文件过大的问题.我们正在使用带有 g++ 4.7.0 的 MinGW/Msys.
Except, we've hit a snag on our Windows builds. It seems to cause issues in the object files being too large. We're using MinGW/Msys with g++ 4.7.0.
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/as.exe: CMakeFiles/source.dir/sourcecode.cpp.obj: too many sections (33396)
C:UsersusernameAppDataLocalTempccnAocvD.s: Assembler messages:
C:UsersusernameAppDataLocalTempccnAocvD.s: Fatal error: can't write CMakeFiles/source.dir/sourcecode.cpp.obj: File too big
谷歌大师透露了这条存档消息,http://sourceforge.net/mailarchive/forum.php?thread_name=CA%2Bsc5mkLvj%3DW9w2%3DsY%3Dc_N%3DEwnsQuPDEX%3DiBcbsbxS34C0mail_5Bg;=mingw-用户
Master google revealed this archived message, http://sourceforge.net/mailarchive/forum.php?thread_name=CA%2Bsc5mkLvj%3DW9w2%3DsY%3Dc_N%3DEwnsQuPDEX%3DiBcbsbxS3CuE_5Bg%40mail.gmail.com&forum_name=mingw-users
在其中,它表明另一个人击中了几乎相同的障碍.它确实指向 Visual Studio 的 /bigobj
选项的一个选项,该选项似乎可以满足我们的需要.但是,我们无法迁移到 Visual Studio.
In it, it indicates that another person hit pretty much the same snag. It did point to an option for Visual Studio's /bigobj
option which appears to do what we would need. However, we're unable to move to Visual Studio.
一个建议是将 --hash-size 添加到汇编器选项中.这没有帮助.
One suggestion was to add --hash-size to the assembler options. This did not help.
如果我没记错的话,问题在于目标文件中的条目限制为 2^16 个.实际上,根据错误消息,我敢说这是一个签名的 2^16 条目,但那是花生.Visual Studio 的 /bigobj
选项会将其更改为 2^32.邮件列表结果不知道 GCC 的等效选项.进一步的谷歌结果似乎与此无关.
If I'm not mistaken, the issue lies in the fact that the object files have a limit of 2^16 entries in them. Actually, according to the error message, I would venture that it's a signed 2^16 entries, but that's peanuts. The /bigobj
option for Visual Studio would change that to 2^32. The mailing list result did not know of an equivalent option for GCC. Further google results don't appear to be relevant to this.
此时我们将不得不重构我们的代码(呃)来解决这个限制.但我仍然担心,如果使用繁重的模板,我们可能会一次又一次地遇到这个问题(我们已经用三个源文件遇到了这个问题).
At this point we'll have to refactor our code (ugh) to get around this limitation. But I am still concerned that, with heavy templating, we could run into the issue again and again (we've already run into it with three source files).
所以我的问题是这样的;是否有等效于 Microsoft /bigobj
选项的 GCC?我还没有找到第三个选项吗?
So my question is thus; is there a GCC equivalent to Microsoft's /bigobj
option? Is there a third option that I'm not yet found?
推荐答案
解决方案是添加选项 -Wa,-mbig-obj
如果您的 GCC 版本支持该选项.您可能只在编译步骤中需要它,而不是在链接器步骤中.
The solution is to add the option -Wa,-mbig-obj
if your version of GCC supports that option. You probably only need it during the compilation step, not the linker step.
如果您的编译器不支持该选项,您应该考虑使用 mingw-w64 和 MSYS2.
If your compiler does not support that option, you should look into using mingw-w64 and MSYS2.
相关文章