Skip to content

Commit ac3e972

Browse files
committed
kbuild: rust: rebuild if the version text changes
Now that `RUSTC_VERSION_TEXT` exists, use it to rebuild `core` when the version text changes (which in turn will trigger a rebuild of all the kernel Rust code). This also applies to proc macros (which only work with the `rustc` that compiled them), via the already existing dependency on `core.o`. That is cleaned up in the next commit. However, this does not cover host programs written in Rust, which is the same case in the C side. This is accomplished by referencing directly the generated file, instead of using the `fixdep` header trick, since we cannot change the Rust standard library sources. This is not too much of a burden, since it only needs to be done for `core`. Tested-by: Alice Ryhl <[email protected]> Reviewed-by: Nicolas Schier <[email protected]> Acked-by: Masahiro Yamada <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 5134a33 commit ac3e972

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

rust/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,8 @@ $(obj)/core.o: private skip_clippy = 1
389389
$(obj)/core.o: private skip_flags = -Wunreachable_pub
390390
$(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym))
391391
$(obj)/core.o: private rustc_target_flags = $(core-cfgs)
392-
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE
392+
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs \
393+
$(wildcard $(objtree)/include/config/RUSTC_VERSION_TEXT) FORCE
393394
+$(call if_changed_rule,rustc_library)
394395
ifneq ($(or $(CONFIG_X86_64),$(CONFIG_X86_32)),)
395396
$(obj)/core.o: scripts/target.json

0 commit comments

Comments
 (0)