kbuild: lto: remove duplicate dependencies from .mod files

With LTO, llvm-nm prints out symbols for each archive member
separately, which results in a lot of duplicate dependencies in the
.mod file when CONFIG_TRIM_UNUSED_SYMS is enabled. When a module
consists of several compilation units, the output can exceed the
default xargs command size limit and split the dependency list to
multiple lines, which results in used symbols getting trimmed.

This change removes duplicate dependencies, which will reduce the
probability of this happening and makes .mod files smaller and
easier to read.

Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: UtsavBalar1231 <utsavbalar1231@gmail.com>
This commit is contained in:
Sami Tolvanen
2020-08-28 17:16:53 +05:30
committed by UtsavBalar1231
parent 078f4fdc83
commit 11757f6885

View File

@@ -351,7 +351,7 @@ endef
# List module undefined symbols (or empty line if not enabled)
ifdef CONFIG_TRIM_UNUSED_KSYMS
cmd_undef_syms = $(NM) $@ | sed -n 's/^ \+U //p' | xargs echo
cmd_undef_syms = $(NM) $@ | sed -n 's/^ \+U //p' | sort -u | xargs echo
else
cmd_undef_syms = echo
endif