gmake change the stack size limit

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 13:42:28

问题


If my current environment,

$ ulimit -s
10240

But if I run a process through gmake, the stack size is unlimited. For instance (the ;: is to make gmake use the shell to execute the command, otherwise it will try to find an executable by that name)

$ cat Makefile
default:
        ulimit -s; :
$ gmake
ulimit -s; :
unlimited
  • is it possible to get gmake not changing the limit?

  • if not, is it possible to reset the limit to what I want for all the rules without modifying them (while I may change the main Makefile, some rules comes from included files which are generated and changing the generation logic starts to bring its own problems).

Edit: @MadScientist learned me that it is a problem with 3.81 which is fixed in 3.82. But I'd still appreciate a work around.


回答1:


This sounds like https://savannah.gnu.org/bugs/?22010 fixed in GNU make 3.82.

If you can't update your version of GNU make (3.82 is, like, over 3 years old now...) and you can't backport the patch, you could try something like this (untested); create a shell script to modify the stack:

$ cat stacksh
#!/bin/sh
ulimit -s ...
exec /bin/sh "$@"

$ chmod 755 stacksh

Then in your makefile, reset SHELL to use your script:

SHELL := /path/to/stacksh

Now make will invoke your shell script to run commands, instead of /bin/sh




回答2:


That is a BUG, which is solved in 3.82, but 3.82 has other bugs.

It seems that make has a (very questionable, imho) only-every-4-years update policy. I guess most Linux distros will update their make not before late 2014.

I read this blog about a breaking bug in 3.82, which is fixed in this fork.



来源:https://stackoverflow.com/questions/16279867/gmake-change-the-stack-size-limit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!