Comment 7 for bug 2047683

Revision history for this message
James Dingwall (a-james-launchpad) wrote :

When I did a `git clean` I noticed that `tools/bpf/bpftool/vmlinux` existed but the failure appeared to look like the file was expected under `debian/build/tools-perarch/tools/bpf/bpftool/vmlinux`. With this hacky patch I managed to get the build to complete:

```
diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index 986a18d7abac9..398e6dc3a3434 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -666,6 +666,9 @@ ifeq ($(do_tools_perf),true)
                $(kmake) prefix=/usr NO_LIBTRACEEVENT=1 HAVE_CPLUS_DEMANGLE_SUPPORT=1 CROSS_COMPILE=$(CROSS_COMPILE) NO_LIBPERL=1 WERROR=0
 endif
 ifeq ($(do_tools_bpftool),true)
+ if [ -f $(CURDIR)/tools/bpf/bpftool/vmlinux ] && ! [ -f $(builddirpa)/tools/bpf/bpftool/vmlinux ] ; then \
+ ln $(CURDIR)/tools/bpf/bpftool/vmlinux $(builddirpa)/tools/bpf/bpftool/vmlinux ; \
+ fi
        mv $(builddirpa)/tools/bpf/bpftool/vmlinux $(builddirpa)/vmlinux
        $(kmake) NO_LIBTRACEEVENT=1 CROSS_COMPILE=$(CROSS_COMPILE) -C $(builddirpa)/tools/bpf/bpftool
        rm -f $(builddirpa)/vmlinux
```

I don't know if using an alternate output path somehow interacts with this method to find the vmlinux file, i.u. a file is found in one place so it is not rebuilt but that place is not the same that 2-binary-arch.mk expects. Makefiles are not my speciality though so likely I've just found a working bodge:)

```
VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux) \
                     $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \
                     ../../../vmlinux \
                     /sys/kernel/btf/vmlinux )libbpf/ \
                     /boot/vmlinux-$(shell uname -r)
VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS))))
```