[PATCH v4 0/5] add kconfirm
From: Julian Braha
Date: Sun Jul 26 2026 - 20:16:46 EST
kconfirm now uses the in-tree parser. Making this migration required a
modification to the parser that allows us to observe the parse tree before
its final simplification step, thus allowing us to detect dead code.
Since no external crates are now necessary, I’ve removed the Cargo requirement,
too.
I believe these changes should resolve the major questions, so I’ve
removed the RFC tag.
Now, onto the existing patch-set description since the RFCs:
===
kconfirm is a tool to detect misusage of Kconfig. It detects dead code,
constant conditions, and invalid (reverse) ranges. There are also optional
checks to detect config options that select visible config options, and to
check for dead links in the help texts.
See also kconfirm's original introduction to the mailing list:
https://lore.kernel.org/all/6ec4df6d-1445-48ca-8f54-1d1a83c4716d@xxxxxxxxx/
False Alarms:
kconfirm aims for zero false-positives, though this is not completely
feasible due to macro evaluation from the host environment, primarily
affecting host compiler-related options. There will also be some false
positives for dead link checks, as this depends on an internet connection,
and we do not attempt to bypass bot blocks. For this reason, dead link
checking is disabled by default, but I've provided an example below of how
to enable it. Additionally, you can view my previous message to the
mailing list with hand-verified dead links here:
https://lore.kernel.org/all/6732bf08-41ee-40c4-83b2-4ae8bc0da7cf@xxxxxxxxx/
Additionally, there is an optional check to detect config options that
select visible config options, as requested by Jani during the review of
the first RFC:
https://lore.kernel.org/all/dcb7439832f0bb35598fba653d922b5f6a4d0058@xxxxxxxxx/
Even after deduplicating across architectures, there are well over 1,000
instances of these select-visible cases, and I suspect that, despite the
Kconfig documentation saying select-visible should be avoided, some
exceptions will be made. So, I have left this check disabled by default,
keeping in line with the goal of having a low-noise checker. If interested
in using it, I have included an example below of how to enable this check.
Current State of Alarms:
With x86-64 on Linux v7.2-rc4 (which this RFC is based), there are 1282
alarms coming from the default set of checks, and an additional 976 alarms
if enabling the optional select-visible check. The last time I checked
linux-next (next-20260427), there were 81 unique dead links.
The most critical check is the dead default statements, which has surfaced
a few misconfiguration bugs (fortunately, just for kunit tests), see
examples:
https://lore.kernel.org/all/20260323124118.1414913-1-julianbraha@xxxxxxxxx/
and:
https://lore.kernel.org/all/20260323123536.1413732-1-julianbraha@xxxxxxxxx/
But hopefully kconfirm can ease maintenance and we can prevent more of
these from making it into the tree in the future.
Use it:
You can test out kconfirm with this patch series by compiling and running
kconfirm like this:
`make kconfirm`
To enable the select-visible check:
`KCONFIRM_ARGS="--enable-check select_visible" make kconfirm`
And to enable dead link checks in the help texts:
`KCONFIRM_ARGS="--enable-check dead_link" make kconfirm`
kconfirm by default runs on the same architecture as the kernel build
would. To run kconfirm on another architecture (for example, ARM with an
X86 host):
`ARCH=arm make kconfirm`
Thanks,
Julian Braha
---
Changes since RFC v3:
- Modify kconfig parser to make raw parse tree viewable to enable analysis
- Switch from external parser to in-tree kconfig parser (Demi)
- Add Rust bindings for kconfig
- Remove Cargo and external crates
- Make curl an optional dependency for optional dead link check (Arnd)
- Switch from libcurl to curl CLI for dead link checks (Miguel)
- Adhere to Rust-for-Linux style (Miguel)
- Add tests (Miguel)
- Move kconfirm under scripts/kconfig/ to resolve broken tab autocompletion (Nathan)
- Remove ungrouped attributes style check
- Add support for checking liveness of ftp and git URIs in help texts
- Dropped RFC tag
Link to RFC v3:
https://lore.kernel.org/all/20260516215354.449807-1-julianbraha@xxxxxxxxx/
Changes since RFC v2:
- Reduce Rust dependencies significantly (follows Demi's suggestions):
- from 6 direct dependencies to 1
- from 107 indirect dependencies to 4
- Replace ureq crate with usage of system libcurl (thanks Demi)
- Replace clap crate with FFI bindings to libc's getopt_long (also Demi)
- Remove crates env_logger, regex
- Switch from vendoring dependencies to requiring users to first download
outside of Make (as suggested by Miguel)
- Various makefile improvements (as pointed out by Nicolas):
- Fix out-of-tree builds
- Only delete kconfirm artifacts with 'distclean' and 'mrproper'
- Add myself as maintainer of kconfirm (as discussed with Nicolas)
- Remove dedicated code license file (pointed out by Jani)
- Update documentation to explain tool setup
- Add hint to users to check documentation and download tool dependencies
- Address sashiko's many code-level and documentation suggestions:
- Follow the kernel's rust import style
- Fix a dead_range/duplicate_range alarm mixup
- Fix potential duplicates in default value style check
- Avoid panicking on errors
- Clarify parse failure check usage in documentation
- Fix typo in documentation
- Can now enable architectures and disable the default (host) architecture in the CLI
Link to RFC v2:
https://lore.kernel.org/all/20260509203808.1142311-1-julianbraha@xxxxxxxxx/
Changes since RFC v1:
- vendored dependencies instead of requiring an internet connection
- removed Cargo.lock
- replaced reqwest dependency with smaller ureq
- removed rustls, expect user to have openssl instead
- added select-visible check based on Jani's feature request
- added invalid (reverse) range check
- deduplicating alarms that appear for multiple architectures
- `make clean` no longer deletes kconfirm's build artifacts
- typo fixes in documentation
- added patch description for the main "add kconfirm" patch (patch 1/2)
Link to RFC v1:
https://lore.kernel.org/all/20260427174429.779474-1-julianbraha@xxxxxxxxx/
---
Julian Braha (5):
kconfig: add add another callback to the parser to view raw parse tree
kconfig: add kconfirm
kconfirm: add tests
Documentation: add kconfirm
MAINTAINERS: add entry for kconfirm
Documentation/dev-tools/index.rst | 1 +
Documentation/dev-tools/kconfirm.rst | 229 ++++++
MAINTAINERS | 7 +
Makefile | 17 +-
scripts/kconfig/.gitignore | 1 +
scripts/kconfig/Makefile | 54 ++
scripts/kconfig/kconfig.rs | 445 +++++++++++
scripts/kconfig/kconfirm/.gitignore | 2 +
scripts/kconfig/kconfirm/analyze.rs | 340 ++++++++
scripts/kconfig/kconfirm/arch.rs | 53 ++
scripts/kconfig/kconfirm/checks.rs | 748 ++++++++++++++++++
scripts/kconfig/kconfirm/dead_links.rs | 230 ++++++
scripts/kconfig/kconfirm/kconfirm-cfg.sh | 57 ++
scripts/kconfig/kconfirm/kconfirm.rs | 278 +++++++
scripts/kconfig/kconfirm/output.rs | 87 ++
scripts/kconfig/kconfirm/symbol_table.rs | 105 +++
.../kconfig/kconfirm/tests/arch/arm/Kconfig | 9 +
.../kconfirm/tests/arch/powerpc/Kconfig | 4 +
.../kconfig/kconfirm/tests/arch/riscv/Kconfig | 9 +
.../kconfig/kconfirm/tests/arch/sh/Kconfig | 4 +
.../kconfirm/tests/arch/testarch/Kconfig | 4 +
.../kconfig/kconfirm/tests/arch/um/Kconfig | 4 +
.../kconfig/kconfirm/tests/arch/x86/Kconfig | 4 +
.../kconfirm/tests/architecture.Kconfig | 4 +
.../tests/architecture_common.Kconfig | 19 +
.../kconfirm/tests/conditional_prompt.Kconfig | 17 +
scripts/kconfig/kconfirm/tests/conftest.py | 93 +++
...nt_condition_negative_expression_1.Kconfig | 13 +
...nt_condition_negative_expression_2.Kconfig | 13 +
...nstant_condition_negative_symbol_1.Kconfig | 13 +
...nstant_condition_negative_symbol_2.Kconfig | 13 +
.../kconfig/kconfirm/tests/dead_link.Kconfig | 12 +
.../tests/default_categorization.Kconfig | 20 +
scripts/kconfig/kconfirm/tests/pytest.ini | 2 +
scripts/kconfig/kconfirm/tests/ranges.Kconfig | 39 +
.../kconfirm/tests/select_imply.Kconfig | 28 +
.../kconfig/kconfirm/tests/test_kconfirm.py | 358 +++++++++
scripts/kconfig/lkc_proto.h | 2 +
scripts/kconfig/parser.y | 21 +
39 files changed, 3357 insertions(+), 2 deletions(-)
create mode 100644 Documentation/dev-tools/kconfirm.rst
create mode 100644 scripts/kconfig/kconfig.rs
create mode 100644 scripts/kconfig/kconfirm/.gitignore
create mode 100644 scripts/kconfig/kconfirm/analyze.rs
create mode 100644 scripts/kconfig/kconfirm/arch.rs
create mode 100644 scripts/kconfig/kconfirm/checks.rs
create mode 100644 scripts/kconfig/kconfirm/dead_links.rs
create mode 100755 scripts/kconfig/kconfirm/kconfirm-cfg.sh
create mode 100644 scripts/kconfig/kconfirm/kconfirm.rs
create mode 100644 scripts/kconfig/kconfirm/output.rs
create mode 100644 scripts/kconfig/kconfirm/symbol_table.rs
create mode 100644 scripts/kconfig/kconfirm/tests/arch/arm/Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/arch/powerpc/Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/arch/riscv/Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/arch/sh/Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/arch/testarch/Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/arch/um/Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/arch/x86/Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/architecture.Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/architecture_common.Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/conditional_prompt.Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/conftest.py
create mode 100644 scripts/kconfig/kconfirm/tests/constant_condition/default_constant_condition_negative_expression_1.Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/constant_condition/default_constant_condition_negative_expression_2.Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/constant_condition/default_constant_condition_negative_symbol_1.Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/constant_condition/default_constant_condition_negative_symbol_2.Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/dead_link.Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/default_categorization.Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/pytest.ini
create mode 100644 scripts/kconfig/kconfirm/tests/ranges.Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/select_imply.Kconfig
create mode 100644 scripts/kconfig/kconfirm/tests/test_kconfirm.py
--
2.54.0