I have large Boost/Spirit metaprogram that is blowing gcc's stack when I try to compile it.
当我尝试编译它时,我有大量的Boost / Spirit元程序正在吹gcc的堆栈。
How can I increase gcc's stack size, so I can compile this program?
如何增加gcc的堆栈大小,以便编译该程序?
Note: There's no infinite recursion going on, but there is enough incidental recursion to exhaust gcc's stack.
注意:没有无限递归,但有足够的偶然递归来耗尽gcc的堆栈。
3 个解决方案
#1
On Linux, you can expand the stack size in /etc/security/limits.conf.
在Linux上,您可以在/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.
这将增加您运行的所有可执行文件的堆栈大小,而不仅仅是GCC。
#2
I use that in my compiler script:
我在我的编译器脚本中使用它:
CFLAGS += -Wl,--stack,10485760
CFLAGS + = -Wl, - stack,10485760
#3
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.
可以在链接期间配置堆栈大小。您应该查看有关链接器脚本的详细信息。这只会改变单个程序的堆栈大小。
#1
On Linux, you can expand the stack size in /etc/security/limits.conf.
在Linux上,您可以在/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.
这将增加您运行的所有可执行文件的堆栈大小,而不仅仅是GCC。
#2
I use that in my compiler script:
我在我的编译器脚本中使用它:
CFLAGS += -Wl,--stack,10485760
CFLAGS + = -Wl, - stack,10485760
#3
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.
可以在链接期间配置堆栈大小。您应该查看有关链接器脚本的详细信息。这只会改变单个程序的堆栈大小。