diff mbox series

[bpf] selftests: bpf: fix makefile dependencies on libbpf

Message ID ee84ab66436fba05a197f952af23c98d90eb6243.1632758415.git.jbenc@redhat.com (mailing list archive)
State Accepted
Delegated to: BPF
Headers show
Series [bpf] selftests: bpf: fix makefile dependencies on libbpf | expand

Checks

Context Check Description
bpf/vmtest-bpf-PR fail PR summary
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf
netdev/subject_prefix success Link
netdev/cc_maintainers warning 7 maintainers not CCed: kpsingh@kernel.org shuah@kernel.org kafai@fb.com linux-kselftest@vger.kernel.org john.fastabend@gmail.com yhs@fb.com songliubraving@fb.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 2 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 0
netdev/header_inline success Link
bpf/vmtest-bpf fail VM_Test

Commit Message

Jiri Benc Sept. 27, 2021, 4:01 p.m. UTC
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(-)

Comments

Andrii Nakryiko Sept. 28, 2021, 4:53 a.m. UTC | #1
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
>
diff mbox series

Patch

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