rust: kbuild: rebuild if `.clippy.toml` changes
Subsystems (3)
Miguel Ojeda
maintainerPATCH v2 1/1 rust: kbuild: rebuild if `.clippy.toml` changes
We rarely modify .clippy.toml, but currently we do not rebuild if that happens, thus it is easy to miss possible changes in lints.
Thus rebuild in case of changes.
--- rust/Makefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
rust/Makefile +9 -3
@@ -57,6 +57,10 @@ rustdoc_test_quiet=--test-args -q rustdoc_test_kernel_quiet=>/dev/null endif +ifeq ($(KBUILD_CLIPPY),1) + clippy_toml := $(srctree)/.clippy.toml +endif + core-cfgs = \ --cfg no_fp_fmt_parse
@@ -405,11 +409,12 @@ quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@ --crate-name $(patsubst lib%.$(libmacros_extension),%,$(notdir $@)) $< # Procedural macros can only be used with the `rustc` that compiled it. -$(obj)/$(libmacros_name): $(src)/macros/lib.rs FORCE +$(obj)/$(libmacros_name): $(src)/macros/lib.rs $(clippy_toml) FORCE +$(call if_changed_dep,rustc_procmacro) $(obj)/$(libpin_init_internal_name): private rustc_target_flags = --cfg kernel -$(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/lib.rs FORCE +$(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/lib.rs \ + $(clippy_toml) FORCE +$(call if_changed_dep,rustc_procmacro) quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L $@
@@ -495,7 +500,8 @@ endif $(obj)/compiler_builtins.o: private skip_gendwarfksyms = 1 $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' -$(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE +$(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o \ + $(clippy_toml) FORCE +$(call if_changed_rule,rustc_library) $(obj)/pin_init.o: private skip_gendwarfksyms = 1
base-commit: 22c3335c5dcd33063fe1894676a3a6ff1008d506
Signature · 1 line
2.49.0
rust/Makefile rustdoc_test_quiet=--test-args -q · line 62
Quoted 4 lines · Miguel Ojeda
rust/Makefile +3
-0+ifeq ($(KBUILD_CLIPPY),1) + clippy_toml := $(srctree)/.clippy.toml +endif
Not sure if this is worth it (see v1), but I think it works, at least from light testing.
More testing for v2 is welcome (v1 is "obviously correct").
Thanks!
Cheers,
Miguel
Quoted 46 lines · Miguel Ojeda
We rarely modify
.clippy.toml, but currently we do not rebuild if that happens, thus it is easy to miss possible changes in lints.Thus rebuild in case of changes.
Reported-by Tamir Duberstein <[email protected]>Fixes 7d56786edcbd ("rust: introduce `.clippy.toml`")Signed-off-by Miguel Ojeda <[email protected]>--- rust/Makefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)rust/Makefile +7
-2@@ -57,6 +57,10 @@ rustdoc_test_quiet=--test-args -q rustdoc_test_kernel_quiet=>/dev/null endif +ifeq ($(KBUILD_CLIPPY),1) + clippy_toml := $(srctree)/.clippy.toml +endif + core-cfgs = \ --cfg no_fp_fmt_parse@@ -405,11 +409,12 @@ quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@ --crate-name $(patsubst lib%.$(libmacros_extension),%,$(notdir $@)) $< # Procedural macros can only be used with the `rustc` that compiled it. -$(obj)/$(libmacros_name): $(src)/macros/lib.rs FORCE +$(obj)/$(libmacros_name): $(src)/macros/lib.rs $(clippy_toml) FORCE +$(call if_changed_dep,rustc_procmacro) $(obj)/$(libpin_init_internal_name): private rustc_target_flags = --cfg kernel -$(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/lib.rs FORCE +$(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/lib.rs \ + $(clippy_toml) FORCE +$(call if_changed_dep,rustc_procmacro) quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L $@
rust/Makefile endif · line 507
Quoted 9 lines
rust/Makefile +2
-1@@ -495,7 +500,8 @@ endif $(obj)/compiler_builtins.o: private skip_gendwarfksyms = 1 $(obj)/compiler_builtins.o: private rustc_objcopy = -w -W '__*' -$(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE +$(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o \ + $(clippy_toml) FORCE +$(call if_changed_rule,rustc_library) $(obj)/pin_init.o: private skip_gendwarfksyms = 1
This is only changing 3 targets, right? libmacros, libpin_init, and compiler_builtins. Can you help me understand why only these need to change? Is it because these are leaf nodes in the graph?
The rusttest target wouldn't rebuild properly, I think? Is it possible to apply this rule to all rust targets, rather than individual ones?