Hi Nicolas,

On Wed, 11 Nov 2026, Nicolas Schier wrote:
>
> On Mon, Nov 09, 2026 at 02:18:49PM +0100, Ahmed S. Darwish wrote:
> >
> > This is why one of the development rules at the top of the Python script,
> > at patch 03/10, is:
> >
> >   The tool must not depend on being run inside the kernel source tree.
> >   This simplifies invocation, testing and possible future packaging.
>
> Then, please move the argument checking from Makefile to the script
> itself.  Handling wrong arguments is good native feature for the script.
>

The script does its own argument checking, all through Python's native
argparse mechanism:

    $ ./tools/kconfig-checker/check.py check -h
    usage: check.py check [-h] -c KCONFIG_FILE -r RULES [-o OVERLAY_FILE]

    options:
      -h, --help            show this help message and exit
      -c, --config KCONFIG_FILE
                            .config file to be checked
      -r, --rules RULES     rules file to check against
      -o, --overlay OVERLAY_FILE
                            file overlay over picked rules

    $ ./tools/kconfig-checker/check.py check -r safety

    usage: check.py check [-h] -c KCONFIG_FILE -r RULES [-o OVERLAY_FILE]

    check.py check: error: argument -r/--rules: invalid choice: 'safety'
    (choose from 'preempt_rt')

And that's by design, as an independent tool that can be later packaged.

Regarding the Makefile's own error handling, I'll touch upon that below.

> As far as I have seen when skimming through the kconfig policy checker
> code, it does not use any Kbuild variables.  So, if it is being placed
> below tools/ and does not use Kbuild at all, and is expected to be run
> w/o Linux tree context at all: why do we need an additional top-level
> Makefile target for it at all (alongside of
> 'make tools/kconfig-policy-checker')?

The reason is the expected kernel configuration workflow, e.g.:

    $ make defconfig                    # Generate a default .config
    $ make debug.config                 # Add debug options to it
    $ make menuconfig                   # Manually customize it

    $ make RULES=preempt_rt checkconfig # Validate it
    $ make menuconfig                   # Follow checkconfig advice
    $ make RULES=preempt_rt checkconfig # Try again..

and so on.

So the "checkconfig" target fits that workflow, even when the checker
itself does not depend on any Kbuild internals.

The Makefile-side validation is also there to improve error handling for
that workflow:

    $ make checkconfig

    Usage: make RULES=<profile> [OVERLAY=<overlay>] checkconfig
    Available RULES: preempt_rt

    make[2]: *** [scripts/kconfig/Makefile:138: checkconfig] Error 2

Without it, the user just sees the lower-level script errors:

    $ make checkconfig

    usage: check.py check [-h] -c KCONFIG_FILE -r RULES [-o OVERLAY_FILE]
    check.py check: error: argument -r/--rules: invalid choice: '' (choose from 
'preempt_rt')

Both error messages are correct, but the former informs the user, exactly,
on how to call the Makefile target.  This matches the aforementioned kernel
configuration workflow as well.

I hope this clarifies things a bit.

Thank you!

--
Ahmed S. Darwish
Linutronix GmbH

Reply via email to