* [PATCH v3] samples/bpf: Fix build out of source tree
@ 2023-07-30 13:17 Anh Tuan Phan
2023-07-31 17:17 ` Stanislav Fomichev
0 siblings, 1 reply; 4+ messages in thread
From: Anh Tuan Phan @ 2023-07-30 13:17 UTC (permalink / raw)
To: ast, daniel, andrii, martin.lau, sdf
Cc: bpf, linux-kernel-mentees, Anh Tuan Phan
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
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] samples/bpf: Fix build out of source tree
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
0 siblings, 1 reply; 4+ messages in thread
From: Stanislav Fomichev @ 2023-07-31 17:17 UTC (permalink / raw)
To: Anh Tuan Phan; +Cc: ast, daniel, andrii, martin.lau, bpf, linux-kernel-mentees
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.
> 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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] samples/bpf: Fix build out of source tree
2023-07-31 17:17 ` Stanislav Fomichev
@ 2023-08-01 15:56 ` Anh Tuan Phan
2023-08-01 18:47 ` Stanislav Fomichev
0 siblings, 1 reply; 4+ messages in thread
From: Anh Tuan Phan @ 2023-08-01 15:56 UTC (permalink / raw)
To: Stanislav Fomichev
Cc: ast, daniel, andrii, martin.lau, bpf, linux-kernel-mentees
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
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] samples/bpf: Fix build out of source tree
2023-08-01 15:56 ` Anh Tuan Phan
@ 2023-08-01 18:47 ` Stanislav Fomichev
0 siblings, 0 replies; 4+ messages in thread
From: Stanislav Fomichev @ 2023-08-01 18:47 UTC (permalink / raw)
To: Anh Tuan Phan; +Cc: ast, daniel, andrii, martin.lau, bpf, linux-kernel-mentees
On Tue, Aug 1, 2023 at 8:56 AM Anh Tuan Phan <tuananhlfc@gmail.com> wrote:
>
>
>
> 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.
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@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
> >>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-01 18:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2023-08-01 18:47 ` Stanislav Fomichev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox