summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorMiguel Ojeda <ojeda@kernel.org>2025-11-24 16:18:15 +0100
committerMiguel Ojeda <ojeda@kernel.org>2025-11-24 17:15:36 +0100
commit7dbe46c0b11dded16cf9c5f85c1a3f260422cee5 (patch)
tree0ae20348f4e0a6e1013b933065ac15444f33913d /rust
parent1181c974421818ff7318e3a211c87b5dd437c13e (diff)
rust: kbuild: add proc macro library support
Add the proc macro library rule that produces `.rlib` files to be used by proc macros such as the `macros` crate. Reviewed-by: Gary Guo <gary@garyguo.net> Tested-by: Gary Guo <gary@garyguo.net> Tested-by: Jesung Yang <y.j3ms.n@gmail.com> Link: https://patch.msgid.link/20251124151837.2184382-4-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust')
-rw-r--r--rust/Makefile10
1 files changed, 10 insertions, 0 deletions
diff --git a/rust/Makefile b/rust/Makefile
index 9967f3457d44..45ef84513b6c 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -421,6 +421,16 @@ $(obj)/exports_bindings_generated.h: $(obj)/bindings.o FORCE
$(obj)/exports_kernel_generated.h: $(obj)/kernel.o FORCE
$(call if_changed,exports)
+quiet_cmd_rustc_procmacrolibrary = $(RUSTC_OR_CLIPPY_QUIET) PL $@
+ cmd_rustc_procmacrolibrary = \
+ $(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \
+ $(filter-out $(skip_flags),$(rust_common_flags) $(rustc_target_flags)) \
+ --emit=dep-info,link --crate-type rlib -O \
+ --out-dir $(objtree)/$(obj) -L$(objtree)/$(obj) \
+ --crate-name $(patsubst lib%.rlib,%,$(notdir $@)) $<; \
+ mv $(objtree)/$(obj)/$(patsubst lib%.rlib,%,$(notdir $@)).d $(depfile); \
+ sed -i '/^\#/d' $(depfile)
+
quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
cmd_rustc_procmacro = \
$(RUSTC_OR_CLIPPY) $(rust_common_flags) $(rustc_target_flags) \