Skip to content

Commit

Permalink
selftests/bpf: Make selftest compilation work on clang 11
Browse files Browse the repository at this point in the history
We can't compile test_core_reloc_module.c selftest with clang 11, compile
fails with:

  CLNG-LLC [test_maps] test_core_reloc_module.o
  progs/test_core_reloc_module.c:57:21: error: use of unknown builtin \
  '__builtin_preserve_type_info' [-Wimplicit-function-declaration]
   out->read_ctx_sz = bpf_core_type_size(struct bpf_testmod_test_read_ctx);

Skipping these tests if __builtin_preserve_type_info() is not supported
by compiler.

Signed-off-by: Jiri Olsa <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
olsajiri authored and borkmann committed Dec 10, 2020
1 parent 7535a35 commit 41003dd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tools/testing/selftests/bpf/progs/test_core_reloc_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ int BPF_PROG(test_core_module_probed,
struct task_struct *task,
struct bpf_testmod_test_read_ctx *read_ctx)
{
#if __has_builtin(__builtin_preserve_enum_value)
struct core_reloc_module_output *out = (void *)&data.out;
__u64 pid_tgid = bpf_get_current_pid_tgid();
__u32 real_tgid = (__u32)(pid_tgid >> 32);
Expand All @@ -61,6 +62,9 @@ int BPF_PROG(test_core_module_probed,
out->len_exists = bpf_core_field_exists(read_ctx->len);

out->comm_len = BPF_CORE_READ_STR_INTO(&out->comm, task, comm);
#else
data.skip = true;
#endif

return 0;
}
Expand All @@ -70,6 +74,7 @@ int BPF_PROG(test_core_module_direct,
struct task_struct *task,
struct bpf_testmod_test_read_ctx *read_ctx)
{
#if __has_builtin(__builtin_preserve_enum_value)
struct core_reloc_module_output *out = (void *)&data.out;
__u64 pid_tgid = bpf_get_current_pid_tgid();
__u32 real_tgid = (__u32)(pid_tgid >> 32);
Expand All @@ -91,6 +96,9 @@ int BPF_PROG(test_core_module_direct,
out->len_exists = bpf_core_field_exists(read_ctx->len);

out->comm_len = BPF_CORE_READ_STR_INTO(&out->comm, task, comm);
#else
data.skip = true;
#endif

return 0;
}

0 comments on commit 41003dd

Please sign in to comment.