Skip to contentSkip to conversation

bpf: btf: Always output invariant hit in pahole DWARF to BTF transform

PATCH Superseded Chris Down 2 participants 5 messages Jan 21, 2020

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chris Down

author
#0 lore raw

PATCH 1/1 bpf: btf: Always output invariant hit in pahole DWARF to BTF transform

When trying to compile with CONFIG_DEBUG_INFO_BTF enabled, I got this error:

% make -s
Failed to generate BTF for vmlinux
Try to disable CONFIG_DEBUG_INFO_BTF
make[3]: *** [vmlinux] Error 1

Compiling again without -s shows the true error (that pahole is missing), but since this is fatal, we should show the error unconditionally on stderr as well, not silence it using the info function. With this patch:

% make -s
BTF: .tmp_vmlinux.btf: pahole (pahole) is not available Failed to generate BTF for vmlinux
Try to disable CONFIG_DEBUG_INFO_BTF
make[3]: *** [vmlinux] Error 1

---
 scripts/link-vmlinux.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/link-vmlinux.sh +4 -2
index c287ad9b3a67..c8e9f49903a0 100755
@@ -108,13 +108,15 @@ gen_btf()
 	local bin_arch
 
 	if ! [ -x "$(command -v ${PAHOLE})" ]; then
-		info "BTF" "${1}: pahole (${PAHOLE}) is not available"
+		printf 'BTF: %s: pahole (%s) is not available\n' \
+			"${1}" "${PAHOLE}" >&2
 		return 1
 	fi
 
 	pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/')
 	if [ "${pahole_ver}" -lt "113" ]; then
-		info "BTF" "${1}: pahole version $(${PAHOLE} --version) is too old, need at least v1.13"
+		printf 'BTF: %s: pahole version %s is too old, need at least v1.13\n' \
+			"${1}" "$(${PAHOLE} --version)" >&2
 		return 1
 	fi
 
Signature · 1 line
2.25.0
#1 lore raw
Quoted 37 lines · Chris Down

When trying to compile with CONFIG_DEBUG_INFO_BTF enabled, I got this error:

% make -s
Failed to generate BTF for vmlinux
Try to disable CONFIG_DEBUG_INFO_BTF
make[3]: *** [vmlinux] Error 1

Compiling again without -s shows the true error (that pahole is missing), but since this is fatal, we should show the error unconditionally on stderr as well, not silence it using the info function. With this patch:

% make -s
BTF: .tmp_vmlinux.btf: pahole (pahole) is not available Failed to generate BTF for vmlinux
Try to disable CONFIG_DEBUG_INFO_BTF
make[3]: *** [vmlinux] Error 1

---
 scripts/link-vmlinux.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/link-vmlinux.sh +0 -0
index c287ad9b3a67..c8e9f49903a0 100755

scripts/link-vmlinux.sh gen_btf() · line 112

Quoted 6 lines
scripts/link-vmlinux.sh +2 -1
@@ -108,13 +108,15 @@ gen_btf()
        local bin_arch
 
        if ! [ -x "$(command -v ${PAHOLE})" ]; then
-               info "BTF" "${1}: pahole (${PAHOLE}) is not available"
+               printf 'BTF: %s: pahole (%s) is not available\n' \
+                       "${1}" "${PAHOLE}" >&2

any reason not to use echo instead of printf? would be more minimal change

Quoted 14 lines
scripts/link-vmlinux.sh +2 -2
                return 1
        fi
 
        pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/')
        if [ "${pahole_ver}" -lt "113" ]; then
-               info "BTF" "${1}: pahole version $(${PAHOLE} --version) is too old, need at least v1.13"
+               printf 'BTF: %s: pahole version %s is too old, need at least v1.13\n' \
+                       "${1}" "$(${PAHOLE} --version)" >&2
                return 1
        fi
 
--

2.25.0

author
#2 lore raw
Quoted 11 lines · Andrii Nakryiko

scripts/link-vmlinux.sh gen_btf() · line 112

Quoted 9 lines
scripts/link-vmlinux.sh +2 -1
@@ -108,13 +108,15 @@ gen_btf()
        local bin_arch
 
        if ! [ -x "$(command -v ${PAHOLE})" ]; then
-               info "BTF" "${1}: pahole (${PAHOLE}) is not available"
+               printf 'BTF: %s: pahole (%s) is not available\n' \
+                       "${1}" "${PAHOLE}" >&2

any reason not to use echo instead of printf? would be more minimal change

I generally avoid using echo because it has a bunch of portability gotchas which printf mostly doesn't have. If you'd prefer echo, that's fine though, just let me know and I can send v2.

#3 lore raw
Quoted 14 lines · Chris Down
Quoted 11 lines · Andrii Nakryiko

scripts/link-vmlinux.sh gen_btf() · line 112

Quoted 9 lines
scripts/link-vmlinux.sh +2 -1
@@ -108,13 +108,15 @@ gen_btf()
        local bin_arch
 
        if ! [ -x "$(command -v ${PAHOLE})" ]; then
-               info "BTF" "${1}: pahole (${PAHOLE}) is not available"
+               printf 'BTF: %s: pahole (%s) is not available\n' \
+                       "${1}" "${PAHOLE}" >&2

any reason not to use echo instead of printf? would be more minimal change

Quoted 3 lines

I generally avoid using echo because it has a bunch of portability gotchas which printf mostly doesn't have. If you'd prefer echo, that's fine though, just let me know and I can send v2.

The rest of the script is using echo for errors, so let's stick to it for consistency. Thanks!

author
#4 lore raw
Quoted 15 lines · Andrii Nakryiko
Quoted 14 lines · Chris Down
Quoted 11 lines · Andrii Nakryiko

scripts/link-vmlinux.sh gen_btf() · line 112

Quoted 9 lines
scripts/link-vmlinux.sh +2 -1
@@ -108,13 +108,15 @@ gen_btf()
        local bin_arch
 
        if ! [ -x "$(command -v ${PAHOLE})" ]; then
-               info "BTF" "${1}: pahole (${PAHOLE}) is not available"
+               printf 'BTF: %s: pahole (%s) is not available\n' \
+                       "${1}" "${PAHOLE}" >&2

any reason not to use echo instead of printf? would be more minimal change

Quoted 6 lines
Quoted 3 lines

I generally avoid using echo because it has a bunch of portability gotchas which printf mostly doesn't have. If you'd prefer echo, that's fine though, just let me know and I can send v2.

The rest of the script is using echo for errors, so let's stick to it for consistency. Thanks!

Sure thing, I'll send v2. Thanks! :-)