From c4c43343501bd9fc24ec501ecaf43b7ef2da44d2 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Tue, 15 Sep 2026 23:12:10 -0700 Subject: perf libbfd: Fix the clang -Wthread-safety build failure perf_bfd_lock() and perf_bfd_unlock() are the callbacks given to bfd_thread_init(), so by design they acquire and release the lock on libbfd's behalf and the lock state differs between entry and exit. clang's thread safety analysis, which perf builds with as an error, flags both: util/libbfd.c:56:1: error: mutex 'bfd_mutex' is still held at the end of function [-Werror,-Wthread-safety-analysis] util/libbfd.c:60:2: error: releasing mutex 'bfd_mutex' that was not held [-Werror,-Wthread-safety-analysis] Mark both functions NO_THREAD_SAFETY_ANALYSIS so that libbfd.c compiles with "make CC=clang BUILD_NONDISTRO=1". Fixes: b72b8132d8fd2d6b ("perf libbfd: Ensure libbfd is initialized prior to use") Signed-off-by: Ian Rogers Assisted-by: Antigravity:gemini-3.1-pro Acked-by: Namhyung Kim Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/libbfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/libbfd.c b/tools/perf/util/libbfd.c index 936555217e81..d1d1c9b2ef22 100644 --- a/tools/perf/util/libbfd.c +++ b/tools/perf/util/libbfd.c @@ -39,13 +39,13 @@ struct a2l_data { asymbol **syms; }; -static bool perf_bfd_lock(void *bfd_mutex) +static bool perf_bfd_lock(void *bfd_mutex) NO_THREAD_SAFETY_ANALYSIS { mutex_lock(bfd_mutex); return true; } -static bool perf_bfd_unlock(void *bfd_mutex) +static bool perf_bfd_unlock(void *bfd_mutex) NO_THREAD_SAFETY_ANALYSIS { mutex_unlock(bfd_mutex); return true; -- cgit v1.2.3