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

Eduard Zingerman
2024-07-20T01:23:55Z

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))