1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00

rust: kbuild: expand rusttest target for macros

Previously, the rusttest target for the macros crate did not specify
the dependencies necessary to run the rustdoc tests. These tests rely on
the kernel crate, so add the dependencies.

Signed-off-by: Ethan D. Twardy <ethan.twardy@gmail.com>
Link: https://github.com/Rust-for-Linux/linux/issues/1076
Link: https://lore.kernel.org/r/20240704145607.17732-2-ethan.twardy@gmail.com
[ Rebased (`alloc` is gone nowadays, sysroot handling is simpler) and
  simplified (reused `rustdoc_test` rule instead of adding a new one,
  no need for `rustdoc-compiler_builtins`, removed unneeded `macros`
  explicit path). Made `vtable` example fail (avoiding to increase
  the complexity in the `rusttest` target). Removed unstable
  `-Zproc-macro-backtrace` option. Reworded accordingly. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
Ethan D. Twardy 2024-07-04 09:55:42 -05:00 committed by Miguel Ojeda
parent 718c406989
commit b2c261fa86
2 changed files with 14 additions and 5 deletions
rust

View file

@ -129,6 +129,14 @@ rusttestlib-macros: private rustc_test_library_proc = yes
rusttestlib-macros: $(src)/macros/lib.rs FORCE rusttestlib-macros: $(src)/macros/lib.rs FORCE
+$(call if_changed,rustc_test_library) +$(call if_changed,rustc_test_library)
rusttestlib-kernel: private rustc_target_flags = \
--extern build_error --extern macros \
--extern bindings --extern uapi
rusttestlib-kernel: $(src)/kernel/lib.rs \
rusttestlib-bindings rusttestlib-uapi rusttestlib-build_error \
$(obj)/libmacros.so $(obj)/bindings.o FORCE
+$(call if_changed,rustc_test_library)
rusttestlib-bindings: $(src)/bindings/lib.rs FORCE rusttestlib-bindings: $(src)/bindings/lib.rs FORCE
+$(call if_changed,rustc_test_library) +$(call if_changed,rustc_test_library)
@ -181,19 +189,20 @@ quiet_cmd_rustc_test = RUSTC T $<
rusttest: rusttest-macros rusttest-kernel rusttest: rusttest-macros rusttest-kernel
rusttest-macros: private rustc_target_flags = --extern proc_macro rusttest-macros: private rustc_target_flags = --extern proc_macro \
--extern macros --extern kernel
rusttest-macros: private rustdoc_test_target_flags = --crate-type proc-macro rusttest-macros: private rustdoc_test_target_flags = --crate-type proc-macro
rusttest-macros: $(src)/macros/lib.rs FORCE rusttest-macros: $(src)/macros/lib.rs \
rusttestlib-macros rusttestlib-kernel FORCE
+$(call if_changed,rustc_test) +$(call if_changed,rustc_test)
+$(call if_changed,rustdoc_test) +$(call if_changed,rustdoc_test)
rusttest-kernel: private rustc_target_flags = \ rusttest-kernel: private rustc_target_flags = \
--extern build_error --extern macros --extern bindings --extern uapi --extern build_error --extern macros --extern bindings --extern uapi
rusttest-kernel: $(src)/kernel/lib.rs \ rusttest-kernel: $(src)/kernel/lib.rs rusttestlib-kernel \
rusttestlib-build_error rusttestlib-macros rusttestlib-bindings \ rusttestlib-build_error rusttestlib-macros rusttestlib-bindings \
rusttestlib-uapi FORCE rusttestlib-uapi FORCE
+$(call if_changed,rustc_test) +$(call if_changed,rustc_test)
+$(call if_changed,rustc_test_library)
ifdef CONFIG_CC_IS_CLANG ifdef CONFIG_CC_IS_CLANG
bindgen_c_flags = $(c_flags) bindgen_c_flags = $(c_flags)

View file

@ -132,7 +132,7 @@ pub fn module(ts: TokenStream) -> TokenStream {
/// calls to this function at compile time: /// calls to this function at compile time:
/// ///
/// ```compile_fail /// ```compile_fail
/// # use kernel::error::VTABLE_DEFAULT_ERROR; /// # // Intentionally missing `use`s to simplify `rusttest`.
/// kernel::build_error(VTABLE_DEFAULT_ERROR) /// kernel::build_error(VTABLE_DEFAULT_ERROR)
/// ``` /// ```
/// ///