Skip to contentSkip to conversation

bpf: Use --no-fail option if CONFIG_BPF is not enabled

PATCH Superseded Jiri Olsa 3 participants 5 messages Sep 18, 2020 – Sep 22, 2020

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jiri Olsa

author reviewer
#0 lore raw

PATCH 1/2 bpf: Use --no-fail option if CONFIG_BPF is not enabled

Currently all the resolve_btfids 'users' are under CONFIG_BPF code, so if we have CONFIG_BPF disabled, resolve_btfids will fail, because there's no data to resolve.

In case CONFIG_BPF is disabled, using resolve_btfids --no-fail option, that makes resolve_btfids leave quietly if there's no data to resolve.

Fixes c9a0f3b85e09 ("bpf: Resolve BTF IDs in vmlinux image")
---
 scripts/link-vmlinux.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
scripts/link-vmlinux.sh +7 -2
index e6e2d9e5ff48..3173b8cf08cb 100755
@@ -342,8 +342,13 @@ vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o}
 
 # fill in BTF IDs
 if [ -n "${CONFIG_DEBUG_INFO_BTF}" ]; then
-info BTFIDS vmlinux
-${RESOLVE_BTFIDS} vmlinux
+	info BTFIDS vmlinux
+	# Let's be more permissive if CONFIG_BPF is disabled
+	# and do not fail if there's no data to resolve.
+	if [ -z "${CONFIG_BPF}" ]; then
+	  no_fail=--no-fail
+	fi
+	${RESOLVE_BTFIDS} $no_fail vmlinux
 fi
 
 if [ -n "${CONFIG_BUILDTIME_TABLE_SORT}" ]; then
Signature · 1 line
2.26.2
author reviewer
#1 lore raw

PATCH 2/2 tools resolve_btfids: Always force HOSTARCH

Seth reported problem with cross builds, that fail on resolve_btfids build, because we are trying to build it on cross build arch.

Fixing this by always forcing the host arch.

Fixes fbbb68de80a4 ("bpf: Add resolve_btfids tool to resolve BTF IDs in ELF object")
---
 tools/bpf/resolve_btfids/Makefile | 2 ++
 1 file changed, 2 insertions(+)
tools/bpf/resolve_btfids/Makefile +2 -0
index a88cd4426398..d3c818b8d8d3 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 include ../../scripts/Makefile.include
+include ../../scripts/Makefile.arch
 
 ifeq ($(srctree),)
 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
@@ -29,6 +30,7 @@ endif
 AR       = $(HOSTAR)
 CC       = $(HOSTCC)
 LD       = $(HOSTLD)
+ARCH     = $(HOSTARCH)
 
 OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/
 
Signature · 1 line
2.26.2
#2 lore raw
In reply to Jiri Olsa
Quoted 5 lines · Jiri Olsa

Currently all the resolve_btfids 'users' are under CONFIG_BPF code, so if we have CONFIG_BPF disabled, resolve_btfids will fail, because there's no data to resolve.

Quoted 7 lines

In case CONFIG_BPF is disabled, using resolve_btfids --no-fail option, that makes resolve_btfids leave quietly if there's no data to resolve.

Fixes c9a0f3b85e09 ("bpf: Resolve BTF IDs in vmlinux image")

---

If no CONFIG_BTF is specified, there is no need to even run resolve_btfids. So why not do just that -- run resolve_btfids only if both CONFIG_BPF and CONFIG_DEBUG_INFO_BTF are specified?

Quoted 26 lines
 scripts/link-vmlinux.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
scripts/link-vmlinux.sh +7 -3
index e6e2d9e5ff48..3173b8cf08cb 100755
@@ -342,8 +342,13 @@ vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o}
 
 # fill in BTF IDs
 if [ -n "${CONFIG_DEBUG_INFO_BTF}" ]; then
-info BTFIDS vmlinux
-${RESOLVE_BTFIDS} vmlinux
+       info BTFIDS vmlinux
+       # Let's be more permissive if CONFIG_BPF is disabled
+       # and do not fail if there's no data to resolve.
+       if [ -z "${CONFIG_BPF}" ]; then
+         no_fail=--no-fail
+       fi
+       ${RESOLVE_BTFIDS} $no_fail vmlinux
 fi
 
 if [ -n "${CONFIG_BUILDTIME_TABLE_SORT}" ]; then
--

2.26.2

#3 lore raw
Quoted 10 lines · Andrii Nakryiko
Quoted 9 lines · Jiri Olsa

Currently all the resolve_btfids 'users' are under CONFIG_BPF code, so if we have CONFIG_BPF disabled, resolve_btfids will fail, because there's no data to resolve.

In case CONFIG_BPF is disabled, using resolve_btfids --no-fail option, that makes resolve_btfids leave quietly if there's no data to resolve.

Quoted 7 lines
Quoted 3 lines
Fixes c9a0f3b85e09 ("bpf: Resolve BTF IDs in vmlinux image")

---

If no CONFIG_BTF is specified, there is no need to even run resolve_btfids. So why not do just that -- run resolve_btfids only if both CONFIG_BPF and CONFIG_DEBUG_INFO_BTF are specified?

we can have CONFIG_DEBUG_INFO_BTF without CONFIG_BPF being enabled, so we could in theory have in future some BTF ID user outside bpf code, but I guess we can enable that, when it actually happens

jirka

Quoted 29 lines
Quoted 28 lines

 scripts/link-vmlinux.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
scripts/link-vmlinux.sh +7 -3
index e6e2d9e5ff48..3173b8cf08cb 100755
@@ -342,8 +342,13 @@ vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o}
 
 # fill in BTF IDs
 if [ -n "${CONFIG_DEBUG_INFO_BTF}" ]; then
-info BTFIDS vmlinux
-${RESOLVE_BTFIDS} vmlinux
+       info BTFIDS vmlinux
+       # Let's be more permissive if CONFIG_BPF is disabled
+       # and do not fail if there's no data to resolve.
+       if [ -z "${CONFIG_BPF}" ]; then
+         no_fail=--no-fail
+       fi
+       ${RESOLVE_BTFIDS} $no_fail vmlinux
 fi
 
 if [ -n "${CONFIG_BUILDTIME_TABLE_SORT}" ]; then
--

2.26.2

#4 lore raw
Quoted 16 lines · Jiri Olsa
Quoted 14 lines · Andrii Nakryiko
Quoted 12 lines · Jiri Olsa

Currently all the resolve_btfids 'users' are under CONFIG_BPF code, so if we have CONFIG_BPF disabled, resolve_btfids will fail, because there's no data to resolve.

In case CONFIG_BPF is disabled, using resolve_btfids --no-fail option, that makes resolve_btfids leave quietly if there's no data to resolve.

Fixes c9a0f3b85e09 ("bpf: Resolve BTF IDs in vmlinux image")

---

Quoted 8 lines
Quoted 3 lines

If no CONFIG_BTF is specified, there is no need to even run resolve_btfids. So why not do just that -- run resolve_btfids only if both CONFIG_BPF and CONFIG_DEBUG_INFO_BTF are specified?

we can have CONFIG_DEBUG_INFO_BTF without CONFIG_BPF being enabled, so we could in theory have in future some BTF ID user outside bpf code, but I guess we can enable that, when it actually happens

Right. Let's cross that bridge when we get there.

Quoted 32 lines

jirka

Quoted 29 lines
Quoted 28 lines

 scripts/link-vmlinux.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
scripts/link-vmlinux.sh +7 -3
index e6e2d9e5ff48..3173b8cf08cb 100755
@@ -342,8 +342,13 @@ vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o}
 
 # fill in BTF IDs
 if [ -n "${CONFIG_DEBUG_INFO_BTF}" ]; then
-info BTFIDS vmlinux
-${RESOLVE_BTFIDS} vmlinux
+       info BTFIDS vmlinux
+       # Let's be more permissive if CONFIG_BPF is disabled
+       # and do not fail if there's no data to resolve.
+       if [ -z "${CONFIG_BPF}" ]; then
+         no_fail=--no-fail
+       fi
+       ${RESOLVE_BTFIDS} $no_fail vmlinux
 fi
 
 if [ -n "${CONFIG_BUILDTIME_TABLE_SORT}" ]; then
--

2.26.2