If you are building on a relatively new host, using musl-1.2.4 or newer, llvm-bpf doesn't build because it attempts to lseek64 and other functions ending with 64; which were renamed since 1.2.4 came out to exclude 64; so lseek64 becomes lseek.
There is a workaround for this issue for almost everything, building with define _LARGEFILE64_SOURCE, so you need to add
HOST_CFLAGS+= -D_LARGEFILE64_SOURCE
to your tools/llvm-bpf/Makefile under
include $(INCLUDE_DIR)/cmake.mk
so that in the end it will look like this:
...
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/cmake.mk
HOST_CFLAGS+= -D_LARGEFILE64_SOURCE
LLVM_BPF_PREFIX = llvm-bpf-$(PKG_VERSION).$(HOST_OS)-$(HOST_ARCH)
...
this will instruct compiler to accept functions ending with 64 and translating them properly. I have also added this information to wiki. It might be worth a while to update wiki, since I've given quite a lot here to take one building openwrt on openwrt a bit further. Ever since I built my first image of openwrt on openwrt, I've been doing it eventually even getting changes even into mainstream to get it more compatible with this build method and I still like this approach very much.
I also attempted to build a newer llvm; version 17.0.6 - which built nicely without patches and tinkering Makefile, unfortunately it just didn't work, there's just something fundamentally different with that newer version and as I am not an expert with llvm, I had to revert to older version of llvm and add that host CFLAG to be able to build it.