* [PATCH] selftests net: additional fix for kselftest net build error
@ 2022-11-14 20:34 Andrea Righi
2022-11-17 23:06 ` Andrii Nakryiko
0 siblings, 1 reply; 2+ messages in thread
From: Andrea Righi @ 2022-11-14 20:34 UTC (permalink / raw)
To: Shuah Khan
Cc: Paolo Abeni, Coleman Dietsch, Lina Wang, Kamal Mostafa,
linux-kselftest, netdev, bpf, linux-kernel
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)
$(OUTPUT)/%.o: %.c
$(CLANG) -O2 -target bpf -c $< $(CCINCLUDE) -o $@
--
2.37.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] selftests net: additional fix for kselftest net build error
2022-11-14 20:34 [PATCH] selftests net: additional fix for kselftest net build error Andrea Righi
@ 2022-11-17 23:06 ` Andrii Nakryiko
0 siblings, 0 replies; 2+ messages in thread
From: Andrii Nakryiko @ 2022-11-17 23:06 UTC (permalink / raw)
To: Andrea Righi
Cc: Shuah Khan, Paolo Abeni, Coleman Dietsch, Lina Wang,
Kamal Mostafa, linux-kselftest, netdev, bpf, linux-kernel
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-17 23:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14 20:34 [PATCH] selftests net: additional fix for kselftest net build error Andrea Righi
2022-11-17 23:06 ` 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).