Build: let a parent make control the wxWidgets build jobs (#1903)

* Build: let a parent make control the wxWidgets build jobs

The wxbuild target always runs the wxWidgets sub-make with -j 4. When
VeraCrypt is built from a parent "make -jN" (for example by a
distribution or embedded build system), the explicit -j 4 overrides the
parent's job count and jobserver: the wx build ignores -j1 and the
configured parallelism and can oversubscribe the machine.

Keep -j 4 as the default for a standalone build, but leave the job count
to the parent make when it was started with -j: MFLAGS then contains -j,
-jN or the jobserver option (-j1 since GNU make 4.2; older makes treat a
-j1 parent like a serial one without -j). MFLAGS is used rather than
MAKEFLAGS because it holds only options, not command-line variable
definitions, so a variable value containing "-j" cannot match.

See also #717, which proposed dropping -j 4 for the same reason.

Signed-off-by: Ville Takio <ville+git@takio.fi>

* Build: also detect grouped -j flags; pass OpenWrt jobs to wxbuild

Address review:

- GNU make 3.81 can group single-letter options in MFLAGS, e.g. "-sj"
  for the -s this Makefile adds plus a bare -j, which the previous
  pattern missed. Look for "j" in every single-dash option word instead,
  skipping the options that take an argument (-C, -E, -I, -O, -W, -f,
  -o). An option argument containing a space followed by "-j" can still
  be mistaken for a job option; this is documented next to the variable.
- The OpenWrt recipe built wxWidgets without the package's job settings,
  so it still ran 4 jobs. Pass $(PKG_JOBS) and an empty WX_MAKE_JOBS, so
  the wxWidgets build follows OpenWrt's settings, including serial
  builds.

Signed-off-by: Ville Takio <ville+git@takio.fi>

---------

Signed-off-by: Ville Takio <ville+git@takio.fi>
This commit is contained in:
Ville Takio
2026-10-10 12:10:26 +09:00
committed by GitHub
parent 37ce73775f
commit 98ef739cd8
2 changed files with 12 additions and 2 deletions
@@ -74,7 +74,7 @@ VC_COMMON_MAKE_FLAGS = \
define Build/Compile
+$(MAKE) -C "$(PKG_BUILD_DIR)/veracrypt/src" $(VC_COMMON_MAKE_FLAGS) clean
+$(MAKE) -C "$(PKG_BUILD_DIR)/veracrypt/src" $(VC_COMMON_MAKE_FLAGS) wxbuild
+$(MAKE) -C "$(PKG_BUILD_DIR)/veracrypt/src" $(PKG_JOBS) $(VC_COMMON_MAKE_FLAGS) WX_MAKE_JOBS= wxbuild
+$(MAKE) -C "$(PKG_BUILD_DIR)/veracrypt/src" $(PKG_JOBS) $(VC_COMMON_MAKE_FLAGS)
endef
+11 -1
View File
@@ -726,6 +726,16 @@ CXXFLAGS :=
LFLAGS :=
endif
# The wxWidgets build runs 4 jobs by default, but follows the job count and
# jobserver of a parent "make -jN" (e.g. a distribution package build).
# MFLAGS may group single-letter options into one word (GNU make 3.81 gives
# "-sj" for "-s -j"), so look for "j" in every single-dash option word,
# skipping the options that take an argument. An argument that contains a
# space followed by "-j" (e.g. -I '/x -j3') still looks like a job option;
# set WX_MAKE_JOBS explicitly in that case.
WX_MAKE_OPTS = $(filter-out --% -C% -E% -I% -O% -W% -f% -o%,$(filter -%,$(MFLAGS)))
WX_MAKE_JOBS = $(if $(findstring j,$(WX_MAKE_OPTS))$(filter --jobserver%,$(MFLAGS)),,-j 4)
wxbuild:
ifneq "$(shell test -f $(WX_ROOT)/configure || test -f $(WX_BUILD_DIR)/../configure && echo 1)" "1"
@@ -746,4 +756,4 @@ endif
"$(WX_ROOT)/configure" $(WX_CONFIGURE_FLAGS) $(WX_CONFIGURE_EXTRA_FLAGS) $$WX_CONFIGURE_LEGACY_FLAGS >/dev/null
@echo Building wxWidgets library...
cd "$(WX_BUILD_DIR)" && $(MAKE) -j 4
cd "$(WX_BUILD_DIR)" && $(MAKE) $(WX_MAKE_JOBS)