Re: [PATCH bpf] samples: bpf: Fix vmlinux.h generation for XDP samples

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 28, 2021 at 10:06:09AM IST, Andrii Nakryiko wrote:
> On Mon, Sep 27, 2021 at 9:16 PM Kumar Kartikeya Dwivedi
> <memxor@xxxxxxxxx> wrote:
> >
> > Generate vmlinux.h only from the in-tree vmlinux, and remove enum
> > declarations that would cause a build failure in case of version
> > mismatches.
> >
> > There are now two options when building the samples:
> > 1. Compile the kernel to use in-tree vmlinux for vmlinux.h
> > 2. Override VMLINUX_BTF for samples using something like this:
> >    make VMLINUX_BTF=/sys/kernel/btf/vmlinux -C samples/bpf
> >
> > This change was tested with relative builds, e.g. cases like:
> >  * make O=build -C samples/bpf
> >  * make KBUILD_OUTPUT=build -C samples/bpf
> >  * make -C samples/bpf
> >  * cd samples/bpf && make
> >
> > When a suitable VMLINUX_BTF is not found, the following message is
> > printed:
> > /home/kkd/src/linux/samples/bpf/Makefile:333: *** Cannot find a vmlinux
> > for VMLINUX_BTF at any of "  ./vmlinux", build the kernel or set
> > VMLINUX_BTF variable.  Stop.
> >
> > Cc: Toke Høiland-Jørgensen <toke@xxxxxxxxxx>
> > Fixes: 384b6b3bbf0d (samples: bpf: Add vmlinux.h generation support)
> > Signed-off-by: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx>
> > ---
> >  samples/bpf/Makefile                     | 13 ++++++-------
> >  samples/bpf/xdp_redirect_map_multi.bpf.c |  5 -----
> >  2 files changed, 6 insertions(+), 12 deletions(-)
> >
> > diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> > index 4dc20be5fb96..a05130e91403 100644
> > --- a/samples/bpf/Makefile
> > +++ b/samples/bpf/Makefile
> > @@ -324,15 +324,9 @@ $(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h
> >
> >  VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux)                           \
> >                      $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux)    \
> > -                    ../../../../vmlinux                                \
> > -                    /sys/kernel/btf/vmlinux                            \
> > -                    /boot/vmlinux-$(shell uname -r)
> > +                    ./vmlinux
>
> isn't this relative to samples/bpf subdirectory, so shouldn't it be
> ../../vmlinux?
>

I was confused about this too; but it executes this when you call make:

# Trick to allow make to be run from this directory
all:
        $(MAKE) -C ../../ M=$(CURDIR) BPF_SAMPLES_PATH=$(CURDIR)

so it fails if the path isn't relative to kernel source root.

> >  VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS))))
> >
> > -ifeq ($(VMLINUX_BTF),)
> > -$(error Cannot find a vmlinux for VMLINUX_BTF at any of "$(VMLINUX_BTF_PATHS)")
> > -endif
> > -
>
> [...]

--
Kartikeya



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux