Skip to content

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

Merged
idrassi merged 2 commits into
veracrypt:masterfrom
flatstik:wxbuild-jobserver
Oct 10, 2026
Merged

idrassi merged 2 commits into
veracrypt:masterfrom
flatstik:wxbuild-jobserver

Conversation

@flatstik

@flatstik flatstik commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

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

This keeps -j 4 as the default for a standalone make, but leaves the job count to the parent when it was started with -j. The parent's MFLAGS then contains -j, -jN or the jobserver option, so the sub-make joins the parent's jobserver. MFLAGS is used rather than MAKEFLAGS because it holds only options, so a command-line variable whose value contains -j (e.g. make 'FOO=a -j3') can't match.

Single-letter options can be grouped in one MFLAGS word (GNU make 3.81 gives -sj for the -s this Makefile adds plus a bare -j), so the check looks for j in every single-dash option word, skipping the options that take an argument (-C, -E, -I, -O, -W, -f, -o). Known limitation, documented next to the variable: an option argument containing a space followed by -j (e.g. -I '/tmp/ordinary -j3') still looks like a job option, so that build inherits the parent's (serial) setting instead of using 4 jobs; WX_MAKE_JOBS can be set explicitly in that case.

The OpenWrt recipe in src/Build/Packaging/openwrt now passes $(PKG_JOBS) and an empty WX_MAKE_JOBS to wxbuild: OpenWrt clears MAKEFLAGS and passes the job count in PKG_JOBS, which can be empty for a serial build, so the empty WX_MAKE_JOBS makes the wxWidgets build follow OpenWrt's settings in every case.

Checked with GNU make 4.4.1:

invocation wx sub-make gets
make -j 4 (as before)
make -j8 the parent's -j8 and --jobserver-auth=...
make -j the parent's unlimited -j
make -j1 the parent's -j1 (serial; GNU make 4.2+, older makes do not record -j1 and give -j 4)
make -k, make -ks -j 4
make 'FOO=a -j3' -j 4
MFLAGS=-sj (GNU make 3.81, bare -j) the parent's unlimited -j
make -I/jail, -C/proj, -Otarget -j 4

The grouped MFLAGS forms were checked by evaluating the same expression with the MFLAGS values make 3.81 produces.

See also #717, which proposed dropping -j 4 for the same reason (closed by its author, not rejected). This version keeps the standalone default, so plain make builds aren't slowed down.

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 veracrypt#717, which proposed dropping -j 4 for the same reason.

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

flatstik commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@idrassi any comments on this? The OpenWrt build is still waiting for your decision for this

Comment thread src/Makefile Outdated
Comment thread src/Makefile
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>

@idrassi idrassi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. Looks good to me now.

@idrassi
idrassi merged commit 98ef739 into veracrypt:master Oct 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants