scripts: add kconfirm
Subsystems (4)
cover scripts: add kconfirm
Hi all,
Following this discussion:
https://lore.kernel.org/all/[email protected]/
in which Andrew brought up the possibility of moving kconfirm in-tree, I've prepared this RFC to do so. See also kconfirm's introduction to the mailing list:
https://lore.kernel.org/all/[email protected]/
kconfirm currently detects dead code (defaults, dependencies, selects, and ranges), and includes an optional check for dead links in the help texts.
False Alarms:
kconfirm aims for zero false-positives, which is currently true for dead code detection (as far as I'm aware - but there are hundreds to go through); this is not really possible 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 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]/
Current State of Alarms:
The last time I checked linux-next (next-20260427), there were 579 instances of dead code, and 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
You can enable dead link checks in the help texts by passing KCONFIRM_ARGS="--enable dead_links", like this:
KCONFIRM_ARGS="--enable dead_links" make kconfirm
Note that it is not architecture-specific; it runs tree-wide. If you run it on linux-next, you should find 579 instances of dead code. Originally this number was even higher, but many patches have since been applied to linux-next, and included in linux 7.1-rc1. Thank you to the maintainers and reviewers for their feedback and patience :)
You will need Rust with Cargo and an internet connection to download the dependencies for compilation. Originally, I planned to vendor the dependencies and submit the entirety of the code here, in-tree, but the dependencies (and their dependencies...) are too large (somehow, a whopping 264MB!), so instead I am proposing to add just the tool's own code.
I've included the Rust for Linux team to discuss the build system changes, as I'd like know if there is a better way to integrate this with make, and if there's a better solution as far as the dependencies and Cargo go.
Thanks,
Julian Braha
Julian Braha (2):
scripts: add kconfirm
Documentation: dev-tools: add kconfirm
Documentation/dev-tools/index.rst | 1 + Documentation/dev-tools/kconfirm.rst | 147 ++ Makefile | 12 +- scripts/Makefile | 2 +- scripts/kconfirm/Cargo.lock | 1710 +++++++++++++++++ scripts/kconfirm/Cargo.toml | 21 + scripts/kconfirm/Makefile | 28 + scripts/kconfirm/kconfirm-lib/Cargo.toml | 16 + scripts/kconfirm/kconfirm-lib/src/analyze.rs | 593 ++++++ scripts/kconfirm/kconfirm-lib/src/checks.rs | 257 +++ .../kconfirm/kconfirm-lib/src/dead_links.rs | 63 + scripts/kconfirm/kconfirm-lib/src/lib.rs | 55 + scripts/kconfirm/kconfirm-lib/src/output.rs | 52 + .../kconfirm/kconfirm-lib/src/symbol_table.rs | 209 ++ scripts/kconfirm/kconfirm-linux/Cargo.toml | 14 + scripts/kconfirm/kconfirm-linux/src/lib.rs | 129 ++ scripts/kconfirm/kconfirm-linux/src/main.rs | 74 + 17 files changed, 3379 insertions(+), 4 deletions(-) create mode 100644 Documentation/dev-tools/kconfirm.rst create mode 100644 scripts/kconfirm/Cargo.lock create mode 100644 scripts/kconfirm/Cargo.toml create mode 100644 scripts/kconfirm/Makefile create mode 100644 scripts/kconfirm/kconfirm-lib/Cargo.toml create mode 100644 scripts/kconfirm/kconfirm-lib/src/analyze.rs create mode 100644 scripts/kconfirm/kconfirm-lib/src/checks.rs create mode 100644 scripts/kconfirm/kconfirm-lib/src/dead_links.rs create mode 100644 scripts/kconfirm/kconfirm-lib/src/lib.rs create mode 100644 scripts/kconfirm/kconfirm-lib/src/output.rs create mode 100644 scripts/kconfirm/kconfirm-lib/src/symbol_table.rs create mode 100644 scripts/kconfirm/kconfirm-linux/Cargo.toml create mode 100644 scripts/kconfirm/kconfirm-linux/src/lib.rs create mode 100644 scripts/kconfirm/kconfirm-linux/src/main.rs
Signature · 1 line
2.53.0
RFC PATCH 1/2 scripts: add kconfirm
Add kconfirm into scripts/ and modify the root Makefile and scripts/Makefile accordingly so that it can be compiled and run with:make kconfirm
from the root of the tree.
The user is expected to have Rust with Cargo installed, and an internet connection on the first run to download and compile the dependencies.
--- Makefile | 12 +- scripts/Makefile | 2 +- scripts/kconfirm/Cargo.lock | 1710 +++++++++++++++++ scripts/kconfirm/Cargo.toml | 21 + scripts/kconfirm/Makefile | 28 + scripts/kconfirm/kconfirm-lib/Cargo.toml | 16 + scripts/kconfirm/kconfirm-lib/src/analyze.rs | 593 ++++++ scripts/kconfirm/kconfirm-lib/src/checks.rs | 257 +++ .../kconfirm/kconfirm-lib/src/dead_links.rs | 63 + scripts/kconfirm/kconfirm-lib/src/lib.rs | 55 + scripts/kconfirm/kconfirm-lib/src/output.rs | 52 + .../kconfirm/kconfirm-lib/src/symbol_table.rs | 209 ++ scripts/kconfirm/kconfirm-linux/Cargo.toml | 14 + scripts/kconfirm/kconfirm-linux/src/lib.rs | 129 ++ scripts/kconfirm/kconfirm-linux/src/main.rs | 74 + 15 files changed, 3231 insertions(+), 4 deletions(-) create mode 100644 scripts/kconfirm/Cargo.lock create mode 100644 scripts/kconfirm/Cargo.toml create mode 100644 scripts/kconfirm/Makefile create mode 100644 scripts/kconfirm/kconfirm-lib/Cargo.toml create mode 100644 scripts/kconfirm/kconfirm-lib/src/analyze.rs create mode 100644 scripts/kconfirm/kconfirm-lib/src/checks.rs create mode 100644 scripts/kconfirm/kconfirm-lib/src/dead_links.rs create mode 100644 scripts/kconfirm/kconfirm-lib/src/lib.rs create mode 100644 scripts/kconfirm/kconfirm-lib/src/output.rs create mode 100644 scripts/kconfirm/kconfirm-lib/src/symbol_table.rs create mode 100644 scripts/kconfirm/kconfirm-linux/Cargo.toml create mode 100644 scripts/kconfirm/kconfirm-linux/src/lib.rs create mode 100644 scripts/kconfirm/kconfirm-linux/src/main.rs
Makefile +9 -3
@@ -1707,13 +1707,16 @@ MRPROPER_FILES += include/config include/generated \ # clean: private rm-files := $(CLEAN_FILES) -PHONY += archclean vmlinuxclean +PHONY += archclean vmlinuxclean kconfirm_clean vmlinuxclean: $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean) -clean: archclean vmlinuxclean resolve_btfids_clean objtool_clean +kconfirm_clean: + $(Q)$(MAKE) -C scripts/kconfirm clean + +clean: archclean vmlinuxclean resolve_btfids_clean objtool_clean kconfirm_clean # mrproper - Delete all generated files, including .config #
@@ -2223,7 +2226,7 @@ endif # Scripts to check various things for consistency # --------------------------------------------------------------------------- -PHONY += includecheck versioncheck coccicheck +PHONY += includecheck versioncheck coccicheck kconfirm includecheck: find $(srctree)/* $(RCS_FIND_IGNORE) \
@@ -2238,6 +2241,9 @@ versioncheck: coccicheck: $(Q)$(BASH) $(srctree)/scripts/$@ +kconfirm: + $(Q)$(MAKE) -C scripts/kconfirm + PHONY += checkstack kernelrelease kernelversion image_name # UML needs a little special treatment here. It wants to use the host
scripts/Makefile +1 -1
@@ -57,7 +57,7 @@ HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED endif # The following programs are only built on demand -hostprogs += unifdef gen_packed_field_checks +hostprogs += unifdef gen_packed_field_checks kconfirm # The module linker script is preprocessed on demand targets += module.lds
scripts/kconfirm/Cargo.lock new file +1710 -0
1,710 lines not on this page · raw message
scripts/kconfirm/Cargo.toml new file +21 -0
@@ -0,0 +1,21 @@ +[workspace] +members = ["kconfirm-lib", "kconfirm-linux"] +resolver = "3" + +[workspace.package] +license = "GPL-2.0-only" +description = "A static analysis tool for Kconfig" +keywords = ["kconfig", "static", "analysis", "detect"] +categories = ["development-tools", "config", "command-line-utilities"] +exclude = ["assets/"] +version = "0.7.0" +edition = "2024" +rust-version = "1.85.0" + +[workspace.dependencies] +nom-kconfig = "0.10" + +log = { version = "0.4", default-features = false } +env_logger = { version = "0.11", default-features = false } + +clap = { version = "4.6", default-features = false, features = ["std", "derive"] }
scripts/kconfirm/Makefile new file +28 -0
@@ -0,0 +1,28 @@ +# SPDX-License-Identifier: GPL-2.0 +# kconfirm makefile + +TARGET := kconfirm + +HAS_CARGO := $(shell command -v cargo 2> /dev/null) + +# Extra arguments forwarded to kconfirm. +# Example: make kconfirm KCONFIRM_ARGS="--enable dead_links" +KCONFIRM_ARGS ?= + +PHONY += all +all: $(TARGET) + +$(TARGET): +ifdef HAS_CARGO + @cargo run --release -p kconfirm-linux -- --linux-path ../../ $(KCONFIRM_ARGS) +else + @echo "Error: Cargo not found. Please install Rust and Cargo to build kconfirm." + @false +endif + +clean: +ifdef HAS_CARGO + @cargo clean > /dev/null 2>&1 +else + @: +endif
scripts/kconfirm/kconfirm-lib/Cargo.toml new file +16 -0
@@ -0,0 +1,16 @@ +[package] +name = "kconfirm-lib" +version = "0.7.0" +edition = "2024" +rust-version.workspace = true + +[dependencies] +nom-kconfig = { workspace = true } +reqwest = { version = "0.13", default-features = false, features = ["blocking", "rustls"] } +regex = { version = "1.12", default-features = false } +log = { workspace = true } +env_logger = { workspace = true } + +[features] +default = [] +coreboot = ["nom-kconfig/coreboot"]
scripts/kconfirm/kconfirm-lib/src/analyze.rs new file +593 -0
593 lines not on this page · raw message
scripts/kconfirm/kconfirm-lib/src/checks.rs new file +257 -0
257 lines not on this page · raw message
scripts/kconfirm/kconfirm-lib/src/dead_links.rs new file +63 -0
63 lines not on this page · raw message
scripts/kconfirm/kconfirm-lib/src/lib.rs new file +55 -0
55 lines not on this page · raw message
scripts/kconfirm/kconfirm-lib/src/output.rs new file +52 -0
52 lines not on this page · raw message
scripts/kconfirm/kconfirm-lib/src/symbol_table.rs new file +209 -0
162 lines not on this page · raw message
scripts/kconfirm/kconfirm-linux/Cargo.toml new file +14 -0
Lines of this file are not shown. View the raw message.
scripts/kconfirm/kconfirm-linux/src/lib.rs new file +129 -0
129 lines not on this page · raw message
scripts/kconfirm/kconfirm-linux/src/main.rs new file +74 -0
74 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.53.0
Part of the diff is not shown here. View the raw message.
RFC PATCH 2/2 Documentation: dev-tools: add kconfirm
In reply to Julian BrahaAdd usage documentation and a brief description for kconfirm to Documentation/dev-tools/
--- Documentation/dev-tools/index.rst | 1 + Documentation/dev-tools/kconfirm.rst | 147 +++++++++++++++++++++++++++ 2 files changed, 148 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 +147 -0
147 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [RFC PATCH 2/2] Documentation: dev-tools: add kconfirm
Documentation/dev-tools/kconfirm.rst line 33
Quoted 3 lines · Julian Braha
Documentation/dev-tools/kconfirm.rst new file +2
-0+kconfirm also requires the Cargo package manager and an internet +connection for compilation of its dependencies.
This will be quite surprising -- I think any make call should avoid touching the network and should allow working while offline as long as one has set up things beforehand.
i.e. I think tools and dependencies in general should be fetched and/or installed beforehand, and then yes, make may use them, without touching the network (e.g. passing --offline or --frozen).
Cheers,
Miguel
Re: [RFC PATCH 2/2] Documentation: dev-tools: add kconfirm
Quoted 9 lines · Miguel Ojeda
Documentation/dev-tools/kconfirm.rst line 33
Quoted 3 lines · Julian Braha
Documentation/dev-tools/kconfirm.rst new file +2
-0+kconfirm also requires the Cargo package manager and an internet +connection for compilation of its dependencies.This will be quite surprising -- I think any
makecall should avoid touching the network and should allow working while offline as long as one has set up things beforehand.
Quoted 3 lines
i.e. I think tools and dependencies in general should be fetched and/or installed beforehand, and then yes,
makemay use them, without touching the network (e.g. passing--offlineor--frozen).
It would also be helpful to reduce the number of hard dependencies and ideally only rely on packages that are already shipping in common distros.
From the dependency list, it appears that the majority of dependencies here are only indirectly pulled in by 'reqwest'. I guess is only required for dead-link checking, so maybe that part could be made optional?
Arnd
Quoted 4 lines · Julian Braha
Add kconfirm into
scripts/and modify the rootMakefileandscripts/Makefileaccordingly so that it can be compiled and run with:make kconfirm
from the root of the tree.
You don't say what this fancy new tool actually does anywhere that I can see :(
Quoted 9 lines
The user is expected to have Rust with Cargo installed, and an internet connection on the first run to download and compile the dependencies.
Signed-off-by Julian Braha <[email protected]>--- Makefile | 12 +- scripts/Makefile | 2 +- scripts/kconfirm/Cargo.lock | 1710 +++++++++++++++++
Did you mean to check this file in? That's not going to work well...
thanks,
greg k-h
Jonathan Corbet
maintainerQuoted 4 lines · Julian Braha
Add kconfirm into
scripts/and modify the rootMakefileandscripts/Makefileaccordingly so that it can be compiled and run with:make kconfirm
from the root of the tree.
As Greg noted, it would be helpful if you said what this tool does in the changelog.
Also, a nit, but I would really suggest putting it under tools/ rather than in the scripts/ dumping ground.
Thanks,
jon
Re: [RFC PATCH 2/2] Documentation: dev-tools: add kconfirm
In reply to Julian BrahaQuoted 140 lines · Julian Braha
Add usage documentation and a brief description for kconfirm to
Documentation/dev-tools/Signed-off-by Julian Braha <[email protected]>--- Documentation/dev-tools/index.rst | 1 + Documentation/dev-tools/kconfirm.rst | 147 +++++++++++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 Documentation/dev-tools/kconfirm.rstDocumentation/dev-tools/index.rst +1
-0@@ -40,3 +40,4 @@ Documentation/process/debugging/index.rst autofdo propeller container + kconfirmDocumentation/dev-tools/kconfirm.rst new file +115
-0@@ -0,0 +1,147 @@ +.. SPDX-License-Identifier: GPL-2.0-only +.. Copyright (C) 2026 Julian Braha <[email protected]> + +======== +kconfirm +======== + +kconfirm is a static analysis tool for the kernel's Kconfig system. It +checks the entire tree-wide Kconfig, and reports misusage like +dead code. In the case of dead default statements, these can be a +significant code smell. + +kconfirm has an optional check for dead links in the Kconfig help texts. +Since this has a high potential for false positives (due to websites +blocking bots) and slows down runtime signficantly, it is disabled by +default. However, an example of how to enable it is included below. + +kconfirm is written in Rust and lives in ``scripts/kconfirm``. Other +than the dead link checks, kconfirm aims for zero false positives. + +**NOTE**: kconfirm does not modify or compile the source tree; it is +strictly a static checker. + + +Getting Started +=============== + + +kconfirm's Minimum Supported Rust Version (MSRV) is v1.85.0, because +it uses Rust edition 2024, and this is the earliest supported version. + +kconfirm also requires the Cargo package manager and an internet +connection for compilation of its dependencies. + +If Cargo is available, kconfirm can be built and run from the top of the +kernel source tree:: + + make kconfirm + +The compiled ``kconfirm-linux`` binary will be available in +``scripts/kconfirm/target/release/``. + +The default checks currently cover dead code analysis. ``dead_links`` +must be turned on explicitly with ``--enable``; conversely, any default +check can be turned off with ``--disable``. Both options accept +either a comma-separated list or repeated flags, so the following +two invocations are equivalent:: + + kconfirm-linux --linux-path . --enable dead_defaults,dead_links + kconfirm-linux --linux-path . --enable dead_defaults --enable dead_links + + + +Options +======= + +**NOTE**: kconfirm's arguments must be provided in the ``KCONFIRM_ARGS`` +environment variable if running with ``make``. See `Examples`_. + +Available options: + +``--linux-path PATH`` + The path to the linux source tree to analyze. ``make`` uses this + option to pass the current linux tree, but this option can be used + when running the tool directly with another source tree. + See `Examples`_. + +``--enable CHECK[,CHECK...]`` + + Enable one or more checks in addition to the default set. May be + given multiple times, or as a single comma-separated list. See + `Available checks`_ below for valid names. + +``--disable CHECK[,CHECK...]`` + + Disable one or more checks from the default set. May be given + multiple times, or as a single comma-separated list. + +``-h, --help`` + + Show the help message and exit. + +``-V, --version`` + + Show version information and exit. + + +Available checks +================ + +Each check has a string name that is accepted by ``--enable`` and +``--disable``. Checks marked *(default)* are enabled unless turned off +explicitly. + +``duplicate_dependency`` *(default)* + + Reports duplicated ``depends on`` entries on a single Kconfig symbol. + +``duplicate_range`` *(default)* + + Reports duplicated ``range`` entries on a single Kconfig symbol. + +``duplicate_select`` *(default)* + + Reports duplicated ``select`` entries on a single Kconfig symbol. + +``duplicate_default`` *(default)* + + Reports duplicated ``default`` entries on a single Kconfig symbol. + +``dead_default`` *(default)* + + Reports ``default`` entries that can never be selected, for example + because their condition is unsatisfiable. +
Documentation/dev-tools/kconfirm.rst line 125
Quoted 10 lines
Documentation/dev-tools/kconfirm.rst new file +10
-0+``dead_links`` + + Reports broken URLs found in Kconfig help text. Because this + performs network requests it can be quite slow, and is disabled by + default. May also have false positives. + +``style`` + + Reports opinionated style issues in Kconfig files. Disabled by + default.
Oh, I'd really like a check on this part from kconfig-language.rst:
Note:
select should be used with care. select will force a symbol to a value without visiting the dependencies. By abusing select you are able to select a symbol FOO even if FOO depends on BAR that is not set.
In general use select only for non-visible symbols (no prompts anywhere) and for symbols with no dependencies. That will limit the usefulness but on the other hand avoid the illegal configurations all over.
i.e. warn on selecting visible symbols or symbols with dependencies.
Yes, it's going to produce tons of warnings. But currently we don't even know how bad it really is.
BR,
Jani.
Quoted 22 lines
Documentation/dev-tools/kconfirm.rst new file +22
-0+ + +Examples +======== + +Compile (as needed) and run on the current tree:: + + make kconfirm + +To additionally enable dead-link checking:: + + make kconfirm KCONFIRM_ARGS="--enable dead_links" + +To disable a check (here, ``duplicate_dependency``) while keeping the +rest of the default set:: + + make kconfirm KCONFIRM_ARGS="--disable duplicate_dependency" + +To run the default checks against a kernel tree separate from the +current directory, such as ``~/repos/linux``:: + + scripts/kconfirm/target/release/kconfirm-linux --linux-path ~/repos/linux
Signature · 1 line
Jani Nikula, Intel
Re: [RFC PATCH 2/2] Documentation: dev-tools: add kconfirm
In reply to Arnd BergmannQuoted 9 lines · Arnd Bergmann
It would also be helpful to reduce the number of hard dependencies and ideally only rely on packages that are already shipping in common distros.
From the dependency list, it appears that the majority of dependencies here are only indirectly pulled in by 'reqwest'. I guess is only required for dead-link checking, so maybe that part could be made optional?
+1, I had the same thoughts -- even if the fetching is done outside make, it would be still be nice to reduce the dependencies. Even if it just means calling into curl or similar.
Then I thought if the same would apply to clap etc., but then again, we may want to write more tools like this in Rust in the future (we already felt the pain in the past the pain of not having a e.g. JSON parser), and whether we could have a more general solution for this, including perhaps even a kernel.org registry (either as primary or not) etc.
Cheers,
Miguel
Gary Guo
reviewerRe: [RFC PATCH 2/2] Documentation: dev-tools: add kconfirm
Quoted 7 lines · Miguel Ojeda
Then I thought if the same would apply to
clapetc., but then again, we may want to write more tools like this in Rust in the future (we already felt the pain in the past the pain of not having a e.g. JSON parser), and whether we could have a more general solution for this, including perhaps even a kernel.org registry (either as primary or not) etc.
Personally, I think if Internet access is needed, downloading from whatever registry doesn't really matter as long as we can guarantee that it doesn't download random packages. Cryptographic hashes would be sufficient for that.
For the part of "not downloading random packages" but only those that are audited by kernel community -- it could be achieved by using cargo-vet and we can maintain a shared list of vetted dependencies.
Best,
Gary
Re: [RFC PATCH 2/2] Documentation: dev-tools: add kconfirm
In reply to Arnd BergmannQuoted 8 lines · Arnd Bergmann
It would also be helpful to reduce the number of hard dependencies and ideally only rely on packages that are already shipping in common distros.
From the dependency list, it appears that the majority of dependencies here are only indirectly pulled in by 'reqwest'. I guess is only required for dead-link checking, so maybe that part could be made optional?
Thanks Arnd, I've done a deep dive on this, and found a number of ways to reduce the size of the vendored dependencies:
1. replace the reqwest dependency with the smaller ureq,
2. remove rustls as a dependency, and instead expect the user's system to have openssl,
3. filter out unneeded artifacts (e.g. none of their tests or docs),
4. filter out non-linux platform support
With all of this, the size of the entire tool source with dependencies is under 50mb (about the same as the perf tool).
And then an internet connection can be avoided when using Make.
- Julian Braha
Re: [RFC PATCH 2/2] Documentation: dev-tools: add kconfirm
In reply to Jani NikulaQuoted 4 lines · Jani Nikula
Oh, I'd really like a check on this part from
kconfig-language.rst:i.e. warn on selecting visible symbols or symbols with dependencies.
Hi Jani,
This is very doable in the general case of unconditional visibility/non-visibility. Handling the more complex case of conditional prompts will require finishing the SMT model, coming later.
I'll add this check, hopefully for kconfirm v0.8 / RFC 2 :)
Thanks for the inspiration, and let me know if you have any other ideas, too.
- Julian Braha
Nathan Chancellor
maintainerQuoted 2 lines · Jonathan Corbet
Also, a nit, but I would really suggest putting it under
tools/rather than in thescripts/dumping ground.
As if tools/ isn't its own dumping ground? :)
While I can understand the desire to avoid adding more random stuff to scripts/, it sets a confusing precedent because tools/ is not a part of Kbuild, so I would not expect tools that would run within Kbuild to live there (which this one appears to do). While there are obvious exceptions such as objtool and resolve_btfids, I would like to avoid adding new ones, which aligns with the comment added by Masahiro's commit 6e6ef2da3a28 ("Makefile: add comment to discourage tools/* addition for kernel builds"). Maybe this could be mitigated with a tools/kbuild/ directory or something but not sure. Just some additional input.
Cheers,
Nathan
Nathan Chancellor
maintainerRe: [RFC PATCH 2/2] Documentation: dev-tools: add kconfirm
In reply to Miguel OjedaQuoted 6 lines · Miguel Ojeda
Then I thought if the same would apply to
clapetc., but then again, we may want to write more tools like this in Rust in the future (we already felt the pain in the past the pain of not having a e.g. JSON parser), and whether we could have a more general solution for this, including perhaps even a kernel.org registry (either as primary or not) etc.
Yeah, I seem to recall a previous proposal for a host program that was written in Rust, I think it was the vdsocheck tool?
https://lore.kernel.org/[email protected]/
I agree with the sentiment that more host tools may want to be written in Rust. The Rust build in the kernel does not use cargo altogether, do we want the same restriction for host programs? Would these tools be able to share the Rust build rules so that we could have a simple hostprogs syntax for tools integrating with Kbuild to use? Obviously, it might be harder for some programs not to use some of the nice third party libraries available but it seems like it would eliminate the build system considerations from the discussion at that point.
Cheers,
Nathan
Jonathan Corbet
maintainerQuoted 5 lines · Nathan Chancellor
Quoted 2 lines · Jonathan Corbet
Also, a nit, but I would really suggest putting it under
tools/rather than in thescripts/dumping ground.As if
tools/isn't its own dumping ground? :)
It is more structured and more amenable to useful MAINTAINERS entries.
Quoted 5 lines
While I can understand the desire to avoid adding more random stuff to
scripts/, it sets a confusing precedent becausetools/is not a part ofKbuild, so I would not expect tools that would run withinKbuildto live there (which this one appears to do). While there are obvious exceptions such as objtool andresolve_btfids,
...and the docs build system...
Quoted 5 lines
I would like to avoid adding new
ones, which aligns with the comment added by Masahiro's commit6e6ef2da3a28("Makefile: add comment to discouragetools/*addition for kernel builds"). Maybe this could be mitigated with atools/kbuild/directory or something but not sure. Just some additional input.
I don't understand that reticence. As we build up more tools, why not organize them in a directory tree, perhaps called "tools", where we can track who's responsible for the various subtrees?
Thanks,
jon
Quoted 2 lines · Greg KH
You don't say what this fancy new tool actually does anywhere that I can see :(
Hi Greg, apologies, I wrote everything in the cover letter:
https://lore.kernel.org/all/[email protected]/
and then I wasn't really sure what to write in the actual patch messages...
I'll spend some more time looking through past RFCs and either separate things out, or add some repetition.
Quoted 1 line
Did you mean to check this file in? That's not going to work well...
I've found some ways to significantly reduce the size of the dependencies when vendored (also thanks to Arnd), details already shared here:
https://lore.kernel.org/all/[email protected]/
so then we can remove the internet connection for dependency download, and the Cargo.lock file becomes unnecessary.
- Julian Braha
Re: [RFC PATCH 2/2] Documentation: dev-tools: add kconfirm
In reply to Nathan ChancellorQuoted 9 lines · Nathan Chancellor
I agree with the sentiment that more host tools may want to be written in Rust. The Rust build in the kernel does not use cargo altogether, do we want the same restriction for host programs? Would these tools be able to share the Rust build rules so that we could have a simple hostprogs syntax for tools integrating with
Kbuildto use? Obviously, it might be harder for some programs not to use some of the nice third party libraries available but it seems like it would eliminate the build system considerations from the discussion at that point.
Yeah, we have already 3 hostprogs in the tree, which just call the compiler, but it would be nice to have a way to use ecosystem crates for those and userprogs etc., even if just a particular vetted set.
Otherwise, it is quite painful sometimes to use Rust, and one may prefer something like Python instead (like we did for scripts/generate_rust_analyzer.py). Python works great for many tasks thanks to its standard library, but we lose the advantages of something like Rust. On the other hand, Rust without a few crates to support certain common things isn't great.
I wouldn't say it is a rush, but it would be nice to agree on an initial vetted set and try to set something up so that eventually it is easy to write scripts/tools/hostprogs in Rust going forward.
We could also consider an earlier MSRV for those, i.e. lower than the kernel image one, if that would allow us to use it in more places, like for hostprogs without assuming CONFIG_RUST=y. Say, Debian Oldstable instead of Stable.
Cheers,
Miguel
Nathan Chancellor
maintainerQuoted 9 lines · Jonathan Corbet
Quoted 5 lines · Nathan Chancellor
Quoted 2 lines · Jonathan Corbet
Also, a nit, but I would really suggest putting it under
tools/rather than in thescripts/dumping ground.As if
tools/isn't its own dumping ground? :)It is more structured and more amenable to useful
MAINTAINERSentries.
Perhaps on the structured aspect but I don't see how tools/ differs from scripts/ with regards to MAINTAINERS entries. Yeah, Kbuild has a scripts/ catch all but you could still add a top level folder and add that to whatever MAINTAINERS entry you want.
Quoted 7 lines
Quoted 5 lines
While I can understand the desire to avoid adding more random stuff to
scripts/, it sets a confusing precedent becausetools/is not a part ofKbuild, so I would not expect tools that would run withinKbuildto live there (which this one appears to do). While there are obvious exceptions such as objtool andresolve_btfids,...and the docs build system...
Which is a recent change, no?
Quoted 9 lines
Quoted 5 lines
I would like to avoid adding new
ones, which aligns with the comment added by Masahiro's commit6e6ef2da3a28("Makefile: add comment to discouragetools/*addition for kernel builds"). Maybe this could be mitigated with atools/kbuild/directory or something but not sure. Just some additional input.I don't understand that reticence. As we build up more tools, why not organize them in a directory tree, perhaps called "tools", where we can track who's responsible for the various subtrees?
Well, the only reason I bring that up is that it will make life harder on the Kbuild people to do treewide audits and reviews of Kbuild usage when certain areas in tools/ use Kbuild while others don't. Obviously, we can adapt should the general consensus want tools to live in tools/.
Signature · 2 lines
Cheers, Nathan