Re: [PATCH v13 05/21] perf build: Enable additional Clang thread-safety flags
From: Ian Rogers
Date: Sat Nov 21 2026 - 01:44:56 EST
On Thu, Nov 19, 2026 at 9:27 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
> On Fri, Nov 13, 2026 at 08:41:36AM -0800, Ian Rogers wrote:
> > Align tools/perf's Clang thread-safety flags with the kernel's
> > scripts/Makefile.context-analysis by adding -Wthread-safety-pointer,
> > -Wthread-safety-beta, and (when supported by the compiler)
> > -fexperimental-late-parse-attributes.
> >
> > Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> > ---
> > tools/perf/Makefile.config | 8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > index 3eb8d095cda0..b50702bac53c 100644
> > --- a/tools/perf/Makefile.config
> > +++ b/tools/perf/Makefile.config
> > @@ -64,7 +64,13 @@ ifeq ($(CC_NO_CLANG), 0)
> > endif
> >
> > # Enabled Wthread-safety analysis for clang builds.
> > - CFLAGS += -Wthread-safety -DWARN_CONTEXT_ANALYSIS
> > + CFLAGS += -DWARN_CONTEXT_ANALYSIS -Wthread-safety
> > + ifeq ($(shell $(CC) -Werror -Wthread-safety-pointer -Wthread-safety-beta -c -x c /dev/null -o /dev/null >/dev/null 2>&1 && echo 1), 1)
>
> Is there a better way to do this? I think there's something like
> cc_has_option but I cannot find it.
Good point - tools/build/Build.include defines `cc-option` (via
`try-run`), which wasn't included in Makefile.config yet. In v15 I'll
include tools/build/Build.include (updating TMPOUT to use $(OUTPUT) when
set) so this becomes:
CFLAGS += -DWARN_CONTEXT_ANALYSIS -Wthread-safety
CFLAGS += $(call cc-option,-Wthread-safety-pointer -Wthread-safety-beta)
CFLAGS += $(call cc-option,-fexperimental-late-parse-attributes)
Thanks,
Ian
> Thanks,
> Namhyung
>
>
> > + CFLAGS += -Wthread-safety-pointer -Wthread-safety-beta
> > + endif
> > + ifeq ($(shell $(CC) -Werror -fexperimental-late-parse-attributes -c -x c /dev/null -o /dev/null >/dev/null 2>&1 && echo 1), 1)
> > + CFLAGS += -fexperimental-late-parse-attributes
> > + endif
> > endif
> >
> > include $(srctree)/tools/scripts/Makefile.arch
> > --
> > 2.56.1.703.gf848ed807c-goog
> >