Skip to content

Problems with building bpftools v0.24.1 in docker (wsl2) #131

Description

@1NC4NDESCENCE

I see from the following snippet that bpftrace version used now is v0.24.1

BPFTRACE_COMMIT = v0.24.1
BPFTRACE_REPO = https://github.com/iovisor/bpftrace.git/
projects/bpftrace/sources:
git clone $(BPFTRACE_REPO) $@ && \
cd $@ && \
git checkout $(BPFTRACE_COMMIT)

I compiled v0.23.4 bpftools last summer and it works flawlessly, but when I try to compile v0.24.1 now it has many problems.

  1. scripts/jammy-install-deps.sh lacks proper error handling and apt-get fails silently likely due to network issues, after fixing that, during build process, another error occurs due to xxd not installed, apt-get install xxd fixed it. I think this script's content should stay in sync with https://github.com/bpftrace/bpftrace/blob/master/docker/Dockerfile.ubuntu, it has xxd in it.
  2. now build succeeds and I get bpftools-arm64.tar.gz, but when I run bpftrace, linker complains it can't find libclang-cpp.so, I confirmed with ldd $(which bpftrace) on wsl2 archlinux that libclang-cpp is indeed a dependency now. And libclang-cpp-dev was added to the dockerfile between the release of v0.23.4 and v0.24.1, see https://github.com/bpftrace/bpftrace/blame/3fc827015ad48f857570bda6783cec273ed83e9c/docker/Dockerfile.ubuntu#L24-L26. After applying the following change, the linker error is fixed.
diff --git a/sysroot/bpftools.mk b/sysroot/bpftools.mk
index fe4360f..dc67656 100644
--- a/sysroot/bpftools.mk
+++ b/sysroot/bpftools.mk
@@ -49,6 +49,7 @@ $(BPFTOOLS):
        cp $(ANDROID_OUT_DIR)/lib/libbcc_bpf.so $@/lib/
        cp -a $(ANDROID_OUT_DIR)/lib/libbpf.so* $@/lib/
        cp $(ANDROID_OUT_DIR)/lib/libclang.so $@/lib/
+       cp $(ANDROID_OUT_DIR)/lib/libclang-cpp.so $@/lib/
        cp $(ANDROID_OUT_DIR)/lib/libc++_shared.so $@/lib/
        cp -a $(ANDROID_OUT_DIR)/lib/libelf*.so* $@/lib/
        cp $(ANDROID_OUT_DIR)/lib/libfl.so $@/lib/
  1. but it still doesn't work. I found the code snippet that went wrong but I don't quite know what the error means. https://elixir.bootlin.com/llvm/llvmorg-22.1.0-rc3/source/llvm/lib/Support/CommandLine.cpp#L220
OP5D0DL1:/data/local/tmp/bpftools $ ./bpftrace
: CommandLine Error: Option 'disable-bpf-peephole' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
Aborted

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions