Re: [PATCH v3] samples/bpf: Fix build out of source tree

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

 



On Tue, Aug 1, 2023 at 8:56 AM Anh Tuan Phan <tuananhlfc@xxxxxxxxx> wrote:
>
>
>
> On 01/08/2023 00:17, Stanislav Fomichev wrote:
> > On Sun, Jul 30, 2023 at 6:18 AM Anh Tuan Phan <tuananhlfc@xxxxxxxxx> wrote:
> >>
> >> This commit fixes a few compilation issues when building out of source
> >> tree. The command that I used to build samples/bpf:
> >>
> >> export KBUILD_OUTPUT=/tmp
> >> make V=1 M=samples/bpf
> >>
> >> The compilation failed since it tried to find the header files in the
> >> wrong places between output directory and source tree directory
> >
> > Still doesn't apply cleanly, most likely due to commit bbaf1ff06af4
> > ("bpf: Replace deprecated -target with --target= for Clang").
> > Please rebase and repost. Also add [PATCH bpf-next v4] tag.
> >
>
> I rebased the commit from bpf tree so it's the reason for your failed
> applied. Have rebased from bpf-next tree and sent a "PATCH bpf-next v4"
> patch.

Yeah, not sure it should go via bpf tree. We don't have a good Fixes
tag and it's about samples, so let's keep bpf-next. Thx!

> Thank you!
>
> >
> >> Signed-off-by: Anh Tuan Phan <tuananhlfc@xxxxxxxxx>
> >> ---
> >> Changes from v1:
> >> - Unconditionally add "-I $(objtree)/$(obj)" to _tprogc_flags and drop unnecessary part
> >> Reference:
> >> - v1: https://lore.kernel.org/all/67bec6a9-af59-d6f9-2630-17280479a1f7@xxxxxxxxx/
> >> - v2: https://lore.kernel.org/all/2ba1c076-f5bf-432f-50c1-72c845403167@xxxxxxxxx/
> >> ---
> >>   samples/bpf/Makefile        | 10 +++++-----
> >>   samples/bpf/Makefile.target |  9 +--------
> >>   2 files changed, 6 insertions(+), 13 deletions(-)
> >>
> >> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> >> index 615f24ebc49c..cfc960b3713a 100644
> >> --- a/samples/bpf/Makefile
> >> +++ b/samples/bpf/Makefile
> >> @@ -341,10 +341,10 @@ $(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h
> >>   # Override includes for xdp_sample_user.o because $(srctree)/usr/include in
> >>   # TPROGS_CFLAGS causes conflicts
> >>   XDP_SAMPLE_CFLAGS += -Wall -O2 \
> >> -                    -I$(src)/../../tools/include \
> >> -                    -I$(src)/../../tools/include/uapi \
> >> +                    -I$(srctree)/tools/include \
> >> +                    -I$(srctree)/tools/include/uapi \
> >>                       -I$(LIBBPF_INCLUDE) \
> >> -                    -I$(src)/../../tools/testing/selftests/bpf
> >> +                    -I$(srctree)/tools/testing/selftests/bpf
> >>
> >>   $(obj)/$(XDP_SAMPLE): TPROGS_CFLAGS = $(XDP_SAMPLE_CFLAGS)
> >>   $(obj)/$(XDP_SAMPLE): $(src)/xdp_sample_user.h $(src)/xdp_sample_shared.h
> >> @@ -393,7 +393,7 @@ $(obj)/xdp_router_ipv4.bpf.o: $(obj)/xdp_sample.bpf.o
> >>   $(obj)/%.bpf.o: $(src)/%.bpf.c $(obj)/vmlinux.h $(src)/xdp_sample.bpf.h $(src)/xdp_sample_shared.h
> >>          @echo "  CLANG-BPF " $@
> >>          $(Q)$(CLANG) -g -O2 -target bpf -D__TARGET_ARCH_$(SRCARCH) \
> >> -               -Wno-compare-distinct-pointer-types -I$(srctree)/include \
> >> +               -Wno-compare-distinct-pointer-types -I$(obj) -I$(srctree)/include \
> >>                  -I$(srctree)/samples/bpf -I$(srctree)/tools/include \
> >>                  -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES) \
> >>                  -c $(filter %.bpf.c,$^) -o $@
> >> @@ -412,7 +412,7 @@ xdp_router_ipv4.skel.h-deps := xdp_router_ipv4.bpf.o xdp_sample.bpf.o
> >>
> >>   LINKED_BPF_SRCS := $(patsubst %.bpf.o,%.bpf.c,$(foreach skel,$(LINKED_SKELS),$($(skel)-deps)))
> >>
> >> -BPF_SRCS_LINKED := $(notdir $(wildcard $(src)/*.bpf.c))
> >> +BPF_SRCS_LINKED := $(notdir $(wildcard $(srctree)/$(src)/*.bpf.c))
> >>   BPF_OBJS_LINKED := $(patsubst %.bpf.c,$(obj)/%.bpf.o, $(BPF_SRCS_LINKED))
> >>   BPF_SKELS_LINKED := $(addprefix $(obj)/,$(LINKED_SKELS))
> >>
> >> diff --git a/samples/bpf/Makefile.target b/samples/bpf/Makefile.target
> >> index 7621f55e2947..d2fab959652e 100644
> >> --- a/samples/bpf/Makefile.target
> >> +++ b/samples/bpf/Makefile.target
> >> @@ -38,14 +38,7 @@ tprog-cobjs  := $(addprefix $(obj)/,$(tprog-cobjs))
> >>   # Handle options to gcc. Support building with separate output directory
> >>
> >>   _tprogc_flags   = $(TPROGS_CFLAGS) \
> >> -                 $(TPROGCFLAGS_$(basetarget).o)
> >> -
> >> -# $(objtree)/$(obj) for including generated headers from checkin source files
> >> -ifeq ($(KBUILD_EXTMOD),)
> >> -ifdef building_out_of_srctree
> >> -_tprogc_flags   += -I $(objtree)/$(obj)
> >> -endif
> >> -endif
> >> +                 -I $(objtree)/$(obj)
> >>
> >>   tprogc_flags    = -Wp,-MD,$(depfile) $(_tprogc_flags)
> >>
> >> --
> >> 2.34.1
> >>





[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