diff mbox series

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

Message ID 20210831074004.3195284-11-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series kbuild: second round of Clang LTO refactoring | expand

Commit Message

Masahiro Yamada Aug. 31, 2021, 7:40 a.m. UTC
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(-)

Comments

Kees Cook Aug. 31, 2021, 5:40 p.m. UTC | #1
On Tue, Aug 31, 2021 at 04:40:01PM +0900, Masahiro Yamada wrote:
> 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>

Reviewed-by: Kees Cook <keescook@chromium.org>
Josh Poimboeuf Sept. 4, 2021, 7:13 p.m. UTC | #2
On Tue, Aug 31, 2021 at 04:40:01PM +0900, Masahiro Yamada wrote:
> 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>

Nice!

Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
diff mbox series

Patch

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)