Skip to content

RFC Initial klint integration

Gary Guo linux-kbuild lkml rust-for-linux 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2kbuild: rust: register "klint" as a toolrust/Makefile scripts/Makefile.build+8 -30 replies
2/2kbuild: rust: use klint to provide CONFIG_FRAME_WARNscripts/Makefile.warn+1 -09 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchDanilo KrummrichNathan Chancellor
SeriesA-b
1/2
2/2A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [RFC PATCH 0/2] Initial klint integration

From: Gary Guo <[email protected]>

This RFC series introduce klint integration into the kernel.

Klint is a linting tool (in the form of a custom Rust compiler driver, similar to how Clippy works) that I have been working on since 2022. It was initially created to help lint on code that can trigger panics on allocation failure; this feature has been long obsolete after we started vendoring alloc crate and subsequently replacing it with a custom implementation, but over time it also gains some other useful lints.

Lints that are considered ready currently:
* Items available via kernel prelude but imported via other means
* build_error/build_assert calls not being optimized out (klint will provide you a backtrace to ease analysis, as opposed to just a linker error).
* Stack frames larger than desired (configured via CONFIG_FRAME_WARN).

The kernel is not currently lint clean. I've already sent out a series to fix the prelude imports; there is a true-positive with Nova-core's Cmdq::new method's excessive stack usage which needs fixing.

Many of you may have also heard about klint's ability to perform locking rule checks, however I did not consider it ready (due to false positives and inability to analysis some code patterns), so it is not enabled in the series.

The source code is available at https://github.com/Rust-for-Linux/klint.
It is licensed in "MIT OR Apache-2.0", the same license as the Rust compiler, as the tool is heavy dependant on the Rust compiler internals. Currently, there's no pre-compiled binary available; it should be easy to build for rustup and Nix users; if there are enough demands I can also consider providing pre-built binaries.

Gary Guo (2):
kbuild: rust: register "klint" as a tool
kbuild: rust: use klint to provide CONFIG_FRAME_WARN

 rust/Makefile          | 5 ++++-
 scripts/Makefile.build | 6 ++++--
 scripts/Makefile.warn  | 1 +
 3 files changed, 9 insertions(+), 3 deletions(-)

base-commit: 615aad0f61e0c7a898184a394dc895c610100d4f

Signature · 1 line
2.51.2