From 98ef739cd87a40175f369fa7d7094b71abe361ff Mon Sep 17 00:00:00 2001 From: Ville Takio <93599126+flatstik@users.noreply.github.com> Date: Sat, 10 Oct 2026 03:10:26 +0000 Subject: [PATCH] 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 * 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 --------- Signed-off-by: Ville Takio --- .../openwrt/package/utils/veracrypt/Makefile.in | 2 +- src/Makefile | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Build/Packaging/openwrt/package/utils/veracrypt/Makefile.in b/src/Build/Packaging/openwrt/package/utils/veracrypt/Makefile.in index 6b73e8e0..a914b338 100644 --- a/src/Build/Packaging/openwrt/package/utils/veracrypt/Makefile.in +++ b/src/Build/Packaging/openwrt/package/utils/veracrypt/Makefile.in @@ -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 diff --git a/src/Makefile b/src/Makefile index 7c15e5a3..43d77ac6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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)