linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/bpf: Elide a check for LLVM versions that can't compile it
@ 2020-01-24 18:08 Palmer Dabbelt
  2020-01-24 20:27 ` Toke Høiland-Jørgensen
  0 siblings, 1 reply; 3+ messages in thread
From: Palmer Dabbelt @ 2020-01-24 18:08 UTC (permalink / raw)
  To: linux-kselftest, netdev, bpf
  Cc: shuah, ast, daniel, kafai, songliubraving, yhs, andriin,
	john.fastabend, Palmer Dabbelt, linux-kernel, clang-built-linux,
	kernel-team

The current stable LLVM BPF backend fails to compile the BPF selftests
due to a compiler bug.  The bug has been fixed in trunk, but that fix
hasn't landed in the binary packages I'm using yet (Fedora arm64).
Without this workaround the tests don't compile for me.

This patch triggers a preprocessor warning on LLVM versions that
definitely have the bug.  The test may be conservative (ie, I'm not sure
if 9.1 will have the fix), but it should at least make the current set
of stable releases work together.

See https://reviews.llvm.org/D69438 for more information on the fix.  I
obtained the workaround from
https://lore.kernel.org/linux-kselftest/aed8eda7-df20-069b-ea14-f06628984566@gmail.com/T/

Fixes: 20a9ad2e7136 ("selftests/bpf: add CO-RE relocs array tests")
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
---
 .../testing/selftests/bpf/progs/test_core_reloc_arrays.c  | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/testing/selftests/bpf/progs/test_core_reloc_arrays.c b/tools/testing/selftests/bpf/progs/test_core_reloc_arrays.c
index 89951b684282..e5eafdab80a4 100644
--- a/tools/testing/selftests/bpf/progs/test_core_reloc_arrays.c
+++ b/tools/testing/selftests/bpf/progs/test_core_reloc_arrays.c
@@ -43,15 +43,23 @@ int test_core_arrays(void *ctx)
 	/* in->a[2] */
 	if (CORE_READ(&out->a2, &in->a[2]))
 		return 1;
+#if defined(__clang__) && (__clang_major__ < 10) && (__clang_minor__ < 1)
+# warning "clang 9.0 SEGVs on multidimensional arrays, see https://reviews.llvm.org/D69438"
+#else
 	/* in->b[1][2][3] */
 	if (CORE_READ(&out->b123, &in->b[1][2][3]))
 		return 1;
+#endif
 	/* in->c[1].c */
 	if (CORE_READ(&out->c1c, &in->c[1].c))
 		return 1;
+#if defined(__clang__) && (__clang_major__ < 10) && (__clang_minor__ < 1)
+# warning "clang 9.0 SEGVs on multidimensional arrays, see https://reviews.llvm.org/D69438"
+#else
 	/* in->d[0][0].d */
 	if (CORE_READ(&out->d00d, &in->d[0][0].d))
 		return 1;
+#endif
 
 	return 0;
 }
-- 
2.25.0.341.g760bfbb309-goog


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

* Re: [PATCH] selftests/bpf: Elide a check for LLVM versions that can't compile it
  2020-01-24 18:08 [PATCH] selftests/bpf: Elide a check for LLVM versions that can't compile it Palmer Dabbelt
@ 2020-01-24 20:27 ` Toke Høiland-Jørgensen
  2020-01-27 11:09   ` Daniel Borkmann
  0 siblings, 1 reply; 3+ messages in thread
From: Toke Høiland-Jørgensen @ 2020-01-24 20:27 UTC (permalink / raw)
  To: Palmer Dabbelt, linux-kselftest, netdev, bpf
  Cc: shuah, ast, daniel, kafai, songliubraving, yhs, andriin,
	john.fastabend, Palmer Dabbelt, linux-kernel, clang-built-linux,
	kernel-team, Jesper Dangaard Brouer

Palmer Dabbelt <palmerdabbelt@google.com> writes:

> The current stable LLVM BPF backend fails to compile the BPF selftests
> due to a compiler bug.  The bug has been fixed in trunk, but that fix
> hasn't landed in the binary packages I'm using yet (Fedora arm64).
> Without this workaround the tests don't compile for me.
>
> This patch triggers a preprocessor warning on LLVM versions that
> definitely have the bug.  The test may be conservative (ie, I'm not sure
> if 9.1 will have the fix), but it should at least make the current set
> of stable releases work together.
>
> See https://reviews.llvm.org/D69438 for more information on the fix.  I
> obtained the workaround from
> https://lore.kernel.org/linux-kselftest/aed8eda7-df20-069b-ea14-f06628984566@gmail.com/T/
>
> Fixes: 20a9ad2e7136 ("selftests/bpf: add CO-RE relocs array tests")
> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>

Having to depend on the latest trunk llvm to compile the selftests is
definitely unfortunate. I believe there are some tests that won't work
at all without trunk llvm (the fentry/fexit stuff comes to mind;
although I'm not sure if they'll fail to compile, just fail to run?).
Could we extend this type of checking to any such case?

-Toke


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

* Re: [PATCH] selftests/bpf: Elide a check for LLVM versions that can't compile it
  2020-01-24 20:27 ` Toke Høiland-Jørgensen
@ 2020-01-27 11:09   ` Daniel Borkmann
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2020-01-27 11:09 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen, Palmer Dabbelt,
	linux-kselftest, netdev, bpf
  Cc: shuah, ast, kafai, songliubraving, yhs, andriin, john.fastabend,
	linux-kernel, clang-built-linux, kernel-team,
	Jesper Dangaard Brouer

On 1/24/20 9:27 PM, Toke Høiland-Jørgensen wrote:
> Palmer Dabbelt <palmerdabbelt@google.com> writes:
> 
>> The current stable LLVM BPF backend fails to compile the BPF selftests
>> due to a compiler bug.  The bug has been fixed in trunk, but that fix
>> hasn't landed in the binary packages I'm using yet (Fedora arm64).
>> Without this workaround the tests don't compile for me.
>>
>> This patch triggers a preprocessor warning on LLVM versions that
>> definitely have the bug.  The test may be conservative (ie, I'm not sure
>> if 9.1 will have the fix), but it should at least make the current set
>> of stable releases work together.
>>
>> See https://reviews.llvm.org/D69438 for more information on the fix.  I
>> obtained the workaround from
>> https://lore.kernel.org/linux-kselftest/aed8eda7-df20-069b-ea14-f06628984566@gmail.com/T/
>>
>> Fixes: 20a9ad2e7136 ("selftests/bpf: add CO-RE relocs array tests")
>> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
> 
> Having to depend on the latest trunk llvm to compile the selftests is
> definitely unfortunate. I believe there are some tests that won't work
> at all without trunk llvm (the fentry/fexit stuff comes to mind;
> although I'm not sure if they'll fail to compile, just fail to run?).
> Could we extend this type of checking to any such case?

Yeah, Palmer, are you saying that with this fix you're able to run through
all of the BPF test suite on bpf-next with clang/llvm 9.0?

So far policy has been that tests run always on latest trunk to also cover
llvm changes in BPF backend to make sure there are no regressions there. OT:
perhaps we should have a 'make deps' target in BPF selftests to make it easier
for developers to spin up a latest test env to run selftests in.

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

end of thread, other threads:[~2020-01-27 11:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-24 18:08 [PATCH] selftests/bpf: Elide a check for LLVM versions that can't compile it Palmer Dabbelt
2020-01-24 20:27 ` Toke Høiland-Jørgensen
2020-01-27 11:09   ` Daniel Borkmann

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