How to increase the gcc executable stack size?

2019-02-12 14:06发布

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.

3条回答
SAY GOODBYE
2楼-- · 2019-02-12 14:39

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.

查看更多
仙女界的扛把子
3楼-- · 2019-02-12 14:49

I use that in my compiler script:

CFLAGS += -Wl,--stack,10485760

查看更多
Viruses.
4楼-- · 2019-02-12 14:51

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.

查看更多
登录 后发表回答