tools/bpf: properly account for libbfd variations
Subsystems (4)
PATCH 1/1 tools/bpf: properly account for libbfd variations
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.
--- tools/bpf/bpftool/Makefile | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
tools/bpf/bpftool/Makefile +13 -2
@@ -92,10 +92,21 @@ BFD_SRCS = jit_disasm.c SRCS = $(filter-out $(BFD_SRCS),$(wildcard *.c)) -ifeq ($(feature-libbfd),1) +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 + endif +endif + +ifneq ($(filter -lbfd,$(EXTLIBS)),) CFLAGS += -DHAVE_LIBBFD_SUPPORT SRCS += $(BFD_SRCS) -LIBS += -lbfd -lopcodes endif OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
Signature · 1 line
2.20.1.97.g81188d93c3-goog
Quoted 11 lines · Stanislav Fomichev
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.Fixes 29a9c10e4110 ("bpftool: make libbfd optional")Signed-off-by Stanislav Fomichev <[email protected]>
Minor nits below, in any case:
Thanks for making bpftool build! :)
tools/bpf/bpftool/Makefile BFD_SRCS = jit_disasm.c · line 95
Quoted 10 lines
tools/bpf/bpftool/Makefile +1
-1@@ -92,10 +92,21 @@ BFD_SRCS = jit_disasm.c SRCS = $(filter-out $(BFD_SRCS),$(wildcard *.c)) -ifeq ($(feature-libbfd),1) +ifeq ($(feature-libbfd), 1)
nit: no space there is more common
$ git grep 'ifeq' | grep ',[^ ]' | wc -l 482 $ git grep 'ifeq' | grep ', ' | wc -l 136
tools/bpf/bpftool/Makefile BFD_SRCS = jit_disasm.c · line 96
Quoted 1 line
tools/bpf/bpftool/Makefile +1
-0+LIBS += -lbfd -ldl -lopcodes
nit: should this be indented?
tools/bpf/bpftool/Makefile BFD_SRCS = jit_disasm.c · line 103
Quoted 7 lines
tools/bpf/bpftool/Makefile +7
-0+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
Would this syntax:
ifeq ($(feature-libbfd),1)
LIBS += ..
else ifeq ($(feature-libbfd-liberty),1)
LIBS += ..
else ifeq ($(feature-libbfd-liberty-z),1)
LIBS += ..
endif
Not work?
https://www.gnu.org/software/make/manual/html_node/Conditional-Syntax.html
I don't think I've ever tried, but looks more concise..
Quoted 10 lines
tools/bpf/bpftool/Makefile +4
-1+ endif +endif + +ifneq ($(filter -lbfd,$(EXTLIBS)),) CFLAGS += -DHAVE_LIBBFD_SUPPORT SRCS += $(BFD_SRCS) -LIBS += -lbfd -lopcodes endif OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
Quoted 60 lines · Jakub Kicinski
Quoted 11 lines · Stanislav Fomichev
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.Fixes 29a9c10e4110 ("bpftool: make libbfd optional")Signed-off-by Stanislav Fomichev <[email protected]>Minor nits below, in any case:
Acked-by Jakub Kicinski <[email protected]>Thanks for making bpftool build! :)
tools/bpf/bpftool/Makefile BFD_SRCS = jit_disasm.c · line 95
Quoted 10 lines
tools/bpf/bpftool/Makefile +1
-1@@ -92,10 +92,21 @@ BFD_SRCS = jit_disasm.c SRCS = $(filter-out $(BFD_SRCS),$(wildcard *.c)) -ifeq ($(feature-libbfd),1) +ifeq ($(feature-libbfd), 1)nit: no space there is more common
$ git grep 'ifeq' | grep ',[^ ]' | wc -l 482 $ git grep 'ifeq' | grep ', ' | wc -l 136tools/bpf/bpftool/Makefile BFD_SRCS = jit_disasm.c · line 96
Quoted 1 line
tools/bpf/bpftool/Makefile +1
-0+LIBS += -lbfd -ldl -lopcodesnit: should this be indented?
tools/bpf/bpftool/Makefile BFD_SRCS = jit_disasm.c · line 103
Quoted 7 lines
tools/bpf/bpftool/Makefile +7
-0+else + ifeq ($(feature-libbfd-liberty), 1) + LIBS += -lbfd -ldl -lopcodes -liberty + else + ifeq ($(feature-libbfd-liberty-z), 1) + LIBS += -lbfd -ldl -lopcodes -liberty -lz + endifWould this syntax:
ifeq ($(feature-libbfd),1)
LIBS += ..
else ifeq ($(feature-libbfd-liberty),1)
LIBS += ..
else ifeq ($(feature-libbfd-liberty-z),1)
LIBS += ..
endif
Quoted 1 line
Not work?
I does seem to work :-) This is the first time I see it being written that way. (but your link indeed shows that this syntax is supported)
I'll post v2 shortly with all the nits addressed. Thanks for a quick review!
Quoted 16 lines
https://www.gnu.org/software/make/manual/html_node/Conditional-Syntax.html
I don't think I've ever tried, but looks more concise..
Quoted 10 lines
tools/bpf/bpftool/Makefile +4
-1+ endif +endif + +ifneq ($(filter -lbfd,$(EXTLIBS)),) CFLAGS += -DHAVE_LIBBFD_SUPPORT SRCS += $(BFD_SRCS) -LIBS += -lbfd -lopcodes endif OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
PATCH v2 1/1 tools/bpf: properly account for libbfd variations
In reply to Jakub KicinskiOn 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
--- tools/bpf/bpftool/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/bpf/bpftool/Makefile +8 -1
@@ -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,$(EXTLIBS)),) CFLAGS += -DHAVE_LIBBFD_SUPPORT SRCS += $(BFD_SRCS) -LIBS += -lbfd -lopcodes endif OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
Signature · 1 line
2.20.1.97.g81188d93c3-goog
Quoted 25 lines · Stanislav Fomichev
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 argsFixes 29a9c10e4110 ("bpftool: make libbfd optional")Signed-off-by Stanislav Fomichev <[email protected]>--- tools/bpf/bpftool/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)tools/bpf/bpftool/Makefile +0
-0@@ -93,9 +93,16 @@ BFD_SRCS = jit_disasm.c SRCS = $(filter-out $(BFD_SRCS),$(wildcard *.c))
tools/bpf/bpftool/Makefile BFD_SRCS = jit_disasm.c · line 103
Quoted 10 lines
tools/bpf/bpftool/Makefile +8
-0ifeq ($(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,$(EXTLIBS)),)
Ah, I just noticed now that you use EXTLIBS here, not LIBS, is that on purpose?
Quoted 6 lines
tools/bpf/bpftool/Makefile +0
-1CFLAGS += -DHAVE_LIBBFD_SUPPORT SRCS += $(BFD_SRCS) -LIBS += -lbfd -lopcodes endif OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
Quoted 27 lines · Jakub Kicinski
Quoted 26 lines · Stanislav Fomichev
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 argsFixes 29a9c10e4110 ("bpftool: make libbfd optional")Signed-off-by Stanislav Fomichev <[email protected]>--- tools/bpf/bpftool/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)tools/bpf/bpftool/Makefile +0
-0@@ -93,9 +93,16 @@ BFD_SRCS = jit_disasm.c SRCS = $(filter-out $(BFD_SRCS),$(wildcard *.c))
Quoted 12 lines
tools/bpf/bpftool/Makefile BFD_SRCS = jit_disasm.c · line 103
Quoted 9 lines
tools/bpf/bpftool/Makefile +8
-0ifeq ($(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,$(EXTLIBS)),)Ah, I just noticed now that you use EXTLIBS here, not LIBS, is that on purpose?
Nice catch! Should be LIBS, probably copy-pasted it from somewhere :-(
Quoted 8 lines
Quoted 7 lines
tools/bpf/bpftool/Makefile +0
-1CFLAGS += -DHAVE_LIBBFD_SUPPORT SRCS += $(BFD_SRCS) -LIBS += -lbfd -lopcodes endif OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
PATCH v3 1/1 tools/bpf: properly account for libbfd variations
In reply to Jakub KicinskiOn 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
--- tools/bpf/bpftool/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/bpf/bpftool/Makefile +8 -1
@@ -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
Signature · 1 line
2.20.1.97.g81188d93c3-goog
Quoted 9 lines · Stanislav Fomichev
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.
Quoted 8 lines
v2 (addressed Jakub's nits):
* better syntax for 'else ifeq'
* no space between ifeq args
v3:
* use LIBS, not EXTLIBS for -DHAVE_LIBBFD_SUPPORTFixes 29a9c10e4110 ("bpftool: make libbfd optional")Signed-off-by Stanislav Fomichev <[email protected]>
Thanks!!
Quoted 9 lines · Stanislav Fomichev
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.
Quoted 8 lines
v2 (addressed Jakub's nits):
* better syntax for 'else ifeq'
* no space between ifeq args
v3:
* use LIBS, not EXTLIBS for -DHAVE_LIBBFD_SUPPORTFixes 29a9c10e4110 ("bpftool: make libbfd optional")Signed-off-by Stanislav Fomichev <[email protected]>
Applied, thanks!