lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260120-ra-fix-v1-2-829e4e92818c@nvidia.com>
Date: Tue, 20 Jan 2026 17:52:51 +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 2/6] scripts: generate_rust_analyzer: plumb editions via
 command line

Add --editions argument to pass crate editions in a similar way to the
existing --cfgs mechanism.

It sets editions as follows:
  - core: 2024 for rustc >= 1.87 otherwise 2021
  - quote: 2018
  - all others: 2021

Signed-off-by: Eliot Courtney <ecourtney@...dia.com>
---
 rust/Makefile                     |  8 +++--
 scripts/generate_rust_analyzer.py | 70 ++++++++++++++++++++++-----------------
 2 files changed, 45 insertions(+), 33 deletions(-)

diff --git a/rust/Makefile b/rust/Makefile
index 4dcc2eff51cb..2238b0b69197 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -95,8 +95,10 @@ quote-cfgs := \
 quote-skip_flags := \
     --edition=2021
 
+quote-edition := 2018
+
 quote-flags := \
-    --edition=2018 \
+    --edition=$(quote-edition) \
     --cap-lints=allow \
     --extern proc_macro2 \
     $(call cfgs-to-flags,$(quote-cfgs))
@@ -567,10 +569,12 @@ 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) \
+		--cfgs='core=$(core-cfgs)' \
 		--cfgs='proc_macro2=$(proc_macro2-cfgs)' \
 		--cfgs='quote=$(quote-cfgs)' \
 		--cfgs='syn=$(syn-cfgs)' \
+		--editions='core=$(core-edition)' \
+		--editions='quote=$(quote-edition)' \
 		$(realpath $(srctree)) $(realpath $(objtree)) \
 		$(rustc_sysroot) $(RUST_LIB_SRC) $(if $(KBUILD_EXTMOD),$(srcroot)) \
 		> rust-project.json
diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
index c188d1f1fd5b..17ed5546504b 100755
--- a/scripts/generate_rust_analyzer.py
+++ b/scripts/generate_rust_analyzer.py
@@ -11,6 +11,13 @@ import pathlib
 import subprocess
 import sys
 
+def args_single(args):
+    result = {}
+    for arg in args:
+        crate, val = arg.split("=", 1)
+        result[crate] = val
+    return result
+
 def args_crates_cfgs(cfgs):
     crates_cfgs = {}
     for cfg in cfgs:
@@ -19,7 +26,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, editions):
     # Generate the configuration list.
     generated_cfg = []
     with open(objtree / "include" / "generated" / "rustc_cfg") as fd:
@@ -34,8 +41,35 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
     crates = []
     crates_indexes = {}
     crates_cfgs = args_crates_cfgs(cfgs)
+    crates_editions = args_single(editions)
+
+    def append_crate(display_name, root_module, deps, cfg=[], is_workspace_member=True, is_proc_macro=False):
+        # Miguel Ojeda writes:
+        #
+        # > ... in principle even the sysroot crates may have different
+        # > editions.
+        # >
+        # > For instance, in the move to 2024, it seems all happened at once
+        # > in 1.87.0 in these upstream commits:
+        # >
+        # >     0e071c2c6a58 ("Migrate core to Rust 2024")
+        # >     f505d4e8e380 ("Migrate alloc to Rust 2024")
+        # >     0b2489c226c3 ("Migrate proc_macro to Rust 2024")
+        # >     993359e70112 ("Migrate std to Rust 2024")
+        # >
+        # > But in the previous move to 2021, `std` moved in 1.59.0, while
+        # > the others in 1.60.0:
+        # >
+        # >     b656384d8398 ("Update stdlib to the 2021 edition")
+        # >     06a1c14d52a8 ("Switch all libraries to the 2021 edition")
+        #
+        # Link: https://lore.kernel.org/all/CANiq72kd9bHdKaAm=8xCUhSHMy2csyVed69bOc4dXyFAW4sfuw@mail.gmail.com/
+        #
+        # At the time of writing all rust versions we support build the
+        # sysroot crates with the same edition. We may need to relax this
+        # assumption if future edition moves span multiple rust versions.
+        edition = crates_editions.get(display_name, "2021")
 
-    def append_crate(display_name, root_module, deps, cfg=[], is_workspace_member=True, is_proc_macro=False, edition="2021"):
         crate = {
             "display_name": display_name,
             "root_module": str(root_module),
@@ -68,31 +102,6 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
             deps,
             cfg,
             is_workspace_member=False,
-            # Miguel Ojeda writes:
-            #
-            # > ... in principle even the sysroot crates may have different
-            # > editions.
-            # >
-            # > For instance, in the move to 2024, it seems all happened at once
-            # > in 1.87.0 in these upstream commits:
-            # >
-            # >     0e071c2c6a58 ("Migrate core to Rust 2024")
-            # >     f505d4e8e380 ("Migrate alloc to Rust 2024")
-            # >     0b2489c226c3 ("Migrate proc_macro to Rust 2024")
-            # >     993359e70112 ("Migrate std to Rust 2024")
-            # >
-            # > But in the previous move to 2021, `std` moved in 1.59.0, while
-            # > the others in 1.60.0:
-            # >
-            # >     b656384d8398 ("Update stdlib to the 2021 edition")
-            # >     06a1c14d52a8 ("Switch all libraries to the 2021 edition")
-            #
-            # Link: https://lore.kernel.org/all/CANiq72kd9bHdKaAm=8xCUhSHMy2csyVed69bOc4dXyFAW4sfuw@mail.gmail.com/
-            #
-            # At the time of writing all rust versions we support build the
-            # sysroot crates with the same edition. We may need to relax this
-            # assumption if future edition moves span multiple rust versions.
-            edition=core_edition,
         )
 
     # NB: sysroot crates reexport items from one another so setting up our transitive dependencies
@@ -120,8 +129,7 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
         "quote",
         srctree / "rust" / "quote" / "lib.rs",
         ["core", "alloc", "std", "proc_macro", "proc_macro2"],
-        cfg=crates_cfgs["quote"],
-        edition="2018",
+        cfg=crates_cfgs["quote"]
     )
 
     append_crate(
@@ -224,7 +232,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('--editions', action='append', default=[])
     parser.add_argument("srctree", type=pathlib.Path)
     parser.add_argument("objtree", type=pathlib.Path)
     parser.add_argument("sysroot", type=pathlib.Path)
@@ -238,7 +246,7 @@ def main():
     )
 
     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.editions),
         "sysroot": str(args.sysroot),
     }
 

-- 
2.52.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ