add kconfirm
Subsystems (6)
Julian Braha
reviewerv4 cover add kconfirm
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/[email protected]/
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/[email protected]/
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/[email protected]/
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/[email protected]/
and:
https://lore.kernel.org/all/[email protected]/
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/[email protected]/
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/[email protected]/
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/[email protected]/
---
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
Signature · 1 line
2.54.0
Julian Braha
reviewerPATCH v4 1/5 kconfig: add add another callback to the parser to view raw parse tree
The final step of the Kconfig parser is to call menu_finalize(), which will evaluate the dead code that static code analyzers like kconfirm need to be able to view.
This patch adds another callback to the parser just before this call to menu_finalize(), making the raw parse tree viewable as necessary to callers of conf_set_pre_finalize_callback().
--- scripts/kconfig/lkc_proto.h | 2 ++ scripts/kconfig/parser.y | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+)
scripts/kconfig/lkc_proto.h +2 -0
@@ -6,6 +6,8 @@/* confdata.c */ void conf_parse (const char *name); +void conf_set_pre_finalize_callback (void (*fn)(const struct menu *root,void *data), +void *data);int conf_read (const char *name);int conf_read_simple (const char *name,int );int conf_write_defconfig (const char *name);
scripts/kconfig/parser.y +21 -0
@@ -28,6 +28,9 @@ static void zconf_error(const char *err, ...); static bool zconf_endtoken(const char *tokenname, const char *expected_tokenname); +static void (*conf_pre_finalize_callback)(const struct menu *root, void *data); +static void *conf_pre_finalize_callback_data; + struct menu *current_menu, *current_entry, *current_choice; %}
@@ -551,6 +554,20 @@ static int choice_check_sanity(const struct menu *menu) return ret; } +/* + * Register a callback to be invoked by conf_parse() once parsing has finished, + * but before menu_finalize() propagates dependencies and simplifies + * expressions. This hands the callback the menu tree as it was written in the + * Kconfig source files, which is what static analysis tools like kconfirm + * need. Passing NULL unregisters the callback. + */ +void conf_set_pre_finalize_callback(void (*fn)(const struct menu *root, void *data), + void *data) +{ + conf_pre_finalize_callback = fn; + conf_pre_finalize_callback_data = fn ? data : NULL; +} + void conf_parse(const char *name) { struct menu *menu;
@@ -587,6 +604,10 @@ void conf_parse(const char *name) menu_add_prompt(P_MENU, "Main menu", NULL); } + if (conf_pre_finalize_callback) + conf_pre_finalize_callback(&rootmenu, + conf_pre_finalize_callback_data); + menu_finalize(); menu_for_each_entry(menu) {
Signature · 1 line
2.54.0
Julian Braha
reviewerPATCH v4 2/5 kconfig: add kconfirm
In reply to Julian BrahaAdd kconfirm into scripts/kconfig/
kconfirm is a static analysis tool with various checks for Kconfig, and intended to have zero false alarms by default, though some are expected for host compiler-related config options due to macro expansion. The default checks currently include dead code, constant conditions, and invalid (reverse) ranges.
There are also optional checks for dead links in the help texts, and for config options that select visible config options.
kconfirm runs semantic analysis on the unsimplified parse tree that the Kconfig parser provides. Config option definitions are collected into its symbol table, and checks run from there using informed heuristics. The dead link check uses the curl CLI to check the liveness of links, and is optional.
--- 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 ++++ 13 files changed, 2415 insertions(+), 2 deletions(-) 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
Makefile +15 -2
@@ -298,7 +298,7 @@ no-dot-config-targets := $(clean-targets) \ %asm-generic kernelversion %src-pkg dt_binding_check \ dt_style_selftest \ outputmakefile rustavailable rustfmt rustfmtcheck \ - run-command + run-command kconfirm kconfirmtest no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \ image_name single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %/
@@ -1879,6 +1879,7 @@ help: @echo ' headerdep - Detect inclusion cycles in headers' @echo ' coccicheck - Check with Coccinelle' @echo ' kconfig-sym-check - Check for dangling Kconfig symbol references' + @echo ' kconfirm - Run static analysis on the Kconfig tree' @echo ' clang-analyzer - Check with clang static analyzer' @echo ' clang-tidy - Check with clang-tidy' @echo ''
@@ -2328,7 +2329,7 @@ endif # Scripts to check various things for consistency # --------------------------------------------------------------------------- -PHONY += includecheck versioncheck coccicheck kconfig-sym-check +PHONY += includecheck versioncheck coccicheck kconfig-sym-check kconfirm kconfirmtest includecheck: find $(srctree)/* $(RCS_FIND_IGNORE) \
@@ -2346,6 +2347,18 @@ coccicheck: kconfig-sym-check: $(Q)$(PERL) $(srctree)/scripts/kconfig/kconfig-sym-check.pl $(srctree) $(KCONFIG_SYM_CHECK_EXCLUDES) +kconfirm-hostrustc = $(if $(filter 1,$(KBUILD_CLIPPY)),HOSTRUSTC=$(CLIPPY_DRIVER)) + +kconfirm: export CC_VERSION_TEXT := $(CC_VERSION_TEXT) +kconfirm: export RUSTC_VERSION_TEXT := $(RUSTC_VERSION_TEXT) +kconfirm: export PAHOLE_VERSION := $(PAHOLE_VERSION) +kconfirm: outputmakefile scripts_basic + $(Q)$(MAKE) $(build)=scripts/kconfig $(kconfirm-hostrustc) kconfirm || \ + (printf "\n kconfirm failed to build or run. It is built with the Rust\n toolchain (rustc, bindgen). See Documentation/dev-tools/kconfirm.rst\n\n" && false) + +kconfirmtest: outputmakefile scripts_basic + $(Q)$(MAKE) $(build)=scripts/kconfig $(kconfirm-hostrustc) kconfirmtest + PHONY += checkstack kernelrelease kernelversion image_name # UML needs a little special treatment here. It wants to use the host
scripts/kconfig/.gitignore +1 -0
@@ -4,4 +4,5 @@ /[gmnq]conf-bin /[gmnq]conf-cflags /[gmnq]conf-libs +/kconfig_bindings.rs /qconf-moc.cc
scripts/kconfig/Makefile +54 -0
63 lines not on this page · raw message
scripts/kconfig/kconfig.rs new file +445 -0
445 lines not on this page · raw message
scripts/kconfig/kconfirm/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +/kconfirm
scripts/kconfig/kconfirm/analyze.rs new file +340 -0
340 lines not on this page · raw message
scripts/kconfig/kconfirm/arch.rs new file +53 -0
53 lines not on this page · raw message
scripts/kconfig/kconfirm/checks.rs new file +748 -0
748 lines not on this page · raw message
scripts/kconfig/kconfirm/dead_links.rs new file +230 -0
230 lines not on this page · raw message
scripts/kconfig/kconfirm/kconfirm-cfg.sh new file +57 -0
57 lines not on this page · raw message
scripts/kconfig/kconfirm/kconfirm.rs new file +278 -0
278 lines not on this page · raw message
scripts/kconfig/kconfirm/output.rs new file +87 -0
87 lines not on this page · raw message
scripts/kconfig/kconfirm/symbol_table.rs new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
2.54.0
Julian Braha
reviewerPATCH v4 3/5 kconfirm: add tests
In reply to Julian BrahaAdd tests for kconfirm using pytest, as Kconfig does. The tests cover all of kconfirm’s checks, and any additional, future checks need to add tests as well.
--- .../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 ++++++++++++++++++ 21 files changed, 682 insertions(+) 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
scripts/kconfig/kconfirm/tests/arch/arm/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +source "architecture_common.Kconfig" + +config ARM_ONLY + bool + depends on ARM_PREREQUISITE + depends on ARM_PREREQUISITE
scripts/kconfig/kconfirm/tests/arch/powerpc/Kconfig new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +source "architecture_common.Kconfig"
scripts/kconfig/kconfirm/tests/arch/riscv/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +source "architecture_common.Kconfig" + +config RISCV_ONLY + bool + depends on RISCV_PREREQUISITE + depends on RISCV_PREREQUISITE
scripts/kconfig/kconfirm/tests/arch/sh/Kconfig new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +source "architecture_common.Kconfig"
scripts/kconfig/kconfirm/tests/arch/testarch/Kconfig new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +# Dynamically discovered test architecture.
scripts/kconfig/kconfirm/tests/arch/um/Kconfig new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +source "architecture_common.Kconfig"
scripts/kconfig/kconfirm/tests/arch/x86/Kconfig new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +source "architecture_common.Kconfig"
scripts/kconfig/kconfirm/tests/architecture.Kconfig new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +source "arch/$(SRCARCH)/Kconfig"
scripts/kconfig/kconfirm/tests/architecture_common.Kconfig new file +19 -0
@@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +config SHARED_SELECTEE + bool "Shared target" + help + This is a test-only symbol with a visible prompt. + Kconfirm uses it as the target of a select statement. + The architecture tests verify that selecting this symbol + produces the expected select-visible diagnostic. + +config SHARED_SELECTOR + bool + select SHARED_SELECTEE + +config SHARED_DEPENDENCY + bool + depends on SHARED_PREREQUISITE + depends on SHARED_PREREQUISITE
scripts/kconfig/kconfirm/tests/conditional_prompt.Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +config SELECTEE + bool "Target" if PROMPT_CONDITION + help + This is a test-only symbol with a conditional prompt. + Kconfirm uses it as the target of a select statement. + The test verifies that the prompt condition is included + when deciding whether the target is visible. + +config SELECTOR + bool + select SELECTEE + +config PROMPT_CONDITION + bool
scripts/kconfig/kconfirm/tests/conftest.py new file +93 -0
93 lines not on this page · raw message
scripts/kconfig/kconfirm/tests/constant_condition/default_constant_condition_negative_expression_1.Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +config A + tristate + depends on !(B || C) + default y if B || C + +config B + bool + +config C + tristate
scripts/kconfig/kconfirm/tests/constant_condition/default_constant_condition_negative_expression_2.Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +config A + tristate + depends on B || C + default y if !(B || C) + +config B + bool + +config C + tristate
scripts/kconfig/kconfirm/tests/constant_condition/default_constant_condition_negative_symbol_1.Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +config A + tristate + depends on B + default y if !B + +config B + bool + +config C + tristate
scripts/kconfig/kconfirm/tests/constant_condition/default_constant_condition_negative_symbol_2.Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +config A + tristate + depends on !B + default y if B + +config B + bool + +config C + tristate
scripts/kconfig/kconfirm/tests/dead_link.Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +config HAS_DEAD_LINK + bool + help + The obsolete documentation was at https://example.invalid/obsolete. + +config HAS_DUPLICATE_DEAD_LINK + bool + help + The same documentation was at https://example.invalid/obsolete.
scripts/kconfig/kconfirm/tests/default_categorization.Kconfig new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> + +config DUPLICATE_UNCONDITIONAL + bool + default y + default y + +config DEAD_AFTER_UNCONDITIONAL + bool + default y + default n + +config DUPLICATE_CONDITIONAL + bool + default y if CONDITION + default y if CONDITION + +config CONDITION + bool
scripts/kconfig/kconfirm/tests/pytest.ini new file +2 -0
@@ -0,0 +1,2 @@ +[pytest] +addopts = --verbose
scripts/kconfig/kconfirm/tests/ranges.Kconfig new file +39 -0
@@ -0,0 +1,39 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> +# +# Fixture for toggling duplicate_range and dead_range independently of each +# other, and for categorizing repeated ranges correctly. + +config GATE + bool + +config OTHER_GATE + bool + +config RANGED_DUP + int + range 1 5 + range 1 5 + +config RANGED_DEAD + int + range 1 5 + range 2 6 if GATE + +config RANGED_CONDITIONAL_FIRST + int + range 1 5 if GATE + range 2 6 + +config RANGED_DEAD_UNCONDITIONAL + int + range 1 5 + range 2 6 + +config RANGED_MULTIPLE + int + range 1 5 if GATE + range 2 6 if OTHER_GATE + range 3 7 + range 4 8 if GATE + range 5 9
scripts/kconfig/kconfirm/tests/select_imply.Kconfig new file +28 -0
@@ -0,0 +1,28 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2026 Julian Braha <[email protected]> +# +# Fixture for toggling duplicate_select/dead_select and +# duplicate_imply/dead_imply independently of each other. + +config SELECTEE + bool + +config OTHER_SELECTEE + bool + +config GATE + bool + +config SELECTOR + bool + select SELECTEE + select SELECTEE if GATE + select OTHER_SELECTEE + select OTHER_SELECTEE + +config IMPLIER + bool + imply SELECTEE + imply SELECTEE if GATE + imply OTHER_SELECTEE + imply OTHER_SELECTEE
scripts/kconfig/kconfirm/tests/test_kconfirm.py new file +358 -0
358 lines not on this page · raw message
Signature · 1 line
2.54.0
Julian Braha
reviewerPATCH v4 4/5 Documentation: add kconfirm
In reply to Julian BrahaAdd usage documentation and a brief description of kconfirm to Documentation/dev-tools/
--- Documentation/dev-tools/index.rst | 1 + Documentation/dev-tools/kconfirm.rst | 229 +++++++++++++++++++++++++++ 2 files changed, 230 insertions(+) create mode 100644 Documentation/dev-tools/kconfirm.rst
Documentation/dev-tools/index.rst +1 -0
@@ -40,3 +40,4 @@ Documentation/process/debugging/index.rst autofdo propeller container + kconfirm
Documentation/dev-tools/kconfirm.rst new file +229 -0
229 lines not on this page · raw message
Signature · 1 line
2.54.0
Julian Braha
reviewerPATCH v4 5/5 MAINTAINERS: add entry for kconfirm
In reply to Julian BrahaI will maintain all files introduced with kconfirm.
--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -14041,6 +14041,13 @@ F: Documentation/kbuild/kconfig* F: scripts/Kconfig.include F: scripts/kconfig/ +KCONFIRM AND KCONFIG BINDINGS [RUST] +M: Julian Braha <[email protected]> +S: Maintained +F: Documentation/dev-tools/kconfirm.rst +F: scripts/kconfig/kconfig.rs +F: scripts/kconfig/kconfirm/ + KCORE M: Omar Sandoval <[email protected]> L: [email protected]
Signature · 1 line
2.54.0
Julian Braha
reviewerQuoted 213 lines · Julian Braha
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/[email protected]/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/[email protected]/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/[email protected]/Even after deduplicating across architectures, there are well over 1,000 instances of these select-visible cases, and I suspect that, despite the
Kconfigdocumentation 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/[email protected]/
and:
https://lore.kernel.org/all/[email protected]/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 kconfirmTo enable the select-visible check:
KCONFIRM_ARGS="--enable-check select_visible" make kconfirmAnd to enable dead link checks in the help texts:
KCONFIRM_ARGS="--enable-check dead_link" make kconfirmkconfirm 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 kconfirmThanks,
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 underscripts/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 tagLink to RFC v3:
https://lore.kernel.org/all/[email protected]/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'sgetopt_long(also Demi)
- Remove cratesenv_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 CLILink to RFC v2:
https://lore.kernel.org/all/[email protected]/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 cleanno 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/[email protected]/
---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 kconfirmDocumentation/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
Quoted 9 lines
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
As I've been getting more comfortable with the in-tree Kconfig interpreter, I've been wondering if the community might prefer the gradual integration of lints directly into Kconfig, instead of as a standalone tool. Similar to a comment by Jani on another patch [1].
Otherwise, I can do a round of self-review and send a v5 for this series. I already noticed some dumb typos in the subject lines, but any other feedback on v4 would be welcome if kconfirm is the preferred route :)
Link:
https://lore.kernel.org/all/[email protected]/
[1]
- Julian Braha
Quoted 224 lines · Julian Braha
Quoted 213 lines · Julian Braha
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/[email protected]/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/[email protected]/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/[email protected]/Even after deduplicating across architectures, there are well over 1,000 instances of these select-visible cases, and I suspect that, despite the
Kconfigdocumentation 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/[email protected]/
and:
https://lore.kernel.org/all/[email protected]/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 kconfirmTo enable the select-visible check:
KCONFIRM_ARGS="--enable-check select_visible" make kconfirmAnd to enable dead link checks in the help texts:
KCONFIRM_ARGS="--enable-check dead_link" make kconfirmkconfirm 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 kconfirmThanks,
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 underscripts/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 tagLink to RFC v3:
https://lore.kernel.org/all/[email protected]/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'sgetopt_long(also Demi)
- Remove cratesenv_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 CLILink to RFC v2:
https://lore.kernel.org/all/[email protected]/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 cleanno 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/[email protected]/
---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 kconfirmDocumentation/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.KconfigQuoted 9 lines
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
Quoted 4 lines
As I've been getting more comfortable with the in-tree
Kconfiginterpreter, I've been wondering if the community might prefer the gradual integration of lints directly intoKconfig, instead of as a standalone tool. Similar to a comment by Jani on another patch [1].
Yes, I'd prefer if in-tree Kconfig is improved to find more mistakes in Kconfig files itself.
Thanks for keeping up!
Kind regards,
Nicolas
Nathan Chancellor
maintainerQuoted 4 lines · Julian Braha
As I've been getting more comfortable with the in-tree
Kconfiginterpreter, I've been wondering if the community might prefer the gradual integration of lints directly intoKconfig, instead of as a standalone tool. Similar to a comment by Jani on another patch [1].
Yes, I would think from a user/general developer perspective, it would be more useful (and frankly, effective) to have these sort of lints/checks in Kconfig directly so that they just run as part of a normal build.
Quoted 4 lines
Otherwise, I can do a round of self-review and send a v5 for this series. I already noticed some dumb typos in the subject lines, but any other feedback on v4 would be welcome if kconfirm is the preferred route :)
My apologies for not getting to this sooner, I have been busy with some other projects. I will try to play around with this from a usability perspective (which is what I am most concerned with at this point). If a v5 is mostly prepared, I would not mind seeing it even if we want to go the in-tree interpreter checks. One option is to take kconfirm into the tree, fix up the warnings it generates, then moving the checks into the interpreter directly while dropping them from kconfirm (since the tree should be clean at that point). I am open to opinions on that though.
Signature · 2 lines
Cheers, Nathan
Julian Braha
reviewerQuoted 9 lines · Nathan Chancellor
My apologies for not getting to this sooner, I have been busy with some other projects. I will try to play around with this from a usability perspective (which is what I am most concerned with at this point). If a v5 is mostly prepared, I would not mind seeing it even if we want to go the in-tree interpreter checks. One option is to take kconfirm into the tree, fix up the warnings it generates, then moving the checks into the interpreter directly while dropping them from kconfirm (since the tree should be clean at that point). I am open to opinions on that though.
Your strategy makes sense to me. I'll send v5 then, but I'd also like to make sure that Nicolas is onboard with this idea.
- Julian Braha
Quoted 12 lines · Julian Braha
Quoted 9 lines · Nathan Chancellor
My apologies for not getting to this sooner, I have been busy with some other projects. I will try to play around with this from a usability perspective (which is what I am most concerned with at this point). If a v5 is mostly prepared, I would not mind seeing it even if we want to go the in-tree interpreter checks. One option is to take kconfirm into the tree, fix up the warnings it generates, then moving the checks into the interpreter directly while dropping them from kconfirm (since the tree should be clean at that point). I am open to opinions on that though.
Quoted 2 lines
Your strategy makes sense to me. I'll send v5 then, but I'd also like to make sure that Nicolas is onboard with this idea.
I am fully ok with that. Thanks!
Nicolas