Skip to content

Commit 41003dd

Browse files
olsajiriborkmann
authored andcommitted
selftests/bpf: Make selftest compilation work on clang 11
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 <jolsa@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20201209142912.99145-1-jolsa@kernel.org
1 parent 7535a35 commit 41003dd

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎tools/testing/selftests/bpf/progs/test_core_reloc_module.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ int BPF_PROG(test_core_module_probed,
4040
struct task_struct *task,
4141
struct bpf_testmod_test_read_ctx *read_ctx)
4242
{
43+
#if __has_builtin(__builtin_preserve_enum_value)
4344
struct core_reloc_module_output *out = (void *)&data.out;
4445
__u64 pid_tgid = bpf_get_current_pid_tgid();
4546
__u32 real_tgid = (__u32)(pid_tgid >> 32);
@@ -61,6 +62,9 @@ int BPF_PROG(test_core_module_probed,
6162
out->len_exists = bpf_core_field_exists(read_ctx->len);
6263

6364
out->comm_len = BPF_CORE_READ_STR_INTO(&out->comm, task, comm);
65+
#else
66+
data.skip = true;
67+
#endif
6468

6569
return 0;
6670
}
@@ -70,6 +74,7 @@ int BPF_PROG(test_core_module_direct,
7074
struct task_struct *task,
7175
struct bpf_testmod_test_read_ctx *read_ctx)
7276
{
77+
#if __has_builtin(__builtin_preserve_enum_value)
7378
struct core_reloc_module_output *out = (void *)&data.out;
7479
__u64 pid_tgid = bpf_get_current_pid_tgid();
7580
__u32 real_tgid = (__u32)(pid_tgid >> 32);
@@ -91,6 +96,9 @@ int BPF_PROG(test_core_module_direct,
9196
out->len_exists = bpf_core_field_exists(read_ctx->len);
9297

9398
out->comm_len = BPF_CORE_READ_STR_INTO(&out->comm, task, comm);
99+
#else
100+
data.skip = true;
101+
#endif
94102

95103
return 0;
96104
}

0 commit comments

Comments
 (0)