diff mbox series

selftests net: additional fix for kselftest net build error

Message ID 20221114203431.302655-1-andrea.righi@canonical.com
State New
Headers show
Series selftests net: additional fix for kselftest net build error | expand

Commit Message

Andrea Righi Nov. 14, 2022, 8:34 p.m. UTC
We need to make sure that bpf_helpers.h is properly generated when
building the net kselftest, otherwise we get this build error:

 $ make -C tools/testing/selftests/net
 ...
 bpf/nat6to4.c:43:10: fatal error: 'bpf/bpf_helpers.h' file not found
          ^~~~~~~~~~~~~~~~~~~
 1 error generated.

Fix by adding a make dependency on tools/lib/bpf/bpf_helper_defs.h.

Moreover, re-add the include that was initially added by commit
cf67838c4422 ("selftests net: fix bpf build error"), otherwise we won't
be able to properly include bpf_helpers.h.

Fixes: 7b92aa9e6135 ("selftests net: fix kselftest net fatal error")
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
---
 tools/testing/selftests/net/bpf/Makefile | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Andrii Nakryiko Nov. 17, 2022, 11:06 p.m. UTC | #1
On Mon, Nov 14, 2022 at 12:39 PM Andrea Righi
<andrea.righi@canonical.com> wrote:
>
> We need to make sure that bpf_helpers.h is properly generated when
> building the net kselftest, otherwise we get this build error:
>
>  $ make -C tools/testing/selftests/net
>  ...
>  bpf/nat6to4.c:43:10: fatal error: 'bpf/bpf_helpers.h' file not found
>           ^~~~~~~~~~~~~~~~~~~
>  1 error generated.
>
> Fix by adding a make dependency on tools/lib/bpf/bpf_helper_defs.h.
>
> Moreover, re-add the include that was initially added by commit
> cf67838c4422 ("selftests net: fix bpf build error"), otherwise we won't
> be able to properly include bpf_helpers.h.
>
> Fixes: 7b92aa9e6135 ("selftests net: fix kselftest net fatal error")
> Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
> ---
>  tools/testing/selftests/net/bpf/Makefile | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/net/bpf/Makefile b/tools/testing/selftests/net/bpf/Makefile
> index 8ccaf8732eb2..cc6579e154eb 100644
> --- a/tools/testing/selftests/net/bpf/Makefile
> +++ b/tools/testing/selftests/net/bpf/Makefile
> @@ -2,11 +2,15 @@
>
>  CLANG ?= clang
>  CCINCLUDE += -I../../bpf
> +CCINCLUDE += -I../../../lib
>  CCINCLUDE += -I../../../../lib
>  CCINCLUDE += -I../../../../../usr/include/
>
> +bpf_helper_defs.h:
> +       @make OUTPUT=./ -C $(OUTPUT)/../../../../tools/lib/bpf bpf_helper_defs.h
> +
>  TEST_CUSTOM_PROGS = $(OUTPUT)/bpf/nat6to4.o
> -all: $(TEST_CUSTOM_PROGS)
> +all: bpf_helper_defs.h $(TEST_CUSTOM_PROGS)

it would be better to call libbpf's install_headers target instead to
generate and install API headers only

>
>  $(OUTPUT)/%.o: %.c
>         $(CLANG) -O2 -target bpf -c $< $(CCINCLUDE) -o $@
> --
> 2.37.2
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/bpf/Makefile b/tools/testing/selftests/net/bpf/Makefile
index 8ccaf8732eb2..cc6579e154eb 100644
--- a/tools/testing/selftests/net/bpf/Makefile
+++ b/tools/testing/selftests/net/bpf/Makefile
@@ -2,11 +2,15 @@ 
 
 CLANG ?= clang
 CCINCLUDE += -I../../bpf
+CCINCLUDE += -I../../../lib
 CCINCLUDE += -I../../../../lib
 CCINCLUDE += -I../../../../../usr/include/
 
+bpf_helper_defs.h:
+	@make OUTPUT=./ -C $(OUTPUT)/../../../../tools/lib/bpf bpf_helper_defs.h
+
 TEST_CUSTOM_PROGS = $(OUTPUT)/bpf/nat6to4.o
-all: $(TEST_CUSTOM_PROGS)
+all: bpf_helper_defs.h $(TEST_CUSTOM_PROGS)
 
 $(OUTPUT)/%.o: %.c
 	$(CLANG) -O2 -target bpf -c $< $(CCINCLUDE) -o $@