Skip to content

Commit

Permalink
Dockerfile: fix a static linking issue with bpftool
Browse files Browse the repository at this point in the history
When bumping the builder image to Ubuntu 24.04, the static build of
bpftool started to fail. We cannot use EXTRA_LDFLAGS unfortunately and
need to mofiy the LIBS and LIBS_BOOTSTRAP Makefile variables. Maybe we
can upstream this fix later.

Signed-off-by: Mahe Tardy <[email protected]>
  • Loading branch information
mtardy committed Aug 16, 2024
1 parent a02c8a8 commit 8e994cf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ RUN if [ $BUILDARCH != $TARGETARCH ]; \
# v7.3.0
ENV BPFTOOL_REV="687e7f06f2ee104ed6515ec3a9816af77bfa7a17"
RUN git clone https://github.com/libbpf/bpftool.git . && git checkout ${BPFTOOL_REV} && git submodule update --init --recursive
# From Ubuntu 24.04 builder image, libzstd must be added at the end of LIBS and LIBS_BOOTSTRAP to compile statically
RUN sed -i 's/\(LIBS = $(LIBBPF) -lelf -lz\)/\1 -lzstd/; s/\(LIBS_BOOTSTRAP = $(LIBBPF_BOOTSTRAP) -lelf -lz\)/\1 -lzstd/' src/Makefile
RUN if [ $BUILDARCH != $TARGETARCH ]; \
then make -C src EXTRA_CFLAGS=--static CC=aarch64-linux-gnu-gcc -j $(nproc) && aarch64-linux-gnu-strip src/bpftool; \
else make -C src EXTRA_CFLAGS=--static -j $(nproc) && strip src/bpftool; fi
Expand Down

0 comments on commit 8e994cf

Please sign in to comment.