make(1): limit memory usage in tests
There is a suspicious condition in SuffUpdateTarget code that looks wrong on the first sight. When removing it though, make allocates huge amounts of memory. To stop freezing the whole machine in this situation, limit the total memory. The limit of 200000 has been determined experimentally on NetBSD 8.0 x86_64. With a limit of 100000, make wouldn't even start. 100 MB of memory is really a lot for such a simple program that according to top(1) only needs 8 MB. But 200 MB is still better than 5 GB. Since the Makefile is used on other platforms as well, via the bmake distribution, and since every operating system has its own list of ulimit options, make this configurable.
This commit is contained in:
parent
b8a5a3568f
commit
6652031933
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.212 2020/11/21 10:32:42 rillig Exp $
|
||||
# $NetBSD: Makefile,v 1.213 2020/11/21 17:44:40 rillig Exp $
|
||||
#
|
||||
# Unit tests for make(1)
|
||||
#
|
||||
|
@ -516,6 +516,11 @@ LANG= C
|
|||
|
||||
MAKE_TEST_ENV?= MALLOC_OPTIONS="JA" # for jemalloc
|
||||
|
||||
.if ${:!uname -s!} == "NetBSD"
|
||||
LIMIT_RESOURCES?= ulimit -v 200000
|
||||
.endif
|
||||
LIMIT_RESOURCES?= :
|
||||
|
||||
# Each test is run in a sub-make, to keep the tests for interfering with
|
||||
# each other, and because they use different environment variables and
|
||||
# command line options.
|
||||
|
@ -523,6 +528,7 @@ MAKE_TEST_ENV?= MALLOC_OPTIONS="JA" # for jemalloc
|
|||
.mk.rawout:
|
||||
@${_MKMSG_TEST:Uecho '# test '} ${.PREFIX}
|
||||
@set -eu; \
|
||||
${LIMIT_RESOURCES}; \
|
||||
cd ${.OBJDIR}; \
|
||||
env -i PATH="$$PATH" ${MAKE_TEST_ENV} ${ENV.${.PREFIX:T}} \
|
||||
${TEST_MAKE} \
|
||||
|
|
Loading…
Reference in New Issue