public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Anh Tuan Phan <tuananhlfc@gmail.com>
To: Stanislav Fomichev <sdf@google.com>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	martin.lau@linux.dev, bpf@vger.kernel.org,
	linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [PATCH v3] samples/bpf: Fix build out of source tree
Date: Tue, 1 Aug 2023 22:56:44 +0700	[thread overview]
Message-ID: <34890307-ca7a-ffa8-321d-eb5ad0db4a5a@gmail.com> (raw)
In-Reply-To: <CAKH8qBtNaEW4pEj7Y1WiLoPk2aMPoq3AuO14D=OF_NCN255awQ@mail.gmail.com>



On 01/08/2023 00:17, Stanislav Fomichev wrote:
> On Sun, Jul 30, 2023 at 6:18 AM Anh Tuan Phan <tuananhlfc@gmail.com> 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.

Thank you!

> 
>> Signed-off-by: Anh Tuan Phan <tuananhlfc@gmail.com>
>> ---
>> 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@gmail.com/
>> - v2: https://lore.kernel.org/all/2ba1c076-f5bf-432f-50c1-72c845403167@gmail.com/
>> ---
>>   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
>>

  reply	other threads:[~2023-08-01 15:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-30 13:17 [PATCH v3] samples/bpf: Fix build out of source tree Anh Tuan Phan
2023-07-31 17:17 ` Stanislav Fomichev
2023-08-01 15:56   ` Anh Tuan Phan [this message]
2023-08-01 18:47     ` Stanislav Fomichev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34890307-ca7a-ffa8-321d-eb5ad0db4a5a@gmail.com \
    --to=tuananhlfc@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=martin.lau@linux.dev \
    --cc=sdf@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox