public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] Initial klint integration
@ 2026-01-27 17:11 Gary Guo
  2026-01-27 17:11 ` [RFC PATCH 1/2] kbuild: rust: register "klint" as a tool Gary Guo
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Gary Guo @ 2026-01-27 17:11 UTC (permalink / raw)
  To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich
  Cc: rust-for-linux

From: Gary Guo <gary@garyguo.net>

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
-- 
2.51.2


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-01-30  4:11 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-27 17:11 [RFC PATCH 0/2] Initial klint integration Gary Guo
2026-01-27 17:11 ` [RFC PATCH 1/2] kbuild: rust: register "klint" as a tool Gary Guo
2026-01-27 17:11 ` [RFC PATCH 2/2] kbuild: rust: use klint to provide CONFIG_FRAME_WARN Gary Guo
2026-01-27 22:15   ` Nathan Chancellor
2026-01-27 22:51     ` Gary Guo
2026-01-27 23:12       ` Miguel Ojeda
2026-01-27 23:27         ` Gary Guo
2026-01-28  0:31   ` Alexandre Courbot
2026-01-28  1:14     ` Gary Guo
2026-01-28 22:02       ` Nathan Chancellor
2026-01-29  0:59         ` Gary Guo
2026-01-30  4:10           ` Nathan Chancellor
2026-01-27 17:35 ` [RFC PATCH 0/2] Initial klint integration Miguel Ojeda
2026-01-27 17:47 ` Danilo Krummrich
2026-01-27 21:26 ` John Hubbard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox