Re: [PATCH] perf build: Only enable context analysis with Clang 23 or later
From: Namhyung Kim
Date: Mon Nov 23 2026 - 16:24:00 EST
Hello,
On Mon, Nov 23, 2026 at 04:55:16PM -0300, Arnaldo Melo wrote:
>
>
> On November 23, 2026 3:44:12 PM GMT-03:00, Ian Rogers <irogers@xxxxxxxxxx> wrote:
> >On Mon, Nov 23, 2026 at 8:46 AM James Clark <james.clark@xxxxxxxxxx> wrote:
> >>
> >> Context analysis requires Clang 23 or later (see
> >> Documentation/dev-tools/context-analysis.rst), otherwise the build fails
> >> on older versions, e.g. Clang 18:
> >>
> >> util/env.h:142:39: error: use of undeclared identifier 'lock'
> >> 142 | struct rb_root infos __guarded_by(&lock);
> >>
> >> Only enable it when the Clang version is supported. Leave the other
> >> thread safety options enabled if they exist because they don't cause
> >> build failures at the moment, and might provide benefits even without
> >> -DWARN_CONTEXT_ANALYSIS.
> >
> >So we've had -Wthread-safety for a long time in the perf tree, I'm
> >guessing __guarded_by is missing on older clang versions. Can we just
> >stub out the __guarded_by for these old clang versions and keep the
> >lock checking?
>
> Looks way more reasonable, and no need for a feature test since we know
> the compiler version when __guarded_by was introduced, right?
Sorry for the trouble. I checked with clang 21 and it didn't have a
problem.
Thanks,
Namhyung