Skip to contentSkip to conversation

libbpf: add zlib as a dependency in pkg-config template

PATCH Applied Andrii Nakryiko 3 participants 3 messages Dec 16, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libbpf: add zlib as a dependency in pkg-config template

List zlib as another dependency of libbpf in pkg-config template. Verified it is correctly resolved to proper -lz flag:

$ make DESTDIR=/tmp/libbpf-install install
$ pkg-config --libs /tmp/libbpf-install/usr/local/lib64/pkgconfig/libbpf.pc
-L/usr/local/lib64 -lbpf
$ pkg-config --libs --static /tmp/libbpf-install/usr/local/lib64/pkgconfig/libbpf.pc
-L/usr/local/lib64 -lbpf -lelf -lz
Fixes 166750bc1dd2 ("libbpf: Support libbpf-provided extern variables")
Cc Luca Boccassi <[email protected]>
---
 tools/lib/bpf/libbpf.pc.template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.pc.template +1 -1
index ac17fcef2108..b45ed534bdfb 100644
@@ -8,5 +8,5 @@ Name: libbpf
 Description: BPF library
 Version: @VERSION@
 Libs: -L${libdir} -lbpf
-Requires.private: libelf
+Requires.private: libelf zlib
 Cflags: -I${includedir}
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Andrii Nakryiko

List zlib as another dependency of libbpf in pkg-config template. Verified it is correctly resolved to proper -lz flag:

$ make DESTDIR=/tmp/libbpf-install install
$ pkg-config --libs /tmp/libbpf-install/usr/local/lib64/pkgconfig/libbpf.pc
-L/usr/local/lib64 -lbpf
$ pkg-config --libs --static /tmp/libbpf-install/usr/local/lib64/pkgconfig/libbpf.pc
-L/usr/local/lib64 -lbpf -lelf -lz

Even without this patch, I already got -lz for static link libraries:

-bash-4.4$ cat libbpf.pc.template
...
Requires.private: libelf
...
-bash-4.4$ pkg-config --libs --static /tmp/libbpf-install/usr/local/lib64/pkgconfig/libbpf.pc -L/usr/local/lib64 -lbpf -lelf -lz

libelf depending on zlib. Maybe -lz is introduced due to libelf.

But in any case, add explicit dependency to zlib from libbpf probably a good thing since libbpf directly uses its API functions.

[...]

Quoted 12 lines
tools/lib/bpf/libbpf.pc.template +1 -1
index ac17fcef2108..b45ed534bdfb 100644
@@ -8,5 +8,5 @@ Name: libbpf
  Description: BPF library
  Version: @VERSION@
  Libs: -L${libdir} -lbpf
-Requires.private: libelf
+Requires.private: libelf zlib
  Cflags: -I${includedir}
#2 lore raw
Quoted 23 lines · Yonghong Song
Quoted 8 lines · Andrii Nakryiko

List zlib as another dependency of libbpf in pkg-config template. Verified it is correctly resolved to proper -lz flag:

$ make DESTDIR=/tmp/libbpf-install install
$ pkg-config --libs /tmp/libbpf-install/usr/local/lib64/pkgconfig/libbpf.pc
-L/usr/local/lib64 -lbpf
$ pkg-config --libs --static /tmp/libbpf-install/usr/local/lib64/pkgconfig/libbpf.pc
-L/usr/local/lib64 -lbpf -lelf -lz

Even without this patch, I already got -lz for static link libraries:

-bash-4.4$ cat libbpf.pc.template
...
Requires.private: libelf
...
-bash-4.4$ pkg-config --libs --static /tmp/libbpf-install/usr/local/lib64/pkgconfig/libbpf.pc -L/usr/local/lib64 -lbpf -lelf -lz

Quoted 6 lines

libelf depending on zlib. Maybe -lz is introduced due to libelf.

But in any case, add explicit dependency to zlib from libbpf probably a good thing since libbpf directly uses its API functions.

Applied. Thanks