Skip to content

Commit 1d11053

Browse files
Lecopzer Chenmasahir0y
authored andcommitted
Kbuild: lto: fix module versionings mismatch in GNU make 3.X
When building modules(CONFIG_...=m), I found some of module versions are incorrect and set to 0. This can be found in build log for first clean build which shows WARNING: EXPORT symbol "XXXX" [drivers/XXX/XXX.ko] version generation failed, symbol will not be versioned. But in second build(incremental build), the WARNING disappeared and the module version becomes valid CRC and make someone who want to change modules without updating kernel image can't insert their modules. The problematic code is + $(foreach n, $(filter-out FORCE,$^), \ + $(if $(wildcard $(n).symversions), \ + ; cat $(n).symversions >> [email protected])) For example: rm -f fs/notify/built-in.a.symversions ; rm -f fs/notify/built-in.a; \ llvm-ar cDPrST fs/notify/built-in.a fs/notify/fsnotify.o \ fs/notify/notification.o fs/notify/group.o ... `foreach n` shows nothing to `cat` into $(n).symversions because `if $(wildcard $(n).symversions)` return nothing, but actually they do exist during this line was executed. -rw-r--r-- 1 root root 168580 Jun 13 19:10 fs/notify/fsnotify.o -rw-r--r-- 1 root root 111 Jun 13 19:10 fs/notify/fsnotify.o.symversions The reason is the $(n).symversions are generated at runtime, but Makefile wildcard function expends and checks the file exist or not during parsing the Makefile. Thus fix this by use `test` shell command to check the file existence in runtime. Rebase from both: 1. [https://lore.kernel.org/lkml/[email protected]/] 2. [https://lore.kernel.org/lkml/[email protected]/] Fixes: 38e8918 ("kbuild: lto: fix module versioning") Co-developed-by: Sami Tolvanen <[email protected]> Signed-off-by: Lecopzer Chen <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent d952cfa commit 1d11053

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/Makefile.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ ifeq ($(CONFIG_LTO_CLANG) $(CONFIG_MODVERSIONS),y y)
386386
cmd_update_lto_symversions = \
387387
388388
$(foreach n, $(filter-out FORCE,$^), \
389-
$(if $(wildcard $(n).symversions), \
389+
$(if $(shell test -s $(n).symversions && echo y), \
390390
; cat $(n).symversions >> [email protected]))
391391
else
392392
cmd_update_lto_symversions = echo >/dev/null

0 commit comments

Comments
 (0)