Skip to content

Commit b2c261f

Browse files
AmateurECEojeda
authored andcommitted
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 <[email protected]> Link: Rust-for-Linux/linux#1076 Link: https://lore.kernel.org/r/[email protected] [ 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 <[email protected]>
1 parent 718c406 commit b2c261f

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

rust/Makefile

+13-4
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ rusttestlib-macros: private rustc_test_library_proc = yes
129129
rusttestlib-macros: $(src)/macros/lib.rs FORCE
130130
+$(call if_changed,rustc_test_library)
131131

132+
rusttestlib-kernel: private rustc_target_flags = \
133+
--extern build_error --extern macros \
134+
--extern bindings --extern uapi
135+
rusttestlib-kernel: $(src)/kernel/lib.rs \
136+
rusttestlib-bindings rusttestlib-uapi rusttestlib-build_error \
137+
$(obj)/libmacros.so $(obj)/bindings.o FORCE
138+
+$(call if_changed,rustc_test_library)
139+
132140
rusttestlib-bindings: $(src)/bindings/lib.rs FORCE
133141
+$(call if_changed,rustc_test_library)
134142

@@ -181,19 +189,20 @@ quiet_cmd_rustc_test = RUSTC T $<
181189

182190
rusttest: rusttest-macros rusttest-kernel
183191

184-
rusttest-macros: private rustc_target_flags = --extern proc_macro
192+
rusttest-macros: private rustc_target_flags = --extern proc_macro \
193+
--extern macros --extern kernel
185194
rusttest-macros: private rustdoc_test_target_flags = --crate-type proc-macro
186-
rusttest-macros: $(src)/macros/lib.rs FORCE
195+
rusttest-macros: $(src)/macros/lib.rs \
196+
rusttestlib-macros rusttestlib-kernel FORCE
187197
+$(call if_changed,rustc_test)
188198
+$(call if_changed,rustdoc_test)
189199

190200
rusttest-kernel: private rustc_target_flags = \
191201
--extern build_error --extern macros --extern bindings --extern uapi
192-
rusttest-kernel: $(src)/kernel/lib.rs \
202+
rusttest-kernel: $(src)/kernel/lib.rs rusttestlib-kernel \
193203
rusttestlib-build_error rusttestlib-macros rusttestlib-bindings \
194204
rusttestlib-uapi FORCE
195205
+$(call if_changed,rustc_test)
196-
+$(call if_changed,rustc_test_library)
197206

198207
ifdef CONFIG_CC_IS_CLANG
199208
bindgen_c_flags = $(c_flags)

rust/macros/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub fn module(ts: TokenStream) -> TokenStream {
132132
/// calls to this function at compile time:
133133
///
134134
/// ```compile_fail
135-
/// # use kernel::error::VTABLE_DEFAULT_ERROR;
135+
/// # // Intentionally missing `use`s to simplify `rusttest`.
136136
/// kernel::build_error(VTABLE_DEFAULT_ERROR)
137137
/// ```
138138
///

0 commit comments

Comments
 (0)