@@ -84,18 +84,17 @@ bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \
8484 $(bindgen_extra_c_flags )
8585endif
8686
87- bindgen_opaque_types := xregs_state desc_struct arch_lbr_state local_apic
88-
8987# To avoid several recompilations in PowerPC, which inserts `-D_TASK_CPU`
9088bindgen_c_flags_final = $(filter-out -D_TASK_CPU=% , $(bindgen_c_flags ) )
9189
9290quiet_cmd_bindgen = BINDGEN $@
9391 cmd_bindgen = \
94- $(BINDGEN ) $< $(addprefix --opaque-type , $(bindgen_opaque_types ) ) \
92+ $(BINDGEN ) $< $(shell grep -v '^\#\|^$$' $(srctree ) /rust/bindgen_parameters ) \
9593 --use-core --with-derive-default --ctypes-prefix c_types \
9694 --size_t-is-usize -o $@ -- $(bindgen_c_flags_final ) -DMODULE
9795
98- $(objtree ) /rust/bindings_generated.rs : $(srctree ) /rust/kernel/bindings_helper.h FORCE
96+ $(objtree ) /rust/bindings_generated.rs : $(srctree ) /rust/kernel/bindings_helper.h \
97+ $(srctree ) /rust/bindgen_parameters FORCE
9998 $(call if_changed_dep,bindgen)
10099
101100quiet_cmd_exports = EXPORTS $@
@@ -126,7 +125,11 @@ quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
126125 mv $(objtree ) /rust/$(patsubst lib% .so,% ,$(notdir $@ ) ) .d $(depfile ) ; \
127126 sed -i '/^\# /d' $(depfile)
128127
129- $(objtree ) /rust/libmodule.so : $(srctree ) /rust/module.rs FORCE
128+ # Procedural macros can only be used with the `rustc` that compiled it.
129+ # Therefore, to get `libmodule.so` automatically recompiled when the compiler
130+ # version changes, we add `core.o` as a dependency (even if it is not needed).
131+ $(objtree ) /rust/libmodule.so : $(srctree ) /rust/module.rs \
132+ $(objtree ) /rust/core.o FORCE
130133 $(call if_changed_dep,rustc_procmacro)
131134
132135quiet_cmd_rustc_library = $(if $(skip_clippy ) ,RUSTC,$(RUSTC_OR_CLIPPY_QUIET ) ) L $@
0 commit comments