From: Quentin Monnet <quentin@isovalent.com>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>
Cc: "Martin KaFai Lau" <kafai@fb.com>,
"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
"John Fastabend" <john.fastabend@gmail.com>,
"KP Singh" <kpsingh@kernel.org>,
"Stanislav Fomichev" <sdf@google.com>,
"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
bpf@vger.kernel.org,
"Niklas Söderlund" <niklas.soderlund@corigine.com>,
"Simon Horman" <simon.horman@corigine.com>,
"Quentin Monnet" <quentin@isovalent.com>,
"Song Liu" <song@kernel.org>
Subject: [PATCH bpf-next v4 4/8] bpftool: Group libbfd defs in Makefile, only pass them if we use libbfd
Date: Tue, 25 Oct 2022 16:03:25 +0100 [thread overview]
Message-ID: <20221025150329.97371-5-quentin@isovalent.com> (raw)
In-Reply-To: <20221025150329.97371-1-quentin@isovalent.com>
Bpftool uses libbfd for disassembling JIT-ed programs. But the feature
is optional, and the tool can be compiled without libbfd support. The
Makefile sets the relevant variables accordingly. It also sets variables
related to libbfd's interface, given that it has changed over time.
Group all those libbfd-related definitions so that it's easier to
understand what we are testing for, and only use variables related to
libbfd's interface if we need libbfd in the first place.
In addition to make the Makefile clearer, grouping the definitions
related to disassembling JIT-ed programs will help support alternatives
to libbfd.
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Tested-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Acked-by: Song Liu <song@kernel.org>
---
tools/bpf/bpftool/Makefile | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
index 0218d6a1cae7..1c81f4d514bb 100644
--- a/tools/bpf/bpftool/Makefile
+++ b/tools/bpf/bpftool/Makefile
@@ -124,13 +124,6 @@ include $(FEATURES_DUMP)
endif
endif
-ifeq ($(feature-disassembler-four-args), 1)
-CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
-endif
-ifeq ($(feature-disassembler-init-styled), 1)
- CFLAGS += -DDISASM_INIT_STYLED
-endif
-
LIBS = $(LIBBPF) -lelf -lz
LIBS_BOOTSTRAP = $(LIBBPF_BOOTSTRAP) -lelf -lz
ifeq ($(feature-libcap), 1)
@@ -142,9 +135,7 @@ include $(wildcard $(OUTPUT)*.d)
all: $(OUTPUT)bpftool
-BFD_SRCS = jit_disasm.c
-
-SRCS = $(filter-out $(BFD_SRCS),$(wildcard *.c))
+SRCS := $(wildcard *.c)
ifeq ($(feature-libbfd),1)
LIBS += -lbfd -ldl -lopcodes
@@ -154,9 +145,21 @@ else ifeq ($(feature-libbfd-liberty-z),1)
LIBS += -lbfd -ldl -lopcodes -liberty -lz
endif
+# If one of the above feature combinations is set, we support libbfd
ifneq ($(filter -lbfd,$(LIBS)),)
-CFLAGS += -DHAVE_LIBBFD_SUPPORT
-SRCS += $(BFD_SRCS)
+ CFLAGS += -DHAVE_LIBBFD_SUPPORT
+
+ # Libbfd interface changed over time, figure out what we need
+ ifeq ($(feature-disassembler-four-args), 1)
+ CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
+ endif
+ ifeq ($(feature-disassembler-init-styled), 1)
+ CFLAGS += -DDISASM_INIT_STYLED
+ endif
+endif
+ifeq ($(filter -DHAVE_LIBBFD_SUPPORT,$(CFLAGS)),)
+ # No support for JIT disassembly
+ SRCS := $(filter-out jit_disasm.c,$(SRCS))
endif
HOST_CFLAGS = $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE),\
--
2.34.1
next prev parent reply other threads:[~2022-10-25 15:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 15:03 [PATCH bpf-next v4 0/8] bpftool: Add LLVM as default library for disassembling JIT-ed programs Quentin Monnet
2022-10-25 15:03 ` [PATCH bpf-next v4 1/8] bpftool: Define _GNU_SOURCE only once Quentin Monnet
2022-10-25 15:03 ` [PATCH bpf-next v4 2/8] bpftool: Remove asserts from JIT disassembler Quentin Monnet
2022-10-25 15:03 ` [PATCH bpf-next v4 3/8] bpftool: Split FEATURE_TESTS/FEATURE_DISPLAY definitions in Makefile Quentin Monnet
2022-10-25 15:03 ` Quentin Monnet [this message]
2022-10-25 15:03 ` [PATCH bpf-next v4 5/8] bpftool: Refactor disassembler for JIT-ed programs Quentin Monnet
2022-10-25 15:03 ` [PATCH bpf-next v4 6/8] bpftool: Add LLVM as default library for disassembling " Quentin Monnet
2022-10-25 15:03 ` [PATCH bpf-next v4 7/8] bpftool: Support setting alternative arch for JIT disasm with LLVM Quentin Monnet
2022-10-25 15:03 ` [PATCH bpf-next v4 8/8] bpftool: Add llvm feature to "bpftool version" Quentin Monnet
2022-10-25 17:20 ` [PATCH bpf-next v4 0/8] bpftool: Add LLVM as default library for disassembling JIT-ed programs patchwork-bot+netdevbpf
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=20221025150329.97371-5-quentin@isovalent.com \
--to=quentin@isovalent.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=niklas.soderlund@corigine.com \
--cc=sdf@google.com \
--cc=simon.horman@corigine.com \
--cc=song@kernel.org \
--cc=songliubraving@fb.com \
--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