History

Merge tag 'rust-fixes-6.14-3' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux

Pull rust fixes from Miguel Ojeda: "Toolchain and infrastructure: - Disallow BTF generation with Rust + LTO - Improve rust-analyzer support 'kernel' crate: - 'init' module: remove 'Zeroable' implementation for a couple types that should not have it - 'alloc' module: fix macOS failure in host test by satisfying POSIX alignment requirement - Add missing '\n's to 'pr_*!()' calls And a couple other minor cleanups" * tag 'rust-fixes-6.14-3' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux: scripts: generate_rust_analyzer: add uapi crate scripts: generate_rust_analyzer: add missing include_dirs scripts: generate_rust_analyzer: add missing macros deps rust: Disallow BTF generation with Rust + LTO rust: task: fix `SAFETY` comment in `Task::wake_up` rust: workqueue: add missing newline to pr_info! examples rust: sync: add missing newline in locked_by log example rust: init: add missing newline to pr_info! calls rust: error: add missing newline to pr_warn! calls rust: docs: add missing newline to printing macro examples rust: alloc: satisfy POSIX alignment requirement rust: init: fix `Zeroable` implementation for `Option<NonNull<T>>` and `Option<KBox<T>>` rust: remove leftover mentions of the `alloc` crate

Linus Torvalds committed 1 year ago

Commit cd3a56a2 parents eb88e6b a1eb95d13 files · +85 −57Browse files

Showing the changes to scripts (2 of 13 files). Show all

Unified · Split

2 files
  1. scripts/generate_rust_analyzer.py +42 −29
  2. scripts/rustdoc_test_gen.rs +2 −2
scripts/generate_rust_analyzer.py+42−29
@@ -57,14 +57,26 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs): · 56 unmodified lines
5757 crates_indexes[display_name] = len(crates)
5858 crates.append(crate)
5959
60− # First, the ones in `rust/` since they are a bit special.
61− append_crate(
62− "core",
63− sysroot_src / "core" / "src" / "lib.rs",
64− [],
65− cfg=crates_cfgs.get("core", []),
66− is_workspace_member=False,
67− )
60+ def append_sysroot_crate(
61+ display_name,
62+ deps,
63+ cfg=[],
64+ ):
65+ append_crate(
66+ display_name,
67+ sysroot_src / display_name / "src" / "lib.rs",
68+ deps,
69+ cfg,
70+ is_workspace_member=False,
71+ )
72+
73+ # NB: sysroot crates reexport items from one another so setting up our transitive dependencies
74+ # here is important for ensuring that rust-analyzer can resolve symbols. The sources of truth
75+ # for this dependency graph are `(sysroot_src / crate / "Cargo.toml" for crate in crates)`.
76+ append_sysroot_crate("core", [], cfg=crates_cfgs.get("core", []))
77+ append_sysroot_crate("alloc", ["core"])
78+ append_sysroot_crate("std", ["alloc", "core"])
79+ append_sysroot_crate("proc_macro", ["core", "std"])
6880
6981 append_crate(
7082 "compiler_builtins",
@@ -75,7 +87,7 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs): · 4 unmodified lines
7587 append_crate(
7688 "macros",
7789 srctree / "rust" / "macros" / "lib.rs",
78− [],
90+ ["std", "proc_macro"],
7991 is_proc_macro=True,
8092 )
8193
@@ -85,27 +97,28 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs): · 3 unmodified lines
8597 ["core", "compiler_builtins"],
8698 )
8799
88− append_crate(
89− "bindings",
90− srctree / "rust"/ "bindings" / "lib.rs",
91− ["core"],
92− cfg=cfg,
93− )
94− crates[-1]["env"]["OBJTREE"] = str(objtree.resolve(True))
100+ def append_crate_with_generated(
101+ display_name,
102+ deps,
103+ ):
104+ append_crate(
105+ display_name,
106+ srctree / "rust"/ display_name / "lib.rs",
107+ deps,
108+ cfg=cfg,
109+ )
110+ crates[-1]["env"]["OBJTREE"] = str(objtree.resolve(True))
111+ crates[-1]["source"] = {
112+ "include_dirs": [
113+ str(srctree / "rust" / display_name),
114+ str(objtree / "rust")
115+ ],
116+ "exclude_dirs": [],
117+ }
95118
96− append_crate(
97− "kernel",
98− srctree / "rust" / "kernel" / "lib.rs",
99− ["core", "macros", "build_error", "bindings"],
100− cfg=cfg,
101− )
102− crates[-1]["source"] = {
103− "include_dirs": [
104− str(srctree / "rust" / "kernel"),
105− str(objtree / "rust")
106− ],
107− "exclude_dirs": [],
108− }
119+ append_crate_with_generated("bindings", ["core"])
120+ append_crate_with_generated("uapi", ["core"])
121+ append_crate_with_generated("kernel", ["core", "macros", "build_error", "bindings", "uapi"])
109122
110123 def is_root_crate(build_file, target):
111124 try:
scripts/rustdoc_test_gen.rs+2−2
@@ -15,8 +15,8 @@ · 14 unmodified lines
1515 //! - Test code should be able to define functions and call them, without having to carry
1616 //! the context.
1717 //!
18−//! - Later on, we may want to be able to test non-kernel code (e.g. `core`, `alloc` or
19−//! third-party crates) which likely use the standard library `assert*!` macros.
18+//! - Later on, we may want to be able to test non-kernel code (e.g. `core` or third-party
19+//! crates) which likely use the standard library `assert*!` macros.
2020 //!
2121 //! For this reason, instead of the passed context, `kunit_get_current_test()` is used instead
2222 //! (i.e. `current->kunit_test`).