* [PATCH v3 0/3] Makefile fixes for samples/{bpf,hid}
@ 2025-02-03 8:55 Jinghao Jia
2025-02-03 8:55 ` [PATCH v3 1/3] samples/hid: remove unnecessary -I flags from libbpf EXTRA_CFLAGS Jinghao Jia
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Jinghao Jia @ 2025-02-03 8:55 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Jiri Kosina, Benjamin Tissoires, Masahiro Yamada, Nicolas Schier,
Ruowen Qin, Jinghao Jia
Cc: bpf, linux-kernel, linux-input
Hi everyone,
Following commit 13b25489b6f8 ("kbuild: change working directory to
external module directory with M="), the Makefiles for both bpf and hid
samples are broken due to the use of the relative vmlinux path (i.e.,
./vmlinux) when generating vmlinux.h. Additionally, samples/hid experience
the same problem that was fixed for samples/bpf in commit 5a6ea7022ff4
("samples/bpf: Remove unnecessary -I flags from libbpf EXTRA_CFLAGS").
This patchset makes the following changes to fix these two problems:
- The first patch applies the same fix from commit 5a6ea7022ff4
("samples/bpf: Remove unnecessary -I flags from libbpf EXTRA_CFLAGS") to
samples/hid.
- The second and third patch replace the relative vmlinux paths in
samples/{bpf,hid}/Makefile with $(objtree)/vmlinux to correctly refer to
the vmlinux in kernel output directory, following the recent working
directory change in kbuild.
Changelog:
v2 -> v3:
- v2: https://lore.kernel.org/all/20250123081950.173588-1-jinghao7@illinois.edu/
- Address feedback from Andrii
- Split the vmlinux path fixes for bpf and hid
v1 -> v2:
- v1: https://lore.kernel.org/all/20250120023027.160448-1-jinghao7@illinois.edu/
- Address feedback from Daniel
- Apply vmlinux path fix to samples/hid
- Add a second patch that fixes the include path issue in samples/hid,
i.e., the same issue fixed fpr samples/bpf in commit 5a6ea7022ff4
("samples/bpf: Remove unnecessary -I flags from libbpf EXTRA_CFLAGS")
- Address feedback from Masahiro and Nicolas
- Use $(objtree) instead of $(srctree) in the path when referring to
vmlinux, as it is an artifact of kbuild
Jinghao Jia (3):
samples/hid: remove unnecessary -I flags from libbpf EXTRA_CFLAGS
samples/bpf: fix broken vmlinux path for VMLINUX_BTF
samples/hid: fix broken vmlinux path for VMLINUX_BTF
samples/bpf/Makefile | 2 +-
samples/hid/Makefile | 13 +++++++------
2 files changed, 8 insertions(+), 7 deletions(-)
--
2.48.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/3] samples/hid: remove unnecessary -I flags from libbpf EXTRA_CFLAGS
2025-02-03 8:55 [PATCH v3 0/3] Makefile fixes for samples/{bpf,hid} Jinghao Jia
@ 2025-02-03 8:55 ` Jinghao Jia
2025-02-03 8:55 ` [PATCH v3 2/3] samples/bpf: fix broken vmlinux path for VMLINUX_BTF Jinghao Jia
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Jinghao Jia @ 2025-02-03 8:55 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Jiri Kosina, Benjamin Tissoires, Masahiro Yamada, Nicolas Schier,
Ruowen Qin, Jinghao Jia
Cc: bpf, linux-kernel, linux-input
Commit 5a6ea7022ff4 ("samples/bpf: Remove unnecessary -I flags from
libbpf EXTRA_CFLAGS") fixed the build error caused by redundant include
path for samples/bpf, but not samples/hid.
Apply the same fix on samples/hid as well.
Fixes: 13b25489b6f8 ("kbuild: change working directory to external module directory with M=")
Tested-by: Ruowen Qin <ruqin@redhat.com>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
---
samples/hid/Makefile | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/samples/hid/Makefile b/samples/hid/Makefile
index 8ea59e9631a3..69159c81d045 100644
--- a/samples/hid/Makefile
+++ b/samples/hid/Makefile
@@ -40,16 +40,17 @@ BPF_EXTRA_CFLAGS += -I$(srctree)/arch/mips/include/asm/mach-generic
endif
endif
-TPROGS_CFLAGS += -Wall -O2
-TPROGS_CFLAGS += -Wmissing-prototypes
-TPROGS_CFLAGS += -Wstrict-prototypes
+COMMON_CFLAGS += -Wall -O2
+COMMON_CFLAGS += -Wmissing-prototypes
+COMMON_CFLAGS += -Wstrict-prototypes
+TPROGS_CFLAGS += $(COMMON_CFLAGS)
TPROGS_CFLAGS += -I$(objtree)/usr/include
TPROGS_CFLAGS += -I$(LIBBPF_INCLUDE)
TPROGS_CFLAGS += -I$(srctree)/tools/include
ifdef SYSROOT
-TPROGS_CFLAGS += --sysroot=$(SYSROOT)
+COMMON_CFLAGS += --sysroot=$(SYSROOT)
TPROGS_LDFLAGS := -L$(SYSROOT)/usr/lib
endif
@@ -112,7 +113,7 @@ clean:
$(LIBBPF): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUTPUT)
# Fix up variables inherited from Kbuild that tools/ build system won't like
- $(MAKE) -C $(LIBBPF_SRC) RM='rm -rf' EXTRA_CFLAGS="$(TPROGS_CFLAGS)" \
+ $(MAKE) -C $(LIBBPF_SRC) RM='rm -rf' EXTRA_CFLAGS="$(COMMON_CFLAGS)" \
LDFLAGS=$(TPROGS_LDFLAGS) srctree=$(HID_SAMPLES_PATH)/../../ \
O= OUTPUT=$(LIBBPF_OUTPUT)/ DESTDIR=$(LIBBPF_DESTDIR) prefix= \
$@ install_headers
--
2.48.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/3] samples/bpf: fix broken vmlinux path for VMLINUX_BTF
2025-02-03 8:55 [PATCH v3 0/3] Makefile fixes for samples/{bpf,hid} Jinghao Jia
2025-02-03 8:55 ` [PATCH v3 1/3] samples/hid: remove unnecessary -I flags from libbpf EXTRA_CFLAGS Jinghao Jia
@ 2025-02-03 8:55 ` Jinghao Jia
2025-02-06 0:54 ` Andrii Nakryiko
2025-02-03 8:55 ` [PATCH v3 3/3] samples/hid: " Jinghao Jia
` (2 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Jinghao Jia @ 2025-02-03 8:55 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Jiri Kosina, Benjamin Tissoires, Masahiro Yamada, Nicolas Schier,
Ruowen Qin, Jinghao Jia
Cc: bpf, linux-kernel, linux-input
Commit 13b25489b6f8 ("kbuild: change working directory to external
module directory with M=") changed kbuild working directory of bpf
sample programs to samples/bpf, which broke the vmlinux path for
VMLINUX_BTF, as the Makefiles assume the current work directory to be
the kernel output directory and use a relative path (i.e., ./vmlinux):
Makefile:316: *** Cannot find a vmlinux for VMLINUX_BTF at any of " /path/to/linux/samples/bpf/vmlinux", build the kernel or set VMLINUX_BTF like "VMLINUX_BTF=/sys/kernel/btf/vmlinux" or VMLINUX_H variable. Stop.
Correctly refer to the kernel output directory using $(objtree).
Fixes: 13b25489b6f8 ("kbuild: change working directory to external module directory with M=")
Tested-by: Ruowen Qin <ruqin@redhat.com>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
---
samples/bpf/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index dd9944a97b7e..5b632635e00d 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -307,7 +307,7 @@ $(obj)/$(TRACE_HELPERS): TPROGS_CFLAGS := $(TPROGS_CFLAGS) -D__must_check=
VMLINUX_BTF_PATHS ?= $(abspath $(if $(O),$(O)/vmlinux)) \
$(abspath $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux)) \
- $(abspath ./vmlinux)
+ $(abspath $(objtree)/vmlinux)
VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS))))
$(obj)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL)
--
2.48.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/3] samples/hid: fix broken vmlinux path for VMLINUX_BTF
2025-02-03 8:55 [PATCH v3 0/3] Makefile fixes for samples/{bpf,hid} Jinghao Jia
2025-02-03 8:55 ` [PATCH v3 1/3] samples/hid: remove unnecessary -I flags from libbpf EXTRA_CFLAGS Jinghao Jia
2025-02-03 8:55 ` [PATCH v3 2/3] samples/bpf: fix broken vmlinux path for VMLINUX_BTF Jinghao Jia
@ 2025-02-03 8:55 ` Jinghao Jia
2025-02-04 10:09 ` (subset) [PATCH v3 0/3] Makefile fixes for samples/{bpf,hid} Benjamin Tissoires
2025-02-06 1:00 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 7+ messages in thread
From: Jinghao Jia @ 2025-02-03 8:55 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Jiri Kosina, Benjamin Tissoires, Masahiro Yamada, Nicolas Schier,
Ruowen Qin, Jinghao Jia
Cc: bpf, linux-kernel, linux-input
Commit 13b25489b6f8 ("kbuild: change working directory to external
module directory with M=") changed kbuild working directory of hid-bpf
sample programs to samples/hid, which broke the vmlinux path for
VMLINUX_BTF, as the Makefiles assume the current work directory to be
the kernel output directory and use a relative path (i.e., ./vmlinux):
Makefile:173: *** Cannot find a vmlinux for VMLINUX_BTF at any of " /path/to/linux/samples/hid/vmlinux", build the kernel or set VMLINUX_BTF or VMLINUX_H variable. Stop.
Correctly refer to the kernel output directory using $(objtree).
Fixes: 13b25489b6f8 ("kbuild: change working directory to external module directory with M=")
Tested-by: Ruowen Qin <ruqin@redhat.com>
Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
---
samples/hid/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/samples/hid/Makefile b/samples/hid/Makefile
index 69159c81d045..db5a077c77fc 100644
--- a/samples/hid/Makefile
+++ b/samples/hid/Makefile
@@ -164,7 +164,7 @@ $(obj)/hid_surface_dial.o: $(obj)/hid_surface_dial.skel.h
VMLINUX_BTF_PATHS ?= $(abspath $(if $(O),$(O)/vmlinux)) \
$(abspath $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux)) \
- $(abspath ./vmlinux)
+ $(abspath $(objtree)/vmlinux)
VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS))))
$(obj)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL)
--
2.48.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: (subset) [PATCH v3 0/3] Makefile fixes for samples/{bpf,hid}
2025-02-03 8:55 [PATCH v3 0/3] Makefile fixes for samples/{bpf,hid} Jinghao Jia
` (2 preceding siblings ...)
2025-02-03 8:55 ` [PATCH v3 3/3] samples/hid: " Jinghao Jia
@ 2025-02-04 10:09 ` Benjamin Tissoires
2025-02-06 1:00 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 7+ messages in thread
From: Benjamin Tissoires @ 2025-02-04 10:09 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Jiri Kosina, Masahiro Yamada, Nicolas Schier, Ruowen Qin,
Jinghao Jia
Cc: bpf, linux-kernel, linux-input
On Mon, 03 Feb 2025 02:55:03 -0600, Jinghao Jia wrote:
> Following commit 13b25489b6f8 ("kbuild: change working directory to
> external module directory with M="), the Makefiles for both bpf and hid
> samples are broken due to the use of the relative vmlinux path (i.e.,
> ./vmlinux) when generating vmlinux.h. Additionally, samples/hid experience
> the same problem that was fixed for samples/bpf in commit 5a6ea7022ff4
> ("samples/bpf: Remove unnecessary -I flags from libbpf EXTRA_CFLAGS").
>
> [...]
Applied to hid/hid.git (for-6.14/upstream-fixes), thanks!
[1/3] samples/hid: remove unnecessary -I flags from libbpf EXTRA_CFLAGS
https://git.kernel.org/hid/hid/c/1739cafdb8de
[3/3] samples/hid: fix broken vmlinux path for VMLINUX_BTF
https://git.kernel.org/hid/hid/c/8b125949df58
Cheers,
--
Benjamin Tissoires <bentiss@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 2/3] samples/bpf: fix broken vmlinux path for VMLINUX_BTF
2025-02-03 8:55 ` [PATCH v3 2/3] samples/bpf: fix broken vmlinux path for VMLINUX_BTF Jinghao Jia
@ 2025-02-06 0:54 ` Andrii Nakryiko
0 siblings, 0 replies; 7+ messages in thread
From: Andrii Nakryiko @ 2025-02-06 0:54 UTC (permalink / raw)
To: Jinghao Jia
Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Jiri Kosina, Benjamin Tissoires, Masahiro Yamada, Nicolas Schier,
Ruowen Qin, bpf, linux-kernel, linux-input
On Mon, Feb 3, 2025 at 12:55 AM Jinghao Jia <jinghao7@illinois.edu> wrote:
>
> Commit 13b25489b6f8 ("kbuild: change working directory to external
> module directory with M=") changed kbuild working directory of bpf
> sample programs to samples/bpf, which broke the vmlinux path for
> VMLINUX_BTF, as the Makefiles assume the current work directory to be
> the kernel output directory and use a relative path (i.e., ./vmlinux):
>
> Makefile:316: *** Cannot find a vmlinux for VMLINUX_BTF at any of " /path/to/linux/samples/bpf/vmlinux", build the kernel or set VMLINUX_BTF like "VMLINUX_BTF=/sys/kernel/btf/vmlinux" or VMLINUX_H variable. Stop.
>
> Correctly refer to the kernel output directory using $(objtree).
>
> Fixes: 13b25489b6f8 ("kbuild: change working directory to external module directory with M=")
> Tested-by: Ruowen Qin <ruqin@redhat.com>
> Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
> ---
> samples/bpf/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Applied this patch to bpf-next. I presume HID ones will go through the
respective tree. Thanks!
> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> index dd9944a97b7e..5b632635e00d 100644
> --- a/samples/bpf/Makefile
> +++ b/samples/bpf/Makefile
> @@ -307,7 +307,7 @@ $(obj)/$(TRACE_HELPERS): TPROGS_CFLAGS := $(TPROGS_CFLAGS) -D__must_check=
>
> VMLINUX_BTF_PATHS ?= $(abspath $(if $(O),$(O)/vmlinux)) \
> $(abspath $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux)) \
> - $(abspath ./vmlinux)
> + $(abspath $(objtree)/vmlinux)
> VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS))))
>
> $(obj)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL)
> --
> 2.48.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 0/3] Makefile fixes for samples/{bpf,hid}
2025-02-03 8:55 [PATCH v3 0/3] Makefile fixes for samples/{bpf,hid} Jinghao Jia
` (3 preceding siblings ...)
2025-02-04 10:09 ` (subset) [PATCH v3 0/3] Makefile fixes for samples/{bpf,hid} Benjamin Tissoires
@ 2025-02-06 1:00 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-06 1:00 UTC (permalink / raw)
To: Jinghao Jia
Cc: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
john.fastabend, kpsingh, sdf, haoluo, jolsa, jikos, bentiss,
masahiroy, n.schier, ruqin, bpf, linux-kernel, linux-input
Hello:
This series was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Mon, 3 Feb 2025 02:55:03 -0600 you wrote:
> Hi everyone,
>
> Following commit 13b25489b6f8 ("kbuild: change working directory to
> external module directory with M="), the Makefiles for both bpf and hid
> samples are broken due to the use of the relative vmlinux path (i.e.,
> ./vmlinux) when generating vmlinux.h. Additionally, samples/hid experience
> the same problem that was fixed for samples/bpf in commit 5a6ea7022ff4
> ("samples/bpf: Remove unnecessary -I flags from libbpf EXTRA_CFLAGS").
>
> [...]
Here is the summary with links:
- [v3,1/3] samples/hid: remove unnecessary -I flags from libbpf EXTRA_CFLAGS
(no matching commit)
- [v3,2/3] samples/bpf: fix broken vmlinux path for VMLINUX_BTF
https://git.kernel.org/bpf/bpf-next/c/94f53edc64e1
- [v3,3/3] samples/hid: fix broken vmlinux path for VMLINUX_BTF
(no matching commit)
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-02-06 1:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-03 8:55 [PATCH v3 0/3] Makefile fixes for samples/{bpf,hid} Jinghao Jia
2025-02-03 8:55 ` [PATCH v3 1/3] samples/hid: remove unnecessary -I flags from libbpf EXTRA_CFLAGS Jinghao Jia
2025-02-03 8:55 ` [PATCH v3 2/3] samples/bpf: fix broken vmlinux path for VMLINUX_BTF Jinghao Jia
2025-02-06 0:54 ` Andrii Nakryiko
2025-02-03 8:55 ` [PATCH v3 3/3] samples/hid: " Jinghao Jia
2025-02-04 10:09 ` (subset) [PATCH v3 0/3] Makefile fixes for samples/{bpf,hid} Benjamin Tissoires
2025-02-06 1:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).