build: fix -j propagation to ninja

The expression containing MAKEFLAGS must be evaluated in a deferred
context for the propagation to work in GNU make. Otherwise, regardless
of the -j value passed to make, ninja will spawn a potentially greater
number of parallel compilation tasks, which can quickly exhaust all
available memory.

PR-URL: https://github.com/nodejs/node/pull/53088
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Tobias Nießen 2024-05-25 19:37:05 +02:00 committed by GitHub
parent 177b8b957b
commit 19f0bcaa62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -146,7 +146,8 @@ endif
ifdef JOBS
NINJA_ARGS := $(NINJA_ARGS) -j$(JOBS)
else
NINJA_ARGS := $(NINJA_ARGS) $(filter -j%,$(MAKEFLAGS))
IMMEDIATE_NINJA_ARGS := $(NINJA_ARGS)
NINJA_ARGS = $(IMMEDIATE_NINJA_ARGS) $(filter -j%,$(MAKEFLAGS))
endif
$(NODE_EXE): config.gypi out/Release/build.ninja
$(NINJA) -C out/Release $(NINJA_ARGS)