On Sat, Oct 17, 2026 at 02:32:09PM +0000, [email protected] wrote:
>> +dry-run := $(findstring n,$(firstword -$(MAKEFLAGS)))
>
>[Severity: Medium]
>Could this dry-run detection logic produce a false positive for common make
>arguments?
>
>If MAKEFLAGS starts with a long option containing 'n' (such as Kbuild's
>frequent default --no-print-directory), -$(MAKEFLAGS) evaluates to something
>like ---no-print-directory, and findstring erroneously matches the letter 'n'.
[...]
>Is it possible to use the standard Kbuild idiom here, like
>$(findstring n,$(filter-out --%,$(MAKEFLAGS))), to properly check the flags?

MAKEFLAGS does not start with a long option. With make 4.0 and later,
which the kernel requires, its first word holds the single letter
options and the long options follow after a space. With no single letter
options, -$(MAKEFLAGS) starts with "- --no-print-directory" and the
first word is "-". The top level Makefile detects -s the same way.

Under kbuild the first word is "-rR", as kbuild adds -rR to MAKEFLAGS. I
checked with make 4.4.1, calling Makefile.kbuild from a parent that adds
-rR --no-print-directory: dry-run is empty for a plain, -j, -k and -s
build, and is "n" only with -n.

-- 
Thanks,
Sasha

Reply via email to