* [PATCH v2] samples/bpf: Fix build out of source tree
@ 2023-07-28 0:43 Anh Tuan Phan
2023-07-28 16:30 ` Stanislav Fomichev via Linux-kernel-mentees
0 siblings, 1 reply; 3+ messages in thread
From: Anh Tuan Phan @ 2023-07-28 0:43 UTC (permalink / raw)
To: Stanislav Fomichev, ast, daniel, andrii, martin.lau
Cc: bpf, linux-kernel-mentees
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/
---
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
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] samples/bpf: Fix build out of source tree
2023-07-28 0:43 [PATCH v2] samples/bpf: Fix build out of source tree Anh Tuan Phan
@ 2023-07-28 16:30 ` Stanislav Fomichev via Linux-kernel-mentees
2023-07-30 13:19 ` Anh Tuan Phan
0 siblings, 1 reply; 3+ messages in thread
From: Stanislav Fomichev via Linux-kernel-mentees @ 2023-07-28 16:30 UTC (permalink / raw)
To: Anh Tuan Phan; +Cc: daniel, martin.lau, ast, andrii, bpf, linux-kernel-mentees
On Thu, Jul 27, 2023 at 5:43 PM 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
I was going to test it locally, but I can't apply it. Patchwork also
complains about the same issue:
stderr: 'error: corrupt patch at line 33
Are you copy-pasting it to gmail maybe? (or manually edited it after
git format-patch?)
Maybe rebase, and resend properly with git send-email?
> 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/
> ---
> 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
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] samples/bpf: Fix build out of source tree
2023-07-28 16:30 ` Stanislav Fomichev via Linux-kernel-mentees
@ 2023-07-30 13:19 ` Anh Tuan Phan
0 siblings, 0 replies; 3+ messages in thread
From: Anh Tuan Phan @ 2023-07-30 13:19 UTC (permalink / raw)
To: Stanislav Fomichev
Cc: daniel, martin.lau, ast, andrii, bpf, linux-kernel-mentees
On 7/28/23 23:30, Stanislav Fomichev wrote:
> On Thu, Jul 27, 2023 at 5:43 PM 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
>
> I was going to test it locally, but I can't apply it. Patchwork also
> complains about the same issue:
> stderr: 'error: corrupt patch at line 33
>
> Are you copy-pasting it to gmail maybe? (or manually edited it after
> git format-patch?)
> Maybe rebase, and resend properly with git send-email?
>
It was the copy paste problem. I rebased and sent again by git
send-email. Sorry for the inconvenient.
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-30 13:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-28 0:43 [PATCH v2] samples/bpf: Fix build out of source tree Anh Tuan Phan
2023-07-28 16:30 ` Stanislav Fomichev via Linux-kernel-mentees
2023-07-30 13:19 ` Anh Tuan Phan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox