diff mbox series

[bpf-next,v1] selftests/bpf: Fix wrong binary in Makefile log output

Message ID 20240719232159.2147210-1-tony.ambardar@gmail.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series [bpf-next,v1] selftests/bpf: Fix wrong binary in Makefile log output | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-0 success Logs for Lint
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Unittests
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-3 success Logs for Validate matrix.py
bpf/vmtest-bpf-next-VM_Test-5 success Logs for aarch64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-4 success Logs for aarch64-gcc / build / build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for aarch64-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-12 success Logs for s390x-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-9 success Logs for aarch64-gcc / test (test_verifier, false, 360) / test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for s390x-gcc / build / build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for s390x-gcc / test (test_verifier, false, 360) / test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for s390x-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-34 success Logs for x86_64-llvm-17 / veristat
bpf/vmtest-bpf-next-VM_Test-36 success Logs for x86_64-llvm-18 / build-release / build for x86_64 with llvm-18-O2
bpf/vmtest-bpf-next-VM_Test-35 success Logs for x86_64-llvm-18 / build / build for x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-18 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-42 success Logs for x86_64-llvm-18 / veristat
bpf/vmtest-bpf-next-VM_Test-20 success Logs for x86_64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-28 success Logs for x86_64-llvm-17 / build / build for x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-29 success Logs for x86_64-llvm-17 / build-release / build for x86_64 with llvm-17-O2
bpf/vmtest-bpf-next-VM_Test-19 success Logs for x86_64-gcc / build / build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for aarch64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for x86_64-gcc / test (test_verifier, false, 360) / test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for x86_64-gcc / veristat / veristat on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for aarch64-gcc / test (test_maps, false, 360) / test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-33 success Logs for x86_64-llvm-17 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-7 success Logs for aarch64-gcc / test (test_progs, false, 360) / test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for x86_64-gcc / test (test_maps, false, 360) / test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-37 success Logs for x86_64-llvm-18 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-41 success Logs for x86_64-llvm-18 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-22 success Logs for x86_64-gcc / test (test_progs, false, 360) / test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for x86_64-gcc / test (test_progs_parallel, true, 30) / test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for x86_64-gcc / test (test_progs_no_alu32_parallel, true, 30) / test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for x86_64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for s390x-gcc / test (test_maps, false, 360) / test_maps on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-31 success Logs for x86_64-llvm-17 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-32 success Logs for x86_64-llvm-17 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-39 success Logs for x86_64-llvm-18 / test (test_progs_cpuv4, false, 360) / test_progs_cpuv4 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-40 success Logs for x86_64-llvm-18 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-30 success Logs for x86_64-llvm-17 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-38 success Logs for x86_64-llvm-18 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-14 success Logs for s390x-gcc / test (test_progs, false, 360) / test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for s390x-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on s390x with gcc
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for bpf-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 661 this patch: 661
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 5 maintainers not CCed: nathan@kernel.org llvm@lists.linux.dev justinstitt@google.com morbo@google.com ndesaulniers@google.com
netdev/build_clang success Errors and warnings before: 663 this patch: 663
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 667 this patch: 667
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 47 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Tony Ambardar July 19, 2024, 11:21 p.m. UTC
Make log output incorrectly shows 'test_maps' as the binary name for every
'CLNG-BPF' build step, apparently picking up the last value defined for the
$(TRUNNER_BINARY) variable. Update the 'CLANG_BPF_BUILD_RULE' variants to
fix this confusing output.

Current output:
  CLNG-BPF [test_maps] access_map_in_map.bpf.o
  GEN-SKEL [test_progs] access_map_in_map.skel.h
  ...
  CLNG-BPF [test_maps] access_map_in_map.bpf.o
  GEN-SKEL [test_progs-no_alu32] access_map_in_map.skel.h
  ...
  CLNG-BPF [test_maps] access_map_in_map.bpf.o
  GEN-SKEL [test_progs-cpuv4] access_map_in_map.skel.h

After fix:
  CLNG-BPF [test_progs] access_map_in_map.bpf.o
  GEN-SKEL [test_progs] access_map_in_map.skel.h
  ...
  CLNG-BPF [test_progs-no_alu32] access_map_in_map.bpf.o
  GEN-SKEL [test_progs-no_alu32] access_map_in_map.skel.h
  ...
  CLNG-BPF [test_progs-cpuv4] access_map_in_map.bpf.o
  GEN-SKEL [test_progs-cpuv4] access_map_in_map.skel.h

Fixes: a5d0c26a2784 ("selftests/bpf: Add a cpuv4 test runner for cpu=v4 testing")
Fixes: 89ad7420b25c ("selftests/bpf: Drop the need for LLVM's llc")
Signed-off-by: Tony Ambardar <tony.ambardar@gmail.com>
---
 tools/testing/selftests/bpf/Makefile | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

Comments

bot+bpf-ci@kernel.org July 20, 2024, 12:14 a.m. UTC | #1
Dear patch submitter,

CI has tested the following submission:
Status:     SUCCESS
Name:       [bpf-next,v1] selftests/bpf: Fix wrong binary in Makefile log output
Patchwork:  https://patchwork.kernel.org/project/netdevbpf/list/?series=872629&state=*
Matrix:     https://github.com/kernel-patches/bpf/actions/runs/10015585896

No further action is necessary on your part.


Please note: this email is coming from an unmonitored mailbox. If you have
questions or feedback, please reach out to the Meta Kernel CI team at
kernel-ci@meta.com.
Eduard Zingerman July 20, 2024, 1:23 a.m. UTC | #2
On Fri, 2024-07-19 at 16:21 -0700, Tony Ambardar wrote:

[...]


>  define GCC_BPF_BUILD_RULE
> -	$(call msg,GCC-BPF,$(TRUNNER_BINARY),$2)
> -	$(Q)$(BPF_GCC) $3 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -c $1 -o $2
> +	$(call msg,GCC-BPF,$1,$3)
> +	$(Q)$(BPF_GCC) $4 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -c $2 -o $3
>  endef
>  
>  SKEL_BLACKLIST := btf__% test_pinning_invalid.c test_sk_assign.c
> @@ -534,7 +535,7 @@ $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.bpf.o:				\
>  		     $(wildcard $(BPFDIR)/bpf_*.h)			\
>  		     $(wildcard $(BPFDIR)/*.bpf.h)			\
>  		     | $(TRUNNER_OUTPUT) $$(BPFOBJ)
> -	$$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@,			\
> +	$$(call $(TRUNNER_BPF_BUILD_RULE),$(TRUNNER_BINARY),$$<,$$@,	\

At first I found it quite confusing that we use TRUNNER_BINARY variable in this define,
but can't use it in the CLANG_BPF_BUILD_RULE and co.
However, it looks like this is because of the eval in the (eval (call ...)) pair,
used to invoke DEFINE_TEST_RUNNER_RULES.

Suggested patch works and is probably the simplest fix.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>

>  					  $(TRUNNER_BPF_CFLAGS)         \
>  					  $$($$<-CFLAGS)		\
>  					  $$($$<-$2-CFLAGS))
Andrii Nakryiko July 20, 2024, 2:57 a.m. UTC | #3
On Fri, Jul 19, 2024 at 4:22 PM Tony Ambardar <tony.ambardar@gmail.com> wrote:
>
> Make log output incorrectly shows 'test_maps' as the binary name for every
> 'CLNG-BPF' build step, apparently picking up the last value defined for the
> $(TRUNNER_BINARY) variable. Update the 'CLANG_BPF_BUILD_RULE' variants to
> fix this confusing output.
>
> Current output:
>   CLNG-BPF [test_maps] access_map_in_map.bpf.o
>   GEN-SKEL [test_progs] access_map_in_map.skel.h
>   ...
>   CLNG-BPF [test_maps] access_map_in_map.bpf.o
>   GEN-SKEL [test_progs-no_alu32] access_map_in_map.skel.h
>   ...
>   CLNG-BPF [test_maps] access_map_in_map.bpf.o
>   GEN-SKEL [test_progs-cpuv4] access_map_in_map.skel.h
>
> After fix:
>   CLNG-BPF [test_progs] access_map_in_map.bpf.o
>   GEN-SKEL [test_progs] access_map_in_map.skel.h
>   ...
>   CLNG-BPF [test_progs-no_alu32] access_map_in_map.bpf.o
>   GEN-SKEL [test_progs-no_alu32] access_map_in_map.skel.h
>   ...
>   CLNG-BPF [test_progs-cpuv4] access_map_in_map.bpf.o
>   GEN-SKEL [test_progs-cpuv4] access_map_in_map.skel.h
>
> Fixes: a5d0c26a2784 ("selftests/bpf: Add a cpuv4 test runner for cpu=v4 testing")
> Fixes: 89ad7420b25c ("selftests/bpf: Drop the need for LLVM's llc")
> Signed-off-by: Tony Ambardar <tony.ambardar@gmail.com>
> ---
>  tools/testing/selftests/bpf/Makefile | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 0b4bfbc0ef68..67921e3367dd 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -425,27 +425,28 @@ $(OUTPUT)/flow_dissector_load.o: flow_dissector_load.h
>  $(OUTPUT)/cgroup_getset_retval_hooks.o: cgroup_getset_retval_hooks.h
>
>  # Build BPF object using Clang
> -# $1 - input .c file
> -# $2 - output .o file
> -# $3 - CFLAGS
> +# $1 - binary name
> +# $2 - input .c file
> +# $3 - output .o file
> +# $4 - CFLAGS
>  define CLANG_BPF_BUILD_RULE
> -       $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
> -       $(Q)$(CLANG) $3 -O2 --target=bpf -c $1 -mcpu=v3 -o $2
> +       $(call msg,CLNG-BPF,$1,$3)
> +       $(Q)$(CLANG) $4 -O2 --target=bpf -c $2 -mcpu=v3 -o $3

this works, but did you have to renumber all parameters? Let's maybe
pass this binary name as the 4th argument?

pw-bot: cr

>  endef
>  # Similar to CLANG_BPF_BUILD_RULE, but with disabled alu32
>  define CLANG_NOALU32_BPF_BUILD_RULE
> -       $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
> -       $(Q)$(CLANG) $3 -O2 --target=bpf -c $1 -mcpu=v2 -o $2
> +       $(call msg,CLNG-BPF,$1,$3)
> +       $(Q)$(CLANG) $4 -O2 --target=bpf -c $2 -mcpu=v2 -o $3
>  endef
>  # Similar to CLANG_BPF_BUILD_RULE, but with cpu-v4
>  define CLANG_CPUV4_BPF_BUILD_RULE
> -       $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
> -       $(Q)$(CLANG) $3 -O2 --target=bpf -c $1 -mcpu=v4 -o $2
> +       $(call msg,CLNG-BPF,$1,$3)
> +       $(Q)$(CLANG) $4 -O2 --target=bpf -c $2 -mcpu=v4 -o $3
>  endef
>  # Build BPF object using GCC
>  define GCC_BPF_BUILD_RULE
> -       $(call msg,GCC-BPF,$(TRUNNER_BINARY),$2)
> -       $(Q)$(BPF_GCC) $3 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -c $1 -o $2
> +       $(call msg,GCC-BPF,$1,$3)
> +       $(Q)$(BPF_GCC) $4 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -c $2 -o $3
>  endef
>
>  SKEL_BLACKLIST := btf__% test_pinning_invalid.c test_sk_assign.c
> @@ -534,7 +535,7 @@ $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.bpf.o:                             \
>                      $(wildcard $(BPFDIR)/bpf_*.h)                      \
>                      $(wildcard $(BPFDIR)/*.bpf.h)                      \
>                      | $(TRUNNER_OUTPUT) $$(BPFOBJ)
> -       $$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@,                      \
> +       $$(call $(TRUNNER_BPF_BUILD_RULE),$(TRUNNER_BINARY),$$<,$$@,    \
>                                           $(TRUNNER_BPF_CFLAGS)         \
>                                           $$($$<-CFLAGS)                \
>                                           $$($$<-$2-CFLAGS))
> --
> 2.34.1
>
Tony Ambardar July 20, 2024, 5:23 a.m. UTC | #4
On Fri, Jul 19, 2024 at 07:57:09PM -0700, Andrii Nakryiko wrote:
> On Fri, Jul 19, 2024 at 4:22 PM Tony Ambardar <tony.ambardar@gmail.com> wrote:
> >
> > Make log output incorrectly shows 'test_maps' as the binary name for every
> > 'CLNG-BPF' build step, apparently picking up the last value defined for the
> > $(TRUNNER_BINARY) variable. Update the 'CLANG_BPF_BUILD_RULE' variants to
> > fix this confusing output.
> >
> > Current output:
> >   CLNG-BPF [test_maps] access_map_in_map.bpf.o
> >   GEN-SKEL [test_progs] access_map_in_map.skel.h
> >   ...
> >   CLNG-BPF [test_maps] access_map_in_map.bpf.o
> >   GEN-SKEL [test_progs-no_alu32] access_map_in_map.skel.h
> >   ...
> >   CLNG-BPF [test_maps] access_map_in_map.bpf.o
> >   GEN-SKEL [test_progs-cpuv4] access_map_in_map.skel.h
> >
> > After fix:
> >   CLNG-BPF [test_progs] access_map_in_map.bpf.o
> >   GEN-SKEL [test_progs] access_map_in_map.skel.h
> >   ...
> >   CLNG-BPF [test_progs-no_alu32] access_map_in_map.bpf.o
> >   GEN-SKEL [test_progs-no_alu32] access_map_in_map.skel.h
> >   ...
> >   CLNG-BPF [test_progs-cpuv4] access_map_in_map.bpf.o
> >   GEN-SKEL [test_progs-cpuv4] access_map_in_map.skel.h
> >
> > Fixes: a5d0c26a2784 ("selftests/bpf: Add a cpuv4 test runner for cpu=v4 testing")
> > Fixes: 89ad7420b25c ("selftests/bpf: Drop the need for LLVM's llc")
> > Signed-off-by: Tony Ambardar <tony.ambardar@gmail.com>
> > ---
> >  tools/testing/selftests/bpf/Makefile | 25 +++++++++++++------------
> >  1 file changed, 13 insertions(+), 12 deletions(-)
> >
> > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> > index 0b4bfbc0ef68..67921e3367dd 100644
> > --- a/tools/testing/selftests/bpf/Makefile
> > +++ b/tools/testing/selftests/bpf/Makefile
> > @@ -425,27 +425,28 @@ $(OUTPUT)/flow_dissector_load.o: flow_dissector_load.h
> >  $(OUTPUT)/cgroup_getset_retval_hooks.o: cgroup_getset_retval_hooks.h
> >
> >  # Build BPF object using Clang
> > -# $1 - input .c file
> > -# $2 - output .o file
> > -# $3 - CFLAGS
> > +# $1 - binary name
> > +# $2 - input .c file
> > +# $3 - output .o file
> > +# $4 - CFLAGS
> >  define CLANG_BPF_BUILD_RULE
> > -       $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
> > -       $(Q)$(CLANG) $3 -O2 --target=bpf -c $1 -mcpu=v3 -o $2
> > +       $(call msg,CLNG-BPF,$1,$3)
> > +       $(Q)$(CLANG) $4 -O2 --target=bpf -c $2 -mcpu=v3 -o $3
> 
> this works, but did you have to renumber all parameters? Let's maybe
> pass this binary name as the 4th argument?
> 

OK, I'll update as requested and minimize the diff.

> pw-bot: cr
> 
> >  endef
> >  # Similar to CLANG_BPF_BUILD_RULE, but with disabled alu32
> >  define CLANG_NOALU32_BPF_BUILD_RULE
> > -       $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
> > -       $(Q)$(CLANG) $3 -O2 --target=bpf -c $1 -mcpu=v2 -o $2
> > +       $(call msg,CLNG-BPF,$1,$3)
> > +       $(Q)$(CLANG) $4 -O2 --target=bpf -c $2 -mcpu=v2 -o $3
> >  endef
> >  # Similar to CLANG_BPF_BUILD_RULE, but with cpu-v4
> >  define CLANG_CPUV4_BPF_BUILD_RULE
> > -       $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
> > -       $(Q)$(CLANG) $3 -O2 --target=bpf -c $1 -mcpu=v4 -o $2
> > +       $(call msg,CLNG-BPF,$1,$3)
> > +       $(Q)$(CLANG) $4 -O2 --target=bpf -c $2 -mcpu=v4 -o $3
> >  endef
> >  # Build BPF object using GCC
> >  define GCC_BPF_BUILD_RULE
> > -       $(call msg,GCC-BPF,$(TRUNNER_BINARY),$2)
> > -       $(Q)$(BPF_GCC) $3 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -c $1 -o $2
> > +       $(call msg,GCC-BPF,$1,$3)
> > +       $(Q)$(BPF_GCC) $4 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -c $2 -o $3
> >  endef
> >
> >  SKEL_BLACKLIST := btf__% test_pinning_invalid.c test_sk_assign.c
> > @@ -534,7 +535,7 @@ $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.bpf.o:                             \
> >                      $(wildcard $(BPFDIR)/bpf_*.h)                      \
> >                      $(wildcard $(BPFDIR)/*.bpf.h)                      \
> >                      | $(TRUNNER_OUTPUT) $$(BPFOBJ)
> > -       $$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@,                      \
> > +       $$(call $(TRUNNER_BPF_BUILD_RULE),$(TRUNNER_BINARY),$$<,$$@,    \
> >                                           $(TRUNNER_BPF_CFLAGS)         \
> >                                           $$($$<-CFLAGS)                \
> >                                           $$($$<-$2-CFLAGS))
> > --
> > 2.34.1
> >
Tony Ambardar July 23, 2024, 1:35 a.m. UTC | #5
On Fri, Jul 19, 2024 at 10:23:33PM -0700, Tony Ambardar wrote:
> On Fri, Jul 19, 2024 at 07:57:09PM -0700, Andrii Nakryiko wrote:
> > On Fri, Jul 19, 2024 at 4:22 PM Tony Ambardar <tony.ambardar@gmail.com> wrote:
> > >

[...]

> > > --- a/tools/testing/selftests/bpf/Makefile
> > > +++ b/tools/testing/selftests/bpf/Makefile
> > > @@ -425,27 +425,28 @@ $(OUTPUT)/flow_dissector_load.o: flow_dissector_load.h
> > >  $(OUTPUT)/cgroup_getset_retval_hooks.o: cgroup_getset_retval_hooks.h
> > >
> > >  # Build BPF object using Clang
> > > -# $1 - input .c file
> > > -# $2 - output .o file
> > > -# $3 - CFLAGS
> > > +# $1 - binary name
> > > +# $2 - input .c file
> > > +# $3 - output .o file
> > > +# $4 - CFLAGS
> > >  define CLANG_BPF_BUILD_RULE
> > > -       $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
> > > -       $(Q)$(CLANG) $3 -O2 --target=bpf -c $1 -mcpu=v3 -o $2
> > > +       $(call msg,CLNG-BPF,$1,$3)
> > > +       $(Q)$(CLANG) $4 -O2 --target=bpf -c $2 -mcpu=v3 -o $3
> > 
> > this works, but did you have to renumber all parameters? Let's maybe
> > pass this binary name as the 4th argument?
> > 
> 
> OK, I'll update as requested and minimize the diff.
> 
Hi Andrii,

I sent out a v2 based on your suggestions but omitted Eduard's Acked-by:
by mistake. Should I resubmit or is that something you can update?

Thanks,
Tony
> > pw-bot: cr
> > 
> > >  endef
> > >  # Similar to CLANG_BPF_BUILD_RULE, but with disabled alu32
> > >  define CLANG_NOALU32_BPF_BUILD_RULE
> > > -       $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
> > > -       $(Q)$(CLANG) $3 -O2 --target=bpf -c $1 -mcpu=v2 -o $2
> > > +       $(call msg,CLNG-BPF,$1,$3)
> > > +       $(Q)$(CLANG) $4 -O2 --target=bpf -c $2 -mcpu=v2 -o $3
> > >  endef
> > >  # Similar to CLANG_BPF_BUILD_RULE, but with cpu-v4
> > >  define CLANG_CPUV4_BPF_BUILD_RULE
> > > -       $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
> > > -       $(Q)$(CLANG) $3 -O2 --target=bpf -c $1 -mcpu=v4 -o $2
> > > +       $(call msg,CLNG-BPF,$1,$3)
> > > +       $(Q)$(CLANG) $4 -O2 --target=bpf -c $2 -mcpu=v4 -o $3
> > >  endef
> > >  # Build BPF object using GCC
> > >  define GCC_BPF_BUILD_RULE
> > > -       $(call msg,GCC-BPF,$(TRUNNER_BINARY),$2)
> > > -       $(Q)$(BPF_GCC) $3 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -c $1 -o $2
> > > +       $(call msg,GCC-BPF,$1,$3)
> > > +       $(Q)$(BPF_GCC) $4 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -c $2 -o $3
> > >  endef
> > >
> > >  SKEL_BLACKLIST := btf__% test_pinning_invalid.c test_sk_assign.c
> > > @@ -534,7 +535,7 @@ $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.bpf.o:                             \
> > >                      $(wildcard $(BPFDIR)/bpf_*.h)                      \
> > >                      $(wildcard $(BPFDIR)/*.bpf.h)                      \
> > >                      | $(TRUNNER_OUTPUT) $$(BPFOBJ)
> > > -       $$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@,                      \
> > > +       $$(call $(TRUNNER_BPF_BUILD_RULE),$(TRUNNER_BINARY),$$<,$$@,    \
> > >                                           $(TRUNNER_BPF_CFLAGS)         \
> > >                                           $$($$<-CFLAGS)                \
> > >                                           $$($$<-$2-CFLAGS))
> > > --
> > > 2.34.1
> > >
Eduard Zingerman July 23, 2024, 1:37 a.m. UTC | #6
On Mon, 2024-07-22 at 18:35 -0700, Tony Ambardar wrote:
[...]

> Hi Andrii,
> 
> I sent out a v2 based on your suggestions but omitted Eduard's Acked-by:
> by mistake. Should I resubmit or is that something you can update?

That's fine, don't bother.

[...]
Andrii Nakryiko July 23, 2024, 8:28 p.m. UTC | #7
On Mon, Jul 22, 2024 at 6:37 PM Eduard Zingerman <eddyz87@gmail.com> wrote:
>
> On Mon, 2024-07-22 at 18:35 -0700, Tony Ambardar wrote:
> [...]
>
> > Hi Andrii,
> >
> > I sent out a v2 based on your suggestions but omitted Eduard's Acked-by:
> > by mistake. Should I resubmit or is that something you can update?
>
> That's fine, don't bother.
>

Added it while applying.

> [...]
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 0b4bfbc0ef68..67921e3367dd 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -425,27 +425,28 @@  $(OUTPUT)/flow_dissector_load.o: flow_dissector_load.h
 $(OUTPUT)/cgroup_getset_retval_hooks.o: cgroup_getset_retval_hooks.h
 
 # Build BPF object using Clang
-# $1 - input .c file
-# $2 - output .o file
-# $3 - CFLAGS
+# $1 - binary name
+# $2 - input .c file
+# $3 - output .o file
+# $4 - CFLAGS
 define CLANG_BPF_BUILD_RULE
-	$(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
-	$(Q)$(CLANG) $3 -O2 --target=bpf -c $1 -mcpu=v3 -o $2
+	$(call msg,CLNG-BPF,$1,$3)
+	$(Q)$(CLANG) $4 -O2 --target=bpf -c $2 -mcpu=v3 -o $3
 endef
 # Similar to CLANG_BPF_BUILD_RULE, but with disabled alu32
 define CLANG_NOALU32_BPF_BUILD_RULE
-	$(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
-	$(Q)$(CLANG) $3 -O2 --target=bpf -c $1 -mcpu=v2 -o $2
+	$(call msg,CLNG-BPF,$1,$3)
+	$(Q)$(CLANG) $4 -O2 --target=bpf -c $2 -mcpu=v2 -o $3
 endef
 # Similar to CLANG_BPF_BUILD_RULE, but with cpu-v4
 define CLANG_CPUV4_BPF_BUILD_RULE
-	$(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
-	$(Q)$(CLANG) $3 -O2 --target=bpf -c $1 -mcpu=v4 -o $2
+	$(call msg,CLNG-BPF,$1,$3)
+	$(Q)$(CLANG) $4 -O2 --target=bpf -c $2 -mcpu=v4 -o $3
 endef
 # Build BPF object using GCC
 define GCC_BPF_BUILD_RULE
-	$(call msg,GCC-BPF,$(TRUNNER_BINARY),$2)
-	$(Q)$(BPF_GCC) $3 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -c $1 -o $2
+	$(call msg,GCC-BPF,$1,$3)
+	$(Q)$(BPF_GCC) $4 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -c $2 -o $3
 endef
 
 SKEL_BLACKLIST := btf__% test_pinning_invalid.c test_sk_assign.c
@@ -534,7 +535,7 @@  $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.bpf.o:				\
 		     $(wildcard $(BPFDIR)/bpf_*.h)			\
 		     $(wildcard $(BPFDIR)/*.bpf.h)			\
 		     | $(TRUNNER_OUTPUT) $$(BPFOBJ)
-	$$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@,			\
+	$$(call $(TRUNNER_BPF_BUILD_RULE),$(TRUNNER_BINARY),$$<,$$@,	\
 					  $(TRUNNER_BPF_CFLAGS)         \
 					  $$($$<-CFLAGS)		\
 					  $$($$<-$2-CFLAGS))