Skip to contentSkip to conversation

kbuild: avoid scripts/kallsyms parsing /dev/null

PATCH In review Masahiro Yamada 3 participants 3 messages Aug 7, 2024 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: avoid scripts/kallsyms parsing /dev/null

On macOS, getline() sets ENOTTY to errno if it is requested to read from /dev/null.

If this is worth fixing, I would rather pass an empty file to scripts/kallsyms instead of adding the ugly #ifdef __APPLE__.

Fixes c442db3f49f2 ("kbuild: remove PROVIDE() for kallsyms symbols")

---

 scripts/link-vmlinux.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/link-vmlinux.sh +2 -1
index f7b2503cdba9..41c68ae3415d 100755
@@ -219,7 +219,8 @@ kallsymso=
 strip_debug=
 
 if is_enabled CONFIG_KALLSYMS; then
-	kallsyms /dev/null .tmp_vmlinux0.kallsyms
+	truncate -s0 .tmp_vmlinux.kallsyms0.syms
+	kallsyms .tmp_vmlinux.kallsyms0.syms .tmp_vmlinux0.kallsyms
 fi
 
 if is_enabled CONFIG_KALLSYMS || is_enabled CONFIG_DEBUG_INFO_BTF; then
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 33 lines · Masahiro Yamada

On macOS, getline() sets ENOTTY to errno if it is requested to read from /dev/null.

If this is worth fixing, I would rather pass an empty file to scripts/kallsyms instead of adding the ugly #ifdef __APPLE__.

Fixes c442db3f49f2 ("kbuild: remove PROVIDE() for kallsyms symbols")

---

 scripts/link-vmlinux.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/link-vmlinux.sh +2 -1
index f7b2503cdba9..41c68ae3415d 100755
@@ -219,7 +219,8 @@ kallsymso=
 strip_debug=
 
 if is_enabled CONFIG_KALLSYMS; then
-	kallsyms /dev/null .tmp_vmlinux0.kallsyms
+	truncate -s0 .tmp_vmlinux.kallsyms0.syms
+	kallsyms .tmp_vmlinux.kallsyms0.syms .tmp_vmlinux0.kallsyms
 fi
 
 if is_enabled CONFIG_KALLSYMS || is_enabled CONFIG_DEBUG_INFO_BTF; then
Signature · 1 line
2.43.0

Thanks! I definitely support moving special MacOS support from source code into scripts and Makefiles.

Might you want to add a comment to truncate, to prevent accidental attempts to revert/refactor this?

Kind regards,
Nicolas

Reviewed-by on v1 1/1
#2 lore raw
In reply to Masahiro Yamada
Quoted 20 lines · Masahiro Yamada

On macOS, getline() sets ENOTTY to errno if it is requested to read from /dev/null.

If this is worth fixing, I would rather pass an empty file to scripts/kallsyms instead of adding the ugly #ifdef __APPLE__.

Fixes c442db3f49f2 ("kbuild: remove PROVIDE() for kallsyms symbols")

---

 scripts/link-vmlinux.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/link-vmlinux.sh +0 -0
index f7b2503cdba9..41c68ae3415d 100755

scripts/link-vmlinux.sh kallsymso= · line 222

Quoted 5 lines
scripts/link-vmlinux.sh +1 -1
@@ -219,7 +219,8 @@ kallsymso=
 strip_debug=
 
 if is_enabled CONFIG_KALLSYMS; then
-	kallsyms /dev/null .tmp_vmlinux0.kallsyms
+	truncate -s0 .tmp_vmlinux.kallsyms0.syms

This looks nicer. Thanks for a quick alternative!

I prefer self explained commands and use the larger argument if available:

	truncate --size=0 .tmp_vmlinux.kallsyms0.syms

But other than that, LGTM.

Quoted 7 lines
scripts/link-vmlinux.sh +1 -0
+	kallsyms .tmp_vmlinux.kallsyms0.syms .tmp_vmlinux0.kallsyms
 fi
 
 if is_enabled CONFIG_KALLSYMS || is_enabled CONFIG_DEBUG_INFO_BTF; then
Signature · 1 line
2.43.0