Skip to contentSkip to conversation

kbuild: Fix 'no symbols' warning when CONFIG_TRIM_UNUSD_KSYMS=y

PATCH New Masahiro Yamada 1 participant 1 message Aug 19, 2021 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kbuild: Fix 'no symbols' warning when CONFIG_TRIM_UNUSD_KSYMS=y

When CONFIG_TRIM_UNUSED_KSYMS is enabled, I see some warnings like this:

nm: arch/x86/entry/vdso/vdso32/note.o: no symbols

$NM (both GNU nm and llvm-nm) warns when no symbol is found in the object. Suppress the stderr.

Fangrui Song mentioned binutils>=2.37 nm -q can be used to suppress "no symbols" [1], and llvm-nm>=13.0.0 supports -q as well.

We cannot use it for now, but note it as a TODO.

[1]: https://sourceware.org/bugzilla/show_bug.cgi?id=27408

Fixes bbda5ec671d3 ("kbuild: simplify dependency generation for CONFIG_TRIM_UNUSED_KSYMS")

---

Changes in v2:
- Add TODO
- Fix 'stdout' to 'stderr' in the comment

 scripts/gen_ksymdeps.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
scripts/gen_ksymdeps.sh +7 -1
index 1324986e1362..725e8c9c1b53 100755
@@ -4,7 +4,13 @@
 set -e
 
 # List of exported symbols
-ksyms=$($NM $1 | sed -n 's/.*__ksym_marker_\(.*\)/\1/p' | tr A-Z a-z)
+#
+# If the object has no symbol, $NM warns 'no symbols'.
+# Suppress the stderr.
+# TODO:
+#   Use -q instead of 2>/dev/null when we upgrade the minimum version of
+#   binutils to 2.37, llvm to 13.0.0.
+ksyms=$($NM $1 2>/dev/null | sed -n 's/.*__ksym_marker_\(.*\)/\1/p' | tr A-Z a-z)
 
 if [ -z "$ksyms" ]; then
 	exit 0
Signature · 1 line
2.30.2