Skip to contentSkip to conversation

kbuild: prefer ${NM} in check-function-names.sh

PATCH Applied Carlos Llamas 3 participants 3 messages Dec 18, 2025 – Jan 14 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: prefer ${NM} in check-function-names.sh

The check-function-names.sh scripts invokes 'nm' directly and this can be problematic during cross-compilation when the toolchain is different from the system's default (e.g. LLVM=1).

scripts/check-function-names.sh: nm: not found

Let's prefer the ${NM} variable which is already set by kbuild. However, still fallback to plain 'nm' to ensure the script is still usable when called directly.

Fixes 93863f3f859a ("kbuild: Check for functions with ambiguous -ffunction-sections section names")
---
 scripts/check-function-names.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/check-function-names.sh +1 -1
index 410042591cfc..08071133e5a5 100755
@@ -13,7 +13,7 @@ if [ ! -f "$objfile" ]; then
 	exit 1
 fi
 
-bad_symbols=$(nm "$objfile" | awk '$2 ~ /^[TtWw]$/ {print $3}' | grep -E '^(startup|exit|split|unlikely|hot|unknown)(\.|$)')
+bad_symbols=$(${NM:-nm} "$objfile" | awk '$2 ~ /^[TtWw]$/ {print $3}' | grep -E '^(startup|exit|split|unlikely|hot|unknown)(\.|$)')
 
 if [ -n "$bad_symbols" ]; then
 	echo "$bad_symbols" | while read -r sym; do
Signature · 1 line
2.52.0.351.gbe84eed79e-goog
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Carlos Llamas

The check-function-names.sh scripts invokes 'nm' directly and this can be problematic during cross-compilation when the toolchain is different from the system's default (e.g. LLVM=1).

scripts/check-function-names.sh: nm: not found

Let's prefer the ${NM} variable which is already set by kbuild. However, still fallback to plain 'nm' to ensure the script is still usable when called directly.

Fixes 93863f3f859a ("kbuild: Check for functions with ambiguous -ffunction-sections section names")

I may have caught this during review if linux-kbuild or its maintainers were CC'd on that change.

Quoted 1 line

If Josh or Peter want to take this through a fixes branch in -tip, that is fine with me. Otherwise, Nicolas can apply this to kbuild-fixes since this change was merged in 6.19-rc1.

Quoted 20 lines
---
 scripts/check-function-names.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/check-function-names.sh +1 -1
index 410042591cfc..08071133e5a5 100755
@@ -13,7 +13,7 @@ if [ ! -f "$objfile" ]; then
 	exit 1
 fi
 
-bad_symbols=$(nm "$objfile" | awk '$2 ~ /^[TtWw]$/ {print $3}' | grep -E '^(startup|exit|split|unlikely|hot|unknown)(\.|$)')
+bad_symbols=$(${NM:-nm} "$objfile" | awk '$2 ~ /^[TtWw]$/ {print $3}' | grep -E '^(startup|exit|split|unlikely|hot|unknown)(\.|$)')
 
 if [ -n "$bad_symbols" ]; then
 	echo "$bad_symbols" | while read -r sym; do
Signature · 1 line
2.52.0.351.gbe84eed79e-goog
maintainer Applied
#2 lore raw
In reply to Carlos Llamas
Quoted 11 lines · Carlos Llamas

The check-function-names.sh scripts invokes 'nm' directly and this can be problematic during cross-compilation when the toolchain is different from the system's default (e.g. LLVM=1).

scripts/check-function-names.sh: nm: not found

Let's prefer the ${NM} variable which is already set by kbuild. However, still fallback to plain 'nm' to ensure the script is still usable when called directly.

[...]

Applied, thanks!

[1/1] kbuild: prefer ${NM} in check-function-names.sh

      https://git.kernel.org/kbuild/c/946d4623

Best regards,

Signature · 1 line
Nicolas