如何增加 gcc 可执行堆栈大小?

发布于 2024-07-29 04:38:12 字数 134 浏览 2 评论 0原文

我有一个大型的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心的憧憬 2024-08-05 04:38:12

在 Linux 上,您可以在 /etc/security/limits.conf 中扩展堆栈大小。

您可以通过使用检查当前堆栈大小

$ ulimit -s
8192

然后将堆栈扩展为两倍:

youruser    soft    stack    16384

然后重新记录。

这将增加您正在运行的所有可执行文件的堆栈大小,而不仅仅是 GCC 的堆栈大小。

On Linux, you can expand the stack size in /etc/security/limits.conf.

You can check your current stack size by using

$ ulimit -s
8192

Then expand the stack to be double than that:

youruser    soft    stack    16384

And then relog.

This will increase stack size for all executable you're running, not just GCC's.

夜光 2024-08-05 04:38:12

我在我的编译器脚本中使用它:

CFLAGS += -Wl,--stack,10485760

I use that in my compiler script:

CFLAGS += -Wl,--stack,10485760

旧故 2024-08-05 04:38:12

堆栈大小可以在链接期间配置。 您应该查看有关链接器脚本的详细信息。 这只会改变单个程序的堆栈大小。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文