[PATCH v2 10/13] kbuild: rebuild modules when objtool is updated for CONFIG_LTO_CLANG

Masahiro Yamada
2021-08-31T07:40:47Z

We rebuilt objects when objtool was updated, but only for non LTO
builds.

For CONFIG_LTO_CLANG, the objtool step is postponed by the link time,
and nothing happens even if objtool is updated.

Add the proper objtool dependency to the pre-modpost module link
for CONFIG_LTO_CLANG.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

scripts/Makefile.build | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index cdc09e9080ca..b94dfc87b7fa 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -451,10 +451,15 @@ endif
quiet_cmd_ld_o_a = LD [M] $@
cmd_ld_o_a = $(LD) $(ld_flags) -r -o $@ --whole-archive $< $(cmd_objtool)

+define rule_ld_o_a
+ $(call cmd_and_savecmd,ld_o_a)
+ $(call cmd,gen_objtooldep)
+endef
+
$(obj)/%.prelink.o: part-of-module := y

$(obj)/%.prelink.o: $(obj)/%.a $(module-symver) FORCE
- $(call if_changed,ld_o_a)
+ $(call if_changed_rule,ld_o_a)

quiet_cmd_ar_module = AR [M] $@
cmd_ar_module = rm -f $@; $(AR) cDPrST $@ $(real-prereqs)
--
2.30.2