netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] selftests: bpf: fix makefile dependencies on libbpf
@ 2021-09-27 16:01 Jiri Benc
  2021-09-28  4:53 ` Andrii Nakryiko
  0 siblings, 1 reply; 2+ messages in thread
From: Jiri Benc @ 2021-09-27 16:01 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Andrii Nakryiko, netdev

When building bpf selftest with make -j, I'm randomly getting build failures
such as this one:

> In file included from progs/bpf_flow.c:19:
> [...]/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:11:10: fatal error: 'bpf_helper_defs.h' file not found
> #include "bpf_helper_defs.h"
>          ^~~~~~~~~~~~~~~~~~~

The file that fails the build varies between runs but it's always in the
progs/ subdir.

The reason is a missing make dependency on libbpf for the .o files in
progs/. There was a dependency before commit 3ac2e20fba07e but that commit
removed it to prevent unneeded rebuilds. However, that only works if libbpf
has been built already; the 'wildcard' prerequisite does not trigger when
there's no bpf_helper_defs.h generated yet.

Keep the libbpf as an order-only prerequisite to satisfy both goals. It is
always built before the progs/ objects but it does not trigger unnecessary
rebuilds by itself.

Fixes: 3ac2e20fba07e ("selftests/bpf: BPF object files should depend only on libbpf headers")
Signed-off-by: Jiri Benc <jbenc@redhat.com>
---
 tools/testing/selftests/bpf/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 866531c08e4f..e7c42695dbbf 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -375,7 +375,8 @@ $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.o:				\
 		     $(TRUNNER_BPF_PROGS_DIR)/%.c			\
 		     $(TRUNNER_BPF_PROGS_DIR)/*.h			\
 		     $$(INCLUDE_DIR)/vmlinux.h				\
-		     $(wildcard $(BPFDIR)/bpf_*.h) | $(TRUNNER_OUTPUT)
+		     $(wildcard $(BPFDIR)/bpf_*.h) | $(TRUNNER_OUTPUT)	\
+		     $$(BPFOBJ)
 	$$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@,			\
 					  $(TRUNNER_BPF_CFLAGS))
 
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf] selftests: bpf: fix makefile dependencies on libbpf
  2021-09-27 16:01 [PATCH bpf] selftests: bpf: fix makefile dependencies on libbpf Jiri Benc
@ 2021-09-28  4:53 ` Andrii Nakryiko
  0 siblings, 0 replies; 2+ messages in thread
From: Andrii Nakryiko @ 2021-09-28  4:53 UTC (permalink / raw)
  To: Jiri Benc
  Cc: bpf, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Andrii Nakryiko, Networking

On Mon, Sep 27, 2021 at 9:02 AM Jiri Benc <jbenc@redhat.com> wrote:
>
> When building bpf selftest with make -j, I'm randomly getting build failures
> such as this one:
>
> > In file included from progs/bpf_flow.c:19:
> > [...]/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:11:10: fatal error: 'bpf_helper_defs.h' file not found
> > #include "bpf_helper_defs.h"
> >          ^~~~~~~~~~~~~~~~~~~
>
> The file that fails the build varies between runs but it's always in the
> progs/ subdir.
>
> The reason is a missing make dependency on libbpf for the .o files in
> progs/. There was a dependency before commit 3ac2e20fba07e but that commit
> removed it to prevent unneeded rebuilds. However, that only works if libbpf
> has been built already; the 'wildcard' prerequisite does not trigger when
> there's no bpf_helper_defs.h generated yet.
>
> Keep the libbpf as an order-only prerequisite to satisfy both goals. It is
> always built before the progs/ objects but it does not trigger unnecessary
> rebuilds by itself.
>
> Fixes: 3ac2e20fba07e ("selftests/bpf: BPF object files should depend only on libbpf headers")
> Signed-off-by: Jiri Benc <jbenc@redhat.com>
> ---
>  tools/testing/selftests/bpf/Makefile | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 866531c08e4f..e7c42695dbbf 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -375,7 +375,8 @@ $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.o:                         \
>                      $(TRUNNER_BPF_PROGS_DIR)/%.c                       \
>                      $(TRUNNER_BPF_PROGS_DIR)/*.h                       \
>                      $$(INCLUDE_DIR)/vmlinux.h                          \
> -                    $(wildcard $(BPFDIR)/bpf_*.h) | $(TRUNNER_OUTPUT)
> +                    $(wildcard $(BPFDIR)/bpf_*.h) | $(TRUNNER_OUTPUT)  \
> +                    $$(BPFOBJ)


I've moved `| $(TRUNNER_OUTPUT)` into this new line so it's more
obvious that both are order-only prerequisites. Applied to bpf,
thanks.

>         $$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@,                      \
>                                           $(TRUNNER_BPF_CFLAGS))
>
> --
> 2.18.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-28  4:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 16:01 [PATCH bpf] selftests: bpf: fix makefile dependencies on libbpf Jiri Benc
2021-09-28  4:53 ` Andrii Nakryiko

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