[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260120-ra-fix-v1-0-829e4e92818c@nvidia.com>
Date: Tue, 20 Jan 2026 17:52:49 +0900
From: Eliot Courtney <ecourtney@...dia.com>
To: Miguel Ojeda <ojeda@...nel.org>, Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>, Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>, Nathan Chancellor <nathan@...nel.org>,
Nicolas Schier <nsc@...nel.org>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-kbuild@...r.kernel.org, Eliot Courtney <ecourtney@...dia.com>
Subject: [PATCH 0/6] scripts: generate_rust_analyzer: improve
rust-project.json generation
This series improves rust-analyzer rust-project.json generation by:
- Adding missing dependencies to driver crates
- Plumbing per-crate editions via command line (core: 2024/2021, quote: 2018)
- Plumbing per-crate crate-attrs for host crates
- Plumbing common crate-attrs for non-host crates (no_std, feature flags)
- Migrating sysroot crates to sysroot_project
This fixes a bunch of errors when using rust-analyzer caused by sysroot
crates not being properly processed.
For example, some sysroot crates try to load paths outside of
themselves, using directives like "`#[path =
"../../portable-simd/crates/core_simd/src/mod.rs"]`". The current
structure of rust-project.json has sysroot crates put in with the driver
and kernel crates. But rust-analyzer doesn't let crates access files
outside of themselves unless they are sysroot crates (there is special
handling for this in rust-analyzer). For this to work the sysroot has to
be specified via either sysroot_src or the new sysroot_project
attribute. It's also possible to specify "include_dirs" to allow this
but it makes sense to specify sysroot crates in the intended way.
This patch series uses the following new rust-analyzer features:
- crate_attrs: added in v0.3.2727 (~rust-analyzer 1.94.0)
- sysroot_project: added in v0.3.2328 (~rust-analyzer 1.87.0)
Both features are silently ignored by older rust-analyzer versions,
so this remains backwards compatible. For older versions, sysroot
is loaded via sysroot_src as before. This may be simpler than version
detecting rust-analyzer and changing behaviour based on that.
I measured how many compile errors rust-analyzer reports using
`rust-analyzer diagnostics . | grep RustcHardError | wc -l`. Since we
know the code compiles this is a rough indication of how incorrect
the rust-project.json setup is compared to the actual build environment.
Error reduction (RustcHardError count):
rust-analyzer 1.78.0: 6127 before patches -> 519 after
rust-analyzer 0.3.2753: 1742 before patches -> 65 after
I also observed no rust-analyzer errors on nova-core after this series.
There is some overlap between this patch series and ones already sent
but not applied, but it's unclear to me what the status of those are.
Signed-off-by: Eliot Courtney <ecourtney@...dia.com>
---
Eliot Courtney (6):
scripts: generate_rust_analyzer: rename cfg to generated_cfg
scripts: generate_rust_analyzer: plumb editions via command line
scripts: generate_rust_analyzer: plumb crate-attrs
scripts: generate_rust_analyzer: plumb common crate-attrs for non-host crates
scripts: generate_rust_analyzer: add pin_init to driver crate deps
scripts: generate_rust_analyzer: move sysroot crates to sysroot_project
rust/Makefile | 16 +++-
scripts/Makefile.build | 14 +--
scripts/Makefile.rust | 20 +++++
scripts/generate_rust_analyzer.py | 181 ++++++++++++++++++++++++--------------
4 files changed, 147 insertions(+), 84 deletions(-)
---
base-commit: 2af6ad09fc7dfe9b3610100983cccf16998bf34d
change-id: 20260119-ra-fix-7b0f18457e62
Best regards,
--
Eliot Courtney <ecourtney@...dia.com>
Powered by blists - more mailing lists