Re: [PATCH v13 05/21] perf build: Enable additional Clang thread-safety flags
From: Namhyung Kim
Date: Fri Nov 20 2026 - 00:27:23 EST
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.
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
>