Message ID | 20200501224300.1012-1-marek.behun@nic.cz (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [kbuild,RFC] kbuild: fix modpost throwing away module symvers when linking vmlinux.o | expand |
Just to note how this breaks things: On OpenWRT this may happen 1. make modules is run - Module.symvers contains symbols from modules 2. make Image/bzImage is run (as part of another OpenWRT make target) - Module.symvers is rewritten to contain only vmlinux.o symbols 3. external kernel modules try to build (wireguard, mac80211) - this now fails because external modules may depend on symbols from other modules and this information isn't in Module.symvers anymore Marek
On Sun, May 3, 2020 at 3:29 AM Marek Behun <marek.behun@nic.cz> wrote: > > Just to note how this breaks things: > > On OpenWRT this may happen > 1. make modules is run > - Module.symvers contains symbols from modules > 2. make Image/bzImage is run (as part of another OpenWRT make target) > - Module.symvers is rewritten to contain only vmlinux.o symbols > 3. external kernel modules try to build (wireguard, mac80211) > - this now fails because external modules may depend on symbols from > other modules and this information isn't in Module.symvers anymore > > Marek Is this a regression by a721588d9475 ? I can reproduce it even before that commit. $ git checkout a721588d^ HEAD is now at acf2a1397a68 kbuild: modpost: remove unnecessary dependency for __modpost $ make mrproper [ snip ] $ make defconfig [ snip] $ make -j24 modules [ snip ] $ cat Module.symvers 0x00000000 nf_log_dump_packet_common net/netfilter/nf_log_common EXPORT_SYMBOL_GPL 0x00000000 nf_log_l2packet net/netfilter/nf_log_common EXPORT_SYMBOL_GPL 0x00000000 nf_log_dump_sk_uid_gid net/netfilter/nf_log_common EXPORT_SYMBOL_GPL 0x00000000 nf_log_dump_tcp_header net/netfilter/nf_log_common EXPORT_SYMBOL_GPL 0x00000000 nf_log_dump_udp_header net/netfilter/nf_log_common EXPORT_SYMBOL_GPL $ make -j24 bzImage [ snip ] $ grep -v vmlinux Module.symvers [ nothing is printed. symbols from nf_log_common.ko are gone. ] I can change it, but this is a long-standing behavior, I think. -- Best Regards Masahiro Yamada
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 952fff485546..d1eb4923e21b 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -60,7 +60,12 @@ MODPOST = scripts/mod/modpost \ ifdef MODPOST_VMLINUX quiet_cmd_modpost = MODPOST vmlinux.o +ifeq ($(wildcard $(MODORDER)),) cmd_modpost = $(MODPOST) vmlinux.o +else +MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - + cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST) vmlinux.o +endif __modpost: $(call cmd,modpost)
If vmlinux.o is rebuilt after modules, the current modpost code throws away the information already stored in Module.symvers. This is due to commit mentioned in the Fixes tag, which introduced this backward-incompatible change which may break ceratin build systems (such as that of OpenWRT). Add code to look if modules.order is present when doing modpost for vmlinux.o, and if it is, include it in modpost. The change introduced here is ugly, therefore this is only a RFC patch. Please comment whether fixing this backward-incompatibility is acceptable. Fixes: a721588d9475 ("kbuild: modpost: do not parse unnecessary ...") Signed-off-by: Marek Behún <marek.behun@nic.cz> Cc: Masahiro Yamada <masahiroy@kernel.org> Cc: Michal Marek <michal.lkml@markovi.net> --- scripts/Makefile.modpost | 5 +++++ 1 file changed, 5 insertions(+)