diff mbox series

[bpf,v3] tools/bpf: properly account for libbfd variations

Message ID 20190115220327.171608-1-sdf@google.com
State Accepted
Delegated to: BPF Maintainers
Headers show
Series [bpf,v3] tools/bpf: properly account for libbfd variations | expand

Commit Message

Stanislav Fomichev Jan. 15, 2019, 10:03 p.m. UTC
On some platforms, in order to link against libbfd, we need to
link against liberty and even possibly libz. Account for that
in the bpftool Makefile. We now have proper feature detection
for each case, so handle each one separately.

See recent commit 14541b1e7e72 ("perf build: Don't unconditionally link the
libbfd feature test to -liberty and -lz") where I fixed feature
detection.

v2 (addressed Jakub's nits):
  * better syntax for 'else ifeq'
  * no space between ifeq args
v3:
  * use LIBS, not EXTLIBS for -DHAVE_LIBBFD_SUPPORT

Fixes: 29a9c10e4110 ("bpftool: make libbfd optional")
Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
 tools/bpf/bpftool/Makefile | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Jakub Kicinski Jan. 15, 2019, 10:06 p.m. UTC | #1
On Tue, 15 Jan 2019 14:03:27 -0800, Stanislav Fomichev wrote:
> On some platforms, in order to link against libbfd, we need to
> link against liberty and even possibly libz. Account for that
> in the bpftool Makefile. We now have proper feature detection
> for each case, so handle each one separately.
> 
> See recent commit 14541b1e7e72 ("perf build: Don't unconditionally link the
> libbfd feature test to -liberty and -lz") where I fixed feature
> detection.
> 
> v2 (addressed Jakub's nits):
>   * better syntax for 'else ifeq'
>   * no space between ifeq args
> v3:
>   * use LIBS, not EXTLIBS for -DHAVE_LIBBFD_SUPPORT
> 
> Fixes: 29a9c10e4110 ("bpftool: make libbfd optional")
> Signed-off-by: Stanislav Fomichev <sdf@google.com>

Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>

Thanks!!
Daniel Borkmann Jan. 15, 2019, 11:55 p.m. UTC | #2
On 01/15/2019 11:03 PM, Stanislav Fomichev wrote:
> On some platforms, in order to link against libbfd, we need to
> link against liberty and even possibly libz. Account for that
> in the bpftool Makefile. We now have proper feature detection
> for each case, so handle each one separately.
> 
> See recent commit 14541b1e7e72 ("perf build: Don't unconditionally link the
> libbfd feature test to -liberty and -lz") where I fixed feature
> detection.
> 
> v2 (addressed Jakub's nits):
>   * better syntax for 'else ifeq'
>   * no space between ifeq args
> v3:
>   * use LIBS, not EXTLIBS for -DHAVE_LIBBFD_SUPPORT
> 
> Fixes: 29a9c10e4110 ("bpftool: make libbfd optional")
> Signed-off-by: Stanislav Fomichev <sdf@google.com>

Applied, thanks!
diff mbox series

Patch

diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
index 492f0f24e2d3..4ad1f0894d53 100644
--- a/tools/bpf/bpftool/Makefile
+++ b/tools/bpf/bpftool/Makefile
@@ -93,9 +93,16 @@  BFD_SRCS = jit_disasm.c
 SRCS = $(filter-out $(BFD_SRCS),$(wildcard *.c))
 
 ifeq ($(feature-libbfd),1)
+  LIBS += -lbfd -ldl -lopcodes
+else ifeq ($(feature-libbfd-liberty),1)
+  LIBS += -lbfd -ldl -lopcodes -liberty
+else ifeq ($(feature-libbfd-liberty-z),1)
+  LIBS += -lbfd -ldl -lopcodes -liberty -lz
+endif
+
+ifneq ($(filter -lbfd,$(LIBS)),)
 CFLAGS += -DHAVE_LIBBFD_SUPPORT
 SRCS += $(BFD_SRCS)
-LIBS += -lbfd -lopcodes
 endif
 
 OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o