From: Martin KaFai Lau <kafai@fb.com>
To: <netdev@vger.kernel.org>
Cc: Alexei Starovoitov <ast@fb.com>,
Daniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>,
Yonghong Song <yhs@fb.com>
Subject: [PATCH v5 bpf-next 10/13] tools/bpf: do not use pahole if clang/llvm can generate BTF sections
Date: Mon, 19 Nov 2018 15:29:17 -0800 [thread overview]
Message-ID: <20181119232917.145817-1-kafai@fb.com> (raw)
In-Reply-To: <20181119232906.144809-1-kafai@fb.com>
From: Yonghong Song <yhs@fb.com>
Add additional checks in tools/testing/selftests/bpf and
samples/bpf such that if clang/llvm compiler can generate
BTF sections, do not use pahole.
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
---
samples/bpf/Makefile | 8 ++++++++
tools/testing/selftests/bpf/Makefile | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index be0a961450bc..35444f4a846b 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -208,12 +208,20 @@ endif
BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
+BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \
+ $(CLANG) -target bpf -O2 -g -c -x c - -o ./llvm_btf_verify.o; \
+ readelf -S ./llvm_btf_verify.o | grep BTF; \
+ /bin/rm -f ./llvm_btf_verify.o)
+ifneq ($(BTF_LLVM_PROBE),)
+ EXTRA_CFLAGS += -g
+else
ifneq ($(and $(BTF_LLC_PROBE),$(BTF_PAHOLE_PROBE),$(BTF_OBJCOPY_PROBE)),)
EXTRA_CFLAGS += -g
LLC_FLAGS += -mattr=dwarfris
DWARF2BTF = y
endif
+endif
# Trick to allow make to be run from this directory
all:
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 57b4712a6276..1dde03ea1484 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -126,7 +126,14 @@ $(OUTPUT)/test_stack_map.o: test_queue_stack_map.h
BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
+BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \
+ $(CLANG) -target bpf -O2 -g -c -x c - -o ./llvm_btf_verify.o; \
+ readelf -S ./llvm_btf_verify.o | grep BTF; \
+ /bin/rm -f ./llvm_btf_verify.o)
+ifneq ($(BTF_LLVM_PROBE),)
+ CLANG_FLAGS += -g
+else
ifneq ($(BTF_LLC_PROBE),)
ifneq ($(BTF_PAHOLE_PROBE),)
ifneq ($(BTF_OBJCOPY_PROBE),)
@@ -136,6 +143,7 @@ ifneq ($(BTF_OBJCOPY_PROBE),)
endif
endif
endif
+endif
# Have one program compiled without "-target bpf" to test whether libbpf loads
# it successfully
--
2.17.1
next prev parent reply other threads:[~2018-11-20 9:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-19 23:29 [PATCH v5 bpf-next 00/13] bpf: Add btf func info support Martin KaFai Lau
2018-11-19 23:29 ` [PATCH v5 bpf-next 01/13] bpf: btf: Break up btf_type_is_void() Martin KaFai Lau
2018-11-19 23:29 ` [PATCH v5 bpf-next 02/13] bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO Martin KaFai Lau
2018-11-19 23:29 ` [PATCH v5 bpf-next 03/13] tools/bpf: Sync kernel btf.h header Martin KaFai Lau
2018-11-19 23:29 ` [PATCH v5 bpf-next 04/13] tools/bpf: Add tests for BTF_KIND_FUNC_PROTO and BTF_KIND_FUNC Martin KaFai Lau
2018-11-19 23:29 ` [PATCH v5 bpf-next 05/13] bpf: Introduce bpf_func_info Martin KaFai Lau
2018-11-20 20:41 ` kbuild test robot
2018-11-19 23:29 ` [PATCH v5 bpf-next 06/13] tools/bpf: sync kernel uapi bpf.h header to tools directory Martin KaFai Lau
2018-11-19 23:29 ` [PATCH v5 bpf-next 07/13] tools/bpf: add new fields for program load in lib/bpf Martin KaFai Lau
2018-11-19 23:29 ` [PATCH v5 bpf-next 08/13] tools/bpf: extends test_btf to test load/retrieve func_type info Martin KaFai Lau
2018-11-19 23:29 ` [PATCH v5 bpf-next 09/13] tools/bpf: add support to read .BTF.ext sections Martin KaFai Lau
2018-11-19 23:29 ` Martin KaFai Lau [this message]
2018-11-19 23:29 ` [PATCH v5 bpf-next 11/13] tools/bpf: refactor to implement btf_get_from_id() in lib/bpf Martin KaFai Lau
2018-11-19 23:29 ` [PATCH v5 bpf-next 12/13] tools/bpf: enhance test_btf file testing to test func info Martin KaFai Lau
2018-11-19 23:29 ` [PATCH v5 bpf-next 13/13] tools/bpf: bpftool: add support for func types Martin KaFai Lau
2018-11-20 11:26 ` [PATCH v5 bpf-next 00/13] bpf: Add btf func info support Edward Cree
2018-11-20 19:01 ` Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181119232917.145817-1-kafai@fb.com \
--to=kafai@fb.com \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox