bpf: Add missing force_checksrc macro
Subsystems (3)
PATCH 1/1 bpf: Add missing force_checksrc macro
According to the documentation, when building a kernel with the C=2 parameter, all source files should be checked. But this does not happen for the kernel/bpf/ directory.
$ touch kernel/bpf/core.o $ make C=2 CHECK=true kernel/bpf/core.o
Outputs:
CHECK scripts/mod/empty.c
CALL scripts/checksyscalls.sh
DESCEND objtool
INSTALL libsubcmd_headers
CC kernel/bpf/core.o
As can be seen the compilation is done, but CHECK is not executed. This happens because kernel/bpf/Makefile has defined its own rule for compilation and forgotten the macro that does the check.
--- kernel/bpf/Makefile | 1 + 1 file changed, 1 insertion(+)
kernel/bpf/Makefile +1 -0
@@ -58,3 +58,4 @@ vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf $(obj)/%.o: %.c FORCE $(call if_changed_rule,cc_o_c) + $(call cmd,force_checksrc)
Signature · 1 line
2.46.0
Masahiro Yamada
NAKQuoted 16 lines · Alexey Gladkov
According to the documentation, when building a kernel with the C=2 parameter, all source files should be checked. But this does not happen for the
kernel/bpf/directory.$ touch kernel/bpf/core.o $ make C=2 CHECK=true kernel/bpf/core.oOutputs:
CHECK
scripts/mod/empty.c
CALLscripts/checksyscalls.sh
DESCEND objtool
INSTALLlibsubcmd_headers
CCkernel/bpf/core.o
Quoted 5 lines
As can be seen the compilation is done, but CHECK is not executed. This happens because
kernel/bpf/Makefilehas defined its own rule for compilation and forgotten the macro that does the check.Signed-off-by Alexey Gladkov <[email protected]>
NACK.
This Makefile is already screwed up.
There is no need to duplicate the build code.
Please remove the last 6 lines of kernel/bpf/Makefile
See the following code as an example:arch/arm/boot/compressed/fdt_rw.c
Like this:
$ cat kernel/bpf/btf_iter.c #include "../../tools/lib/bpf/btf_iter.c"
Same forkernel/bpf/btf_relocate.ckernel/bpf/relo_core.c
Quoted 17 lines
--- kernel/bpf/Makefile | 1 + 1 file changed, 1 insertion(+)kernel/bpf/Makefile +1
-1@@ -58,3 +58,4 @@ vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf $(obj)/%.o: %.c FORCE $(call if_changed_rule,cc_o_c) + $(call cmd,force_checksrc) --2.46.0
Signature · 2 lines
Best Regards Masahiro Yamada
PATCH v2 1/1 bpf: Remove custom build rule
According to the documentation, when building a kernel with the C=2 parameter, all source files should be checked. But this does not happen for the kernel/bpf/ directory.
$ touch kernel/bpf/core.o $ make C=2 CHECK=true kernel/bpf/core.o
Outputs:
CHECK scripts/mod/empty.c
CALL scripts/checksyscalls.sh
DESCEND objtool
INSTALL libsubcmd_headers
CC kernel/bpf/core.o
As can be seen the compilation is done, but CHECK is not executed. This happens because kernel/bpf/Makefile has defined its own rule for compilation and forgotten the macro that does the check.
There is no need to duplicate the build code, and this rule can be removed to use generic rules.
--- kernel/bpf/Makefile | 6 ------ 1 file changed, 6 deletions(-)
kernel/bpf/Makefile +0 -6
@@ -52,9 +52,3 @@ obj-$(CONFIG_BPF_PRELOAD) += preload/ obj-$(CONFIG_BPF_SYSCALL) += relo_core.o obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o - -# Some source files are common to libbpf. -vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf - -$(obj)/%.o: %.c FORCE - $(call if_changed_rule,cc_o_c)
Signature · 1 line
2.46.0
Re: [PATCH v2] bpf: Remove custom build rule
Quoted 16 lines · Alexey Gladkov
According to the documentation, when building a kernel with the C=2 parameter, all source files should be checked. But this does not happen for the
kernel/bpf/directory.$ touch kernel/bpf/core.o $ make C=2 CHECK=true kernel/bpf/core.oOutputs:
CHECK
scripts/mod/empty.c
CALLscripts/checksyscalls.sh
DESCEND objtool
INSTALLlibsubcmd_headers
CCkernel/bpf/core.o
Quoted 8 lines
As can be seen the compilation is done, but CHECK is not executed. This happens because
kernel/bpf/Makefilehas defined its own rule for compilation and forgotten the macro that does the check.There is no need to duplicate the build code, and this rule can be removed to use generic rules.
Signed-off-by Alexey Gladkov <[email protected]>
Did you compile-test this?
See my previous email.
I said this:
$ cat kernel/bpf/btf_iter.c #include "../../tools/lib/bpf/btf_iter.c"
Same forkernel/bpf/btf_relocate.ckernel/bpf/relo_core.c
Quoted 19 lines
--- kernel/bpf/Makefile | 6 ------ 1 file changed, 6 deletions(-)kernel/bpf/Makefile +0
-7@@ -52,9 +52,3 @@ obj-$(CONFIG_BPF_PRELOAD) += preload/ obj-$(CONFIG_BPF_SYSCALL) += relo_core.o obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o - -# Some source files are common to libbpf. -vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf - -$(obj)/%.o: %.c FORCE - $(call if_changed_rule,cc_o_c) --
Quoted 2 lines
2.46.0
--
Best Regards
Masahiro Yamada
Re: [PATCH v2] bpf: Remove custom build rule
Quoted 21 lines · Masahiro Yamada
Quoted 20 lines · Alexey Gladkov
According to the documentation, when building a kernel with the C=2 parameter, all source files should be checked. But this does not happen for the
kernel/bpf/directory.$ touch kernel/bpf/core.o $ make C=2 CHECK=true kernel/bpf/core.oOutputs:
CHECK
scripts/mod/empty.c
CALLscripts/checksyscalls.sh
DESCEND objtool
INSTALLlibsubcmd_headers
CCkernel/bpf/core.oAs can be seen the compilation is done, but CHECK is not executed. This happens because
kernel/bpf/Makefilehas defined its own rule for compilation and forgotten the macro that does the check.
Quoted 7 lines
Quoted 4 lines
There is no need to duplicate the build code, and this rule can be removed to use generic rules.
Signed-off-by Alexey Gladkov <[email protected]>Did you compile-test this?
Yes. I repeated my steps for reproduce:
$ touch kernel/bpf/core.c $ make C=2 CHECK=true |grep kernel/bpf/core CC kernel/bpf/core.o CHECK kernel/bpf/core.c
but maybe my config is too small.
Quoted 53 lines
See my previous email.
I said this:
$ cat kernel/bpf/btf_iter.c #include "../../tools/lib/bpf/btf_iter.c"Same for
kernel/bpf/btf_relocate.ckernel/bpf/relo_core.cQuoted 19 lines
--- kernel/bpf/Makefile | 6 ------ 1 file changed, 6 deletions(-)kernel/bpf/Makefile +0
-7@@ -52,9 +52,3 @@ obj-$(CONFIG_BPF_PRELOAD) += preload/ obj-$(CONFIG_BPF_SYSCALL) += relo_core.o obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o - -# Some source files are common to libbpf. -vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf - -$(obj)/%.o: %.c FORCE - $(call if_changed_rule,cc_o_c) --Quoted 2 lines
2.46.0
--
Best Regards
Masahiro Yamada
Signature · 1 line
Rgrds, legion
PATCH v3 1/1 bpf: Remove custom build rule
In reply to Masahiro YamadaAccording to the documentation, when building a kernel with the C=2 parameter, all source files should be checked. But this does not happen for the kernel/bpf/ directory.
$ touch kernel/bpf/core.c $ make C=2 CHECK=true kernel/bpf/core.o
Outputs:
CHECK scripts/mod/empty.c
CALL scripts/checksyscalls.sh
DESCEND objtool
INSTALL libsubcmd_headers
CC kernel/bpf/core.o
As can be seen the compilation is done, but CHECK is not executed. This happens because kernel/bpf/Makefile has defined its own rule for compilation and forgotten the macro that does the check.
There is no need to duplicate the build code, and this rule can be removed to use generic rules.
--- kernel/bpf/Makefile | 6 ------ kernel/bpf/btf_iter.c | 2 ++ kernel/bpf/btf_relocate.c | 2 ++ kernel/bpf/relo_core.c | 2 ++ 4 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 kernel/bpf/btf_iter.c create mode 100644 kernel/bpf/btf_relocate.c create mode 100644 kernel/bpf/relo_core.c
kernel/bpf/Makefile +0 -6
@@ -52,9 +52,3 @@ obj-$(CONFIG_BPF_PRELOAD) += preload/ obj-$(CONFIG_BPF_SYSCALL) += relo_core.o obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o - -# Some source files are common to libbpf. -vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf - -$(obj)/%.o: %.c FORCE - $(call if_changed_rule,cc_o_c)
kernel/bpf/btf_iter.c new file +2 -0
@@ -0,0 +1,2 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "../../tools/lib/bpf/btf_iter.c"
kernel/bpf/btf_relocate.c new file +2 -0
@@ -0,0 +1,2 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "../../tools/lib/bpf/btf_relocate.c"
kernel/bpf/relo_core.c new file +2 -0
@@ -0,0 +1,2 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "../../tools/lib/bpf/relo_core.c"
Signature · 1 line
2.46.0
Re: [PATCH v3] bpf: Remove custom build rule
Quoted 16 lines · Alexey Gladkov
According to the documentation, when building a kernel with the C=2 parameter, all source files should be checked. But this does not happen for the
kernel/bpf/directory.$ touch kernel/bpf/core.c $ make C=2 CHECK=true kernel/bpf/core.oOutputs:
CHECK
scripts/mod/empty.c
CALLscripts/checksyscalls.sh
DESCEND objtool
INSTALLlibsubcmd_headers
CCkernel/bpf/core.o
Quoted 8 lines
As can be seen the compilation is done, but CHECK is not executed. This happens because
kernel/bpf/Makefilehas defined its own rule for compilation and forgotten the macro that does the check.There is no need to duplicate the build code, and this rule can be removed to use generic rules.
Signed-off-by Alexey Gladkov <[email protected]>
Quoted 51 lines
--- kernel/bpf/Makefile | 6 ------ kernel/bpf/btf_iter.c | 2 ++ kernel/bpf/btf_relocate.c | 2 ++ kernel/bpf/relo_core.c | 2 ++ 4 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 kernel/bpf/btf_iter.c create mode 100644 kernel/bpf/btf_relocate.c create mode 100644 kernel/bpf/relo_core.ckernel/bpf/Makefile +0
-6@@ -52,9 +52,3 @@ obj-$(CONFIG_BPF_PRELOAD) += preload/ obj-$(CONFIG_BPF_SYSCALL) += relo_core.o obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o - -# Some source files are common to libbpf. -vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf - -$(obj)/%.o: %.c FORCE - $(call if_changed_rule,cc_o_c)kernel/bpf/btf_iter.c new file +2
-0@@ -0,0 +1,2 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "../../tools/lib/bpf/btf_iter.c" kernel/bpf/btf_relocate.c new file +2
-0@@ -0,0 +1,2 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "../../tools/lib/bpf/btf_relocate.c" kernel/bpf/relo_core.c new file +2
-1@@ -0,0 +1,2 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "../../tools/lib/bpf/relo_core.c" --2.46.0
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH v3] bpf: Remove custom build rule
In reply to Alexey GladkovI know nothing about Kbuild, I can only confirm that this patch fixes the problem I encountered in practice.
Quoted 6 lines · Alexey Gladkov
$ touch kernel/bpf/core.c $ make C=2 CHECK=true kernel/bpf/core.oOutputs:
Quoted 7 lines
CHECK
scripts/mod/empty.c
CALLscripts/checksyscalls.sh
DESCEND objtool
INSTALLlibsubcmd_headers
CCkernel/bpf/core.oAs can be seen the compilation is done, but CHECK is not executed.
And after that
$ make C=2 CHECK=true kernel/bpf/core.o CHECK scripts/mod/empty.c CALL scripts/checksyscalls.sh DESCEND objtool INSTALL libsubcmd_headers
CHECK is also not executed.
compare with, for example,
$ touch kernel/trace/trace.c $ make C=2 CHECK=true kernel/trace/trace.o CHECK scripts/mod/empty.c CALL scripts/checksyscalls.sh DESCEND objtool INSTALL libsubcmd_headers CC kernel/trace/trace.o CHECK kernel/trace/trace.c $ make C=2 CHECK=true kernel/trace/trace.o CHECK scripts/mod/empty.c CALL scripts/checksyscalls.sh DESCEND objtool INSTALL libsubcmd_headers CHECK kernel/trace/trace.c
Re: [PATCH v3] bpf: Remove custom build rule
In reply to Alexey GladkovQuoted 15 lines · Alexey Gladkov
According to the documentation, when building a kernel with the C=2 parameter, all source files should be checked. But this does not happen for the
kernel/bpf/directory.$ touch kernel/bpf/core.c $ make C=2 CHECK=true kernel/bpf/core.oOutputs:
CHECK
scripts/mod/empty.c
CALLscripts/checksyscalls.sh
DESCEND objtool
INSTALLlibsubcmd_headers
CCkernel/bpf/core.o
Quoted 8 lines
As can be seen the compilation is done, but CHECK is not executed. This happens because
kernel/bpf/Makefilehas defined its own rule for compilation and forgotten the macro that does the check.There is no need to duplicate the build code, and this rule can be removed to use generic rules.
Signed-off-by Alexey Gladkov <[email protected]>
The aim from the BPF side is just to share the btf_iter.c, btf_relocate.c and relo_core.c files for both libbpf and kernel build. Those files need to live in tools/lib/bpf because the libbpf standalone repo on github is built from tools/lib/bpf.
Since the approach in this patch continues to support that while it doesn't break other things like check targets it's definitely preferred.
Thanks for the fix!
Alan
Quoted 48 lines
--- kernel/bpf/Makefile | 6 ------ kernel/bpf/btf_iter.c | 2 ++ kernel/bpf/btf_relocate.c | 2 ++ kernel/bpf/relo_core.c | 2 ++ 4 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 kernel/bpf/btf_iter.c create mode 100644 kernel/bpf/btf_relocate.c create mode 100644 kernel/bpf/relo_core.ckernel/bpf/Makefile +0
-6@@ -52,9 +52,3 @@ obj-$(CONFIG_BPF_PRELOAD) += preload/ obj-$(CONFIG_BPF_SYSCALL) += relo_core.o obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o - -# Some source files are common to libbpf. -vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf - -$(obj)/%.o: %.c FORCE - $(call if_changed_rule,cc_o_c)kernel/bpf/btf_iter.c new file +2
-0@@ -0,0 +1,2 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "../../tools/lib/bpf/btf_iter.c" kernel/bpf/btf_relocate.c new file +2
-0@@ -0,0 +1,2 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "../../tools/lib/bpf/btf_relocate.c" kernel/bpf/relo_core.c new file +2
-0@@ -0,0 +1,2 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "../../tools/lib/bpf/relo_core.c"
Re: [PATCH v3] bpf: Remove custom build rule
In reply to Alexey Gladkovkernel/bpf/btf_iter.c line 2
Quoted 6 lines · Alexey Gladkov
kernel/bpf/btf_iter.c new file +2
-0@@ -0,0 +1,2 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "../../tools/lib/bpf/btf_iter.c"
These files are licensed as
// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) in libbpf directory.
Pls use that.
Pls keep acks/reviews-bys/tested-by when you respin.
Thanks
pw-bot: cr
PATCH v4 1/1 bpf: Remove custom build rule
According to the documentation, when building a kernel with the C=2 parameter, all source files should be checked. But this does not happen for the kernel/bpf/ directory.
$ touch kernel/bpf/core.o $ make C=2 CHECK=true kernel/bpf/core.o
Outputs:
CHECK scripts/mod/empty.c
CALL scripts/checksyscalls.sh
DESCEND objtool
INSTALL libsubcmd_headers
CC kernel/bpf/core.o
As can be seen the compilation is done, but CHECK is not executed. This happens because kernel/bpf/Makefile has defined its own rule for compilation and forgotten the macro that does the check.
There is no need to duplicate the build code, and this rule can be removed to use generic rules.
--- kernel/bpf/Makefile | 6 ------ kernel/bpf/btf_iter.c | 2 ++ kernel/bpf/btf_relocate.c | 2 ++ kernel/bpf/relo_core.c | 2 ++ 4 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 kernel/bpf/btf_iter.c create mode 100644 kernel/bpf/btf_relocate.c create mode 100644 kernel/bpf/relo_core.c
kernel/bpf/Makefile +0 -6
@@ -52,9 +52,3 @@ obj-$(CONFIG_BPF_PRELOAD) += preload/ obj-$(CONFIG_BPF_SYSCALL) += relo_core.o obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o - -# Some source files are common to libbpf. -vpath %.c $(srctree)/kernel/bpf:$(srctree)/tools/lib/bpf - -$(obj)/%.o: %.c FORCE - $(call if_changed_rule,cc_o_c)
kernel/bpf/btf_iter.c new file +2 -0
@@ -0,0 +1,2 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +#include "../../tools/lib/bpf/btf_iter.c"
kernel/bpf/btf_relocate.c new file +2 -0
@@ -0,0 +1,2 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +#include "../../tools/lib/bpf/btf_relocate.c"
kernel/bpf/relo_core.c new file +2 -0
@@ -0,0 +1,2 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +#include "../../tools/lib/bpf/relo_core.c"
Signature · 1 line
2.46.0
Re: [PATCH v4] bpf: Remove custom build rule
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 8 lines · On Fri, 30 Aug 2024 09:43:50 +0200 you wrote:
According to the documentation, when building a kernel with the C=2 parameter, all source files should be checked. But this does not happen for the
kernel/bpf/directory.$ touch kernel/bpf/core.o $ make C=2 CHECK=true kernel/bpf/core.o[...]
Here is the summary with links:
- [v4] bpf: Remove custom build rule
https://git.kernel.org/bpf/bpf-next/c/1dd7622ef508
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html