Skip to content

Commit

Permalink
backend/ninja: use 32k byte limit for command lines on !Windows
Browse files Browse the repository at this point in the history
At an OS level, Unix-like OSes usually have very large or even
unlimited sized command line limits. In practice, however, many
applications do not handle this (intentionally or otherwise). Notably
Wine has the same limits Windows does, 32,768 characters. Because we
previously double counted most characters, we papered over most
situations that we would need an RSP file on Unix-like OSes with Wine.

To fix this issue I have set the command line limit to 32k, this is
still a massive command line to pass without an RSP file, and will only
cause the use of an RSP file where it is not strictly necessary in a
small number of cases, but will fix Wine applications. Projects who wish
to not use an RSP file can still set the MESON_RSP_THRESHOLD environment
variable to a very large number instead.

Fixes: mesonbuild#13414
Fixes: cf0fecf ("backend/ninja: Fix bug in NinjaRule.length_estimate")
  • Loading branch information
dcbaker committed Jul 25, 2024
1 parent 68ddcf4 commit 03e865b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ def get_rsp_threshold() -> int:
# and that has a limit of 8k.
limit = 8192
else:
# On Linux, ninja always passes the commandline as a single
# big string to /bin/sh, and the kernel limits the size of a
# single argument; see MAX_ARG_STRLEN
limit = 131072
# Unix-like OSes usualy have very large command line limits, (On Linux,
# for example, this is limited by the kernel's MAX_ARG_STRLEN). However,
# some programs place much lower limits, notably Wine which enforces a
# 32k limit like Windows. Therefore, we limit the command line to 32k.
limit = 32768
# Be conservative
limit = limit // 2
return int(os.environ.get('MESON_RSP_THRESHOLD', limit))
Expand Down

0 comments on commit 03e865b

Please sign in to comment.