Re: [PATCH] perf lock contention: Fix builtin detection

From: Namhyung Kim
Date: Tue Mar 07 2023 - 11:57:16 EST


On Mon, Mar 6, 2023 at 9:56 PM Ian Rogers <irogers@xxxxxxxxxx> wrote:
>
> On Mon, Mar 6, 2023 at 8:43 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> >
> > Hi Ian,
> >
> > On Mon, Mar 6, 2023 at 7:21 PM Ian Rogers <irogers@xxxxxxxxxx> wrote:
> > >
> > > __has_builtin was passed the macro rather than the actual builtin
> > > feature.
> >
> > Oh, I missed it's a macro define in tools/lib/bpf/bpf_core_read.h file.
> >
> > Looking at some BPF test codes, it seems you also need to check the
> > clang compiler version. Please take a look at the file below:
> >
> > tools/testing/selftests/bpf/progs/test_core_reloc_type_base.c
> >
> > Thanks,
> > Namhyung
>
> Hmm..
>
> tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c:
> ...
> /* Support for the BPF_TYPE_MATCHES argument to the
> * __builtin_preserve_type_info builtin was added at some point during
> * development of clang 15 and it's what we require for this test.
> */
> #if __has_builtin(__builtin_preserve_type_info) && __clang_major__ >= 15
> ...
>
> I'm not sure we need to worry about development clang builds and just
> the __has_builtin is cleaner. Perhaps the BPF folks can chime in.

My understanding is that __builtin_preserve_type_info is supported
before. But clang 15 added BPF_TYPE_MATCHES which is used for
bpf_core_type_matches(). So just checking the builtin would not work.

Thanks,
Namhyung