Skip to content

Commit

Permalink
selftests/bpf: List newest Clang built-ins needed for some CO-RE self…
Browse files Browse the repository at this point in the history
…tests

Record which built-ins are optional and needed for some of recent BPF CO-RE
subtests. Document Clang diff that fixed corner-case issue with
__builtin_btf_type_id().

Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20200820061411.1755905-4-andriin@fb.com
  • Loading branch information
Andrii Nakryiko authored and Daniel Borkmann committed Aug 20, 2020
1 parent 37a6a9e commit 149cb33
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
21 changes: 21 additions & 0 deletions tools/testing/selftests/bpf/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,24 @@ This is due to a llvm BPF backend bug. The fix
https://reviews.llvm.org/D78466
has been pushed to llvm 10.x release branch and will be
available in 10.0.1. The fix is available in llvm 11.0.0 trunk.

BPF CO-RE-based tests and Clang version
=======================================

A set of selftests use BPF target-specific built-ins, which might require
bleeding-edge Clang versions (Clang 12 nightly at this time).

Few sub-tests of core_reloc test suit (part of test_progs test runner) require
the following built-ins, listed with corresponding Clang diffs introducing
them to Clang/LLVM. These sub-tests are going to be skipped if Clang is too
old to support them, they shouldn't cause build failures or runtime test
failures:

- __builtin_btf_type_id() ([0], [1], [2]);
- __builtin_preserve_type_info(), __builtin_preserve_enum_value() ([3], [4]).

[0] https://reviews.llvm.org/D74572
[1] https://reviews.llvm.org/D74668
[2] https://reviews.llvm.org/D85174
[3] https://reviews.llvm.org/D83878
[4] https://reviews.llvm.org/D83242
4 changes: 3 additions & 1 deletion tools/testing/selftests/bpf/progs/test_core_reloc_type_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ int test_core_type_id(void *ctx)
{
/* We use __builtin_btf_type_id() in this tests, but up until the time
* __builtin_preserve_type_info() was added it contained a bug that
* would make this test fail. The bug was fixed with addition of
* would make this test fail. The bug was fixed ([0]) with addition of
* __builtin_preserve_type_info(), though, so that's what we are using
* to detect whether this test has to be executed, however strange
* that might look like.
*
* [0] https://reviews.llvm.org/D85174
*/
#if __has_builtin(__builtin_preserve_type_info)
struct core_reloc_type_id_output *out = (void *)&data.out;
Expand Down

0 comments on commit 149cb33

Please sign in to comment.