Compile BPF samples from Linux Kernel

If I compile the bpf samples in the linux kernel I get following error:

/bin/sh: /home/USER/openwrt/build_dir/target-x86_64_musl/linux-x86_64/linux-4.19.81/samples/bpf/../..//tools/build/fixdep: No such file or directory

But this directroy exists and contains


Missing or incompatible libraries.

1 Like

The the output of ldd /home/USER/openwrt/build_dir/target-x86_64_musl/linux-x86_64/linux-4.19.81/samples/bpf/../..//tools/build/fixdep - it is likely that it will report unresolved library dependencies.


Yep. Something with glibc. Just deletet whole OpenWrt build root, that's why I do not have the ldd output right now.

What I did:

  1. Compile kernel with CONFIG_SAMPLES=y or modify kernel Makefile...
  2. make target/linux/prepare
  3. Add under samples/Makefile the bpf directory
  4. make target/linux/compile

The Makefile under the bpf directory is resetting the srctree and LDFLAGS and stuff like this. I think this is very problematic. I will try to build it in an OpenWrt environment directly on the system. :confused:

Oh, in the README is written

export ARCH=arm64 export CROSS_COMPILE="aarch64-linux-gnu-" make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang

How can I map this to OpenWrt? :confused:

I wouldn’t mind clang as a compiler option, but I think that’s “major surgery”

1 Like

Just following this guide:

Let's see what happens. :wink:
Right now I have to recompile the toolchain again, due to some errors and the forum says this should work

make toolchain/clean
make toolchain/install
make V=99

Can somebody try my steps? I do not get, why I habe no libelf support. :confused:

Check libelf in menuconfig and then compile your toolchain and everything.

Compile for x86_64.
Setup the environment.

export PATH


Go to:


And then

make CC=x86_64-openwrt-linux-musl-gcc LD=x86_64-openwrt-linux-musl-ld

I think, this sould compile? :confused: