iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.58k stars 3.88k forks source link

Build from source for Alpine Linux needs some modifications. #4594

Open suhho1993 opened 1 year ago

suhho1993 commented 1 year ago

First, I tried to build a docker container with bcc using Alpine linux image (tag: Latest). But it showed some errors and seems it needs some updates. Here's my Dockerfile

FROM alpine:latest
ENV  DEBIAN_FRONTEND=noninteractive

RUN apk --no-cache update

RUN apk --no-cache add tar git build-base iperf \
        linux-headers llvm15-dev llvm15-static \
        clang-dev clang-static cmake python3 \
        flex-dev bison luajit-dev elfutils-dev \
        zlib-dev musl xz zip

RUN git clone  https://github.com/iovisor/bcc.git
RUN sed -i 's/error.h/err.h/' bcc/examples/cpp/KModRetExample.cc | cat -n
RUN mkdir bcc/build
WORKDIR  bcc/build
RUN cmake -DPYTHON_CMD=python3 .. # build python3 binding
RUN make
RUN make install

WORKDIR /

There are three things to do in order to make things work.

  1. It needs extra packages such as xz, zip, and musl, which are not instructed in the INSTALL.MD.
  2. The llvm10, which is instructed in INSTALL.MD is not supported. So I changed it to llvm15.
  3. Alpine doesn't have error.h headerfile. So i switched 'error.h' from "bcc/usr/share/bcc/tools/execsnoop" up with 'err.h'.

These steps will solve things for now I guess. Any comments?

ChangHoon-Sung commented 10 months ago

I could reproduce the problem and solve it by following the steps. Docs should be fixed!

hhoffstaette commented 2 months ago

This bit:

RUN sed -i 's/error.h/err.h/' bcc/examples/cpp/KModRetExample.cc | cat -n

is obsolete and actually wrong by now since neither error() (glibc) nor err() (musl variant) are used in KModRetExample.cc. The #include statement can simply be removed.