Skip to content

Commit d9d49cb

Browse files
committed
rust: ensure libmodule.so gets recompiled when rustc version changes
Procedural macros can only be used with the rustc that compiles it. When rustc version changes, the corresponding libcore source code also changes, so adding `core.o` to the dependency of `libmodule.so` can force a recompilation of `libmodule.so`. Signed-off-by: Gary Guo <gary@garyguo.net>
1 parent 50f2249 commit d9d49cb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

rust/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
126126
mv $(objtree)/rust/$(patsubst lib%.so,%,$(notdir $@)).d $(depfile); \
127127
sed -i '/^\#/d' $(depfile)
128128

129-
$(objtree)/rust/libmodule.so: $(srctree)/rust/module.rs FORCE
129+
# Procedural macros can only be used with the `rustc` that compiled it.
130+
# Therefore, to get `libmodule.so` automatically recompiled when the compiler
131+
# version changes, we add `core.o` as a dependency (even if it is not needed).
132+
$(objtree)/rust/libmodule.so: $(srctree)/rust/module.rs \
133+
$(objtree)/rust/core.o FORCE
130134
$(call if_changed_dep,rustc_procmacro)
131135

132136
quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L $@

0 commit comments

Comments
 (0)