Skip to contentSkip to conversation

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

PATCH Superseded Masahiro Yamada 4 participants 6 messages Aug 14, 2021 – Aug 18, 2021 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

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

---

 scripts/gen_ksymdeps.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/gen_ksymdeps.sh +4 -1
index 1324986e1362..5493124e8ee6 100755
@@ -4,7 +4,10 @@
 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 stdout.
+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
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Masahiro Yamada

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.

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

---

  scripts/gen_ksymdeps.sh | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
scripts/gen_ksymdeps.sh +4 -1
index 1324986e1362..5493124e8ee6 100755
@@ -4,7 +4,10 @@
  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 stdout.
+ksyms=$($NM $1 2>/dev/null | sed -n 's/.*__ksym_marker_\(.*\)/\1/p' | tr A-Z a-z)
 
  if [ -z "$ksyms" ]; then
  	exit 0
#2 lore raw
Quoted 11 lines · Nathan Chancellor
Quoted 9 lines · Masahiro Yamada

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.

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

LGTM.

FWIW binutils>=2.37 nm -q can be used to suppress "no symbols"
https://sourceware.org/bugzilla/show_bug.cgi?id=27408

llvm-nm>=13.0.0 supports -q as well.

Quoted 29 lines
Quoted 12 lines

---

  scripts/gen_ksymdeps.sh | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
scripts/gen_ksymdeps.sh +0 -0
index 1324986e1362..5493124e8ee6 100755
@@ -4,7 +4,10 @@
  set -e

scripts/gen_ksymdeps.sh line 13

Quoted 10 lines
scripts/gen_ksymdeps.sh +4 -1
 
  # 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 stdout.
+ksyms=$($NM $1 2>/dev/null | sed -n 's/.*__ksym_marker_\(.*\)/\1/p' | tr A-Z a-z)
 
  if [ -z "$ksyms" ]; then
      exit 0

--
You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/3afe5054-8129-fe42-b5a4-00bd091b1a0c%40kernel.org.

Signature · 1 line
宋方睿
#3 lore raw
Quoted 14 lines · Fāng-ruì Sòng
Quoted 11 lines · Nathan Chancellor
Quoted 9 lines · Masahiro Yamada

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.

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

LGTM.

FWIW binutils>=2.37 nm -q can be used to suppress "no symbols"
https://sourceware.org/bugzilla/show_bug.cgi?id=27408

llvm-nm>=13.0.0 supports -q as well.

Thanks for the info.
Perhaps, I can note the future migration to -q
in a comment.

Signature · 2 lines
Best Regards
Masahiro Yamada
#4 lore raw
In reply to Masahiro Yamada
Quoted 19 lines · Masahiro Yamada

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.

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

---

 scripts/gen_ksymdeps.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/gen_ksymdeps.sh +0 -0
index 1324986e1362..5493124e8ee6 100755

scripts/gen_ksymdeps.sh line 10

Quoted 8 lines
scripts/gen_ksymdeps.sh +4 -1
@@ -4,7 +4,10 @@
 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 stdout.
+ksyms=$($NM $1 2>/dev/null | sed -n 's/.*__ksym_marker_\(.*\)/\1/p' | tr A-Z a-z)

You mean stderr.

Nicolas

#5 lore raw
Quoted 24 lines · Nicolas Pitre
Quoted 21 lines · Masahiro Yamada

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.

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

---

 scripts/gen_ksymdeps.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/gen_ksymdeps.sh +0 -0
index 1324986e1362..5493124e8ee6 100755
@@ -4,7 +4,10 @@
 set -e
 
Quoted 8 lines

scripts/gen_ksymdeps.sh line 10

Quoted 6 lines
scripts/gen_ksymdeps.sh +4 -1
 # 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 stdout.
+ksyms=$($NM $1 2>/dev/null | sed -n 's/.*__ksym_marker_\(.*\)/\1/p' | tr A-Z a-z)

You mean stderr.

My bad - I will fix it in v2.
Thanks.

Signature · 2 lines
Best Regards
Masahiro Yamada