From: Eliot Courtney <ecourtney@nvidia.com>
To: "Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nicolas Schier" <nsc@kernel.org>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kbuild@vger.kernel.org,
Eliot Courtney <ecourtney@nvidia.com>
Subject: [PATCH 0/6] scripts: generate_rust_analyzer: improve rust-project.json generation
Date: Tue, 20 Jan 2026 17:52:49 +0900 [thread overview]
Message-ID: <20260120-ra-fix-v1-0-829e4e92818c@nvidia.com> (raw)
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@nvidia.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@nvidia.com>
next reply other threads:[~2026-01-20 8:54 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-20 8:52 Eliot Courtney [this message]
2026-01-20 8:52 ` [PATCH 1/6] scripts: generate_rust_analyzer: rename cfg to generated_cfg Eliot Courtney
2026-01-20 15:28 ` Tamir Duberstein
2026-03-02 17:09 ` Tamir Duberstein
2026-01-20 8:52 ` [PATCH 2/6] scripts: generate_rust_analyzer: plumb editions via command line Eliot Courtney
2026-01-20 13:57 ` Miguel Ojeda
2026-01-20 15:28 ` Tamir Duberstein
2026-01-20 8:52 ` [PATCH 3/6] scripts: generate_rust_analyzer: plumb crate-attrs Eliot Courtney
2026-01-20 15:28 ` Tamir Duberstein
2026-01-20 8:52 ` [PATCH 4/6] scripts: generate_rust_analyzer: plumb common crate-attrs for non-host crates Eliot Courtney
2026-01-20 15:28 ` Tamir Duberstein
2026-01-20 8:52 ` [PATCH 5/6] scripts: generate_rust_analyzer: add pin_init to driver crate deps Eliot Courtney
2026-01-20 15:28 ` Tamir Duberstein
2026-01-20 8:52 ` [PATCH 6/6] scripts: generate_rust_analyzer: move sysroot crates to sysroot_project Eliot Courtney
2026-01-20 15:34 ` Tamir Duberstein
2026-01-21 0:01 ` Jesung Yang
2026-01-22 9:23 ` Eliot Courtney
2026-01-22 11:06 ` Jesung Yang
2026-01-23 5:45 ` Eliot Courtney
2026-01-23 12:08 ` Miguel Ojeda
2026-01-23 12:23 ` Gary Guo
2026-01-23 12:31 ` Miguel Ojeda
2026-01-20 13:38 ` [PATCH 0/6] scripts: generate_rust_analyzer: improve rust-project.json generation Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260120-ra-fix-v1-0-829e4e92818c@nvidia.com \
--to=ecourtney@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®