如何增加 gcc 可执行堆栈大小?
我有一个大型的 Boost/Spirit 元程序,当我尝试编译它时,它会破坏 gcc 的堆栈。
如何增加 gcc 的堆栈大小,以便可以编译该程序?
注意:没有无限递归发生,但有足够的附带递归来耗尽 gcc 的堆栈。
I have large Boost/Spirit metaprogram that is blowing gcc's stack when I try to compile it.
How can I increase gcc's stack size, so I can compile this program?
Note: There's no infinite recursion going on, but there is enough incidental recursion to exhaust gcc's stack.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 Linux 上,您可以在 /etc/security/limits.conf 中扩展堆栈大小。
您可以通过使用检查当前堆栈大小
然后将堆栈扩展为两倍:
然后重新记录。
这将增加您正在运行的所有可执行文件的堆栈大小,而不仅仅是 GCC 的堆栈大小。
On Linux, you can expand the stack size in /etc/security/limits.conf.
You can check your current stack size by using
Then expand the stack to be double than that:
And then relog.
This will increase stack size for all executable you're running, not just GCC's.
我在我的编译器脚本中使用它:
I use that in my compiler script:
堆栈大小可以在链接期间配置。 您应该查看有关链接器脚本的详细信息。 这只会改变单个程序的堆栈大小。
The stack size can be configured during linking. You should look at details regarding the linker scripts. That will only change the stack size for your single programme.