[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260115-rust-analyzer-sysroot-v1-1-4de831df234a@gmail.com>
Date: Thu, 15 Jan 2026 11:35:50 -0500
From: Tamir Duberstein <tamird@...nel.org>
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>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
Tamir Duberstein <tamird@...il.com>
Subject: [PATCH] scripts: generate_rust_analyzer: compile sysroot with
correct edition
From: Tamir Duberstein <tamird@...il.com>
Rename `core-edition` to `sysroot-edition` to align with the naming used
to refer to standard library crates in `generate_rust_analyzer.py` and
apply it to all standard library crates rather than just core.
Note that backporting this will conflict unless commit 46e58a9637ec ("rust:
kbuild: introduce `core-flags` and `core-skip_flags`") is also backported.
Fixes: f4daa80d6be7 ("rust: compile libcore with edition 2024 for 1.87+")
Signed-off-by: Tamir Duberstein <tamird@...il.com>
---
rust/Makefile | 7 ++++---
scripts/generate_rust_analyzer.py | 11 +++++------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/rust/Makefile b/rust/Makefile
index 4dcc2eff51cb..a8ded6c07255 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -67,7 +67,7 @@ cfgs-to-flags = $(patsubst %,--cfg='%',$1)
core-cfgs := \
no_fp_fmt_parse
-core-edition := $(if $(call rustc-min-version,108700),2024,2021)
+sysroot_edition := $(if $(call rustc-min-version,108700),2024,2021)
core-skip_flags := \
--edition=2021 \
@@ -75,7 +75,7 @@ core-skip_flags := \
-Wrustdoc::unescaped_backticks
core-flags := \
- --edition=$(core-edition) \
+ --edition=$(sysroot_edition) \
$(call cfgs-to-flags,$(core-cfgs))
proc_macro2-cfgs := \
@@ -567,7 +567,8 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L
rust-analyzer:
$(Q)MAKEFLAGS= $(srctree)/scripts/generate_rust_analyzer.py \
- --cfgs='core=$(core-cfgs)' $(core-edition) \
+ $(sysroot_edition) \
+ --cfgs='core=$(core-cfgs)' \
--cfgs='proc_macro2=$(proc_macro2-cfgs)' \
--cfgs='quote=$(quote-cfgs)' \
--cfgs='syn=$(syn-cfgs)' \
diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
index 6061bd6e2ebd..47e49f8dacbc 100755
--- a/scripts/generate_rust_analyzer.py
+++ b/scripts/generate_rust_analyzer.py
@@ -19,7 +19,7 @@ def args_crates_cfgs(cfgs):
return crates_cfgs
-def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edition):
+def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, sysroot_edition):
# Generate the configuration list.
cfg = []
with open(objtree / "include" / "generated" / "rustc_cfg") as fd:
@@ -61,7 +61,6 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
display_name,
deps,
cfg=[],
- edition="2021",
):
append_crate(
display_name,
@@ -69,13 +68,13 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
deps,
cfg,
is_workspace_member=False,
- edition=edition,
+ edition=sysroot_edition,
)
# NB: sysroot crates reexport items from one another so setting up our transitive dependencies
# here is important for ensuring that rust-analyzer can resolve symbols. The sources of truth
# for this dependency graph are `(sysroot_src / crate / "Cargo.toml" for crate in crates)`.
- append_sysroot_crate("core", [], cfg=crates_cfgs.get("core", []), edition=core_edition)
+ append_sysroot_crate("core", [], cfg=crates_cfgs.get("core", []))
append_sysroot_crate("alloc", ["core"])
append_sysroot_crate("std", ["alloc", "core"])
append_sysroot_crate("proc_macro", ["core", "std"])
@@ -200,7 +199,7 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument('--verbose', '-v', action='store_true')
parser.add_argument('--cfgs', action='append', default=[])
- parser.add_argument("core_edition")
+ parser.add_argument("sysroot_edition")
parser.add_argument("srctree", type=pathlib.Path)
parser.add_argument("objtree", type=pathlib.Path)
parser.add_argument("sysroot", type=pathlib.Path)
@@ -217,7 +216,7 @@ def main():
assert args.sysroot in args.sysroot_src.parents
rust_project = {
- "crates": generate_crates(args.srctree, args.objtree, args.sysroot_src, args.exttree, args.cfgs, args.core_edition),
+ "crates": generate_crates(args.srctree, args.objtree, args.sysroot_src, args.exttree, args.cfgs, args.sysroot_edition),
"sysroot": str(args.sysroot),
}
---
base-commit: 74e15ac34b098934895fd27655d098971d2b43d9
change-id: 20260115-rust-analyzer-sysroot-5fb95aa985d2
Best regards,
--
Tamir Duberstein <tamird@...il.com>
Powered by blists - more mailing lists