]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf build: Feature test for libbfd thread safety API
authorJames Clark <james.clark@linaro.org>
Tue, 23 Dec 2025 17:00:27 +0000 (17:00 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 6 Jan 2026 22:14:46 +0000 (19:14 -0300)
The non-distro build requires libbfd 2.42 since commit b72b8132d8fd
("perf libbfd: Ensure libbfd is initialized prior to use"). Add a
feature test so that it's obvious why the build fails if this criteria
isn't met.

Signed-off-by: James Clark <james.clark@linaro.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Bill Wendling <morbo@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Justin Stitt <justinstitt@google.com>
Cc: Leo Yan <leo.yan@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/build/Makefile.feature
tools/build/feature/Makefile
tools/build/feature/test-libbfd-threadsafe.c [new file with mode: 0644]
tools/perf/Makefile.config

index bbaa88bb9b30537064a2783108efd4ec813b1a35..7f119eafc7c464ae9e5b781c1a5ed5f90d702f2c 100644 (file)
@@ -71,6 +71,7 @@ FEATURE_TESTS_BASIC :=                  \
         gettid                         \
         glibc                           \
         libbfd                          \
+       libbfd-threadsafe               \
         libelf                          \
         libelf-getphdrnum               \
         libelf-gelf_getnote             \
index d84db7df7988ede57a10b84561a280150e6f558e..5c15572d505e994b88076318c3425b87a8721b78 100644 (file)
@@ -13,6 +13,7 @@ FILES=                                          \
          test-gtk2-infobar.bin                  \
          test-hello.bin                         \
          test-libbfd.bin                        \
+        test-libbfd-threadsafe.bin             \
          test-disassembler-four-args.bin        \
          test-disassembler-init-styled.bin     \
          test-reallocarray.bin                 \
@@ -267,6 +268,9 @@ $(OUTPUT)test-libpython.bin:
 $(OUTPUT)test-libbfd.bin:
        $(BUILD_BFD)
 
+$(OUTPUT)test-libbfd-threadsafe.bin:
+       $(BUILD_BFD) || $(BUILD_BFD) -liberty || $(BUILD_BFD) -liberty -lz
+
 $(OUTPUT)test-disassembler-four-args.bin:
        $(BUILD_BFD) -lopcodes || $(BUILD_BFD) -lopcodes -liberty || \
        $(BUILD_BFD) -lopcodes -liberty -lz
diff --git a/tools/build/feature/test-libbfd-threadsafe.c b/tools/build/feature/test-libbfd-threadsafe.c
new file mode 100644 (file)
index 0000000..fe97f95
--- /dev/null
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <bfd.h>
+
+static bool lock(void *unused)
+{
+       return true;
+}
+
+static bool unlock(void *unused)
+{
+       return true;
+}
+
+int main(void)
+{
+       /* Check for presence of new thread safety API (version 2.42) */
+       return !bfd_thread_init(lock, unlock, NULL);
+}
index fb1cf2bf5d8360a4c6be189b048a18fcfd09faa0..6f2c7bd36e748fdaff54747ffda70c847da0042c 100644 (file)
@@ -935,9 +935,14 @@ ifdef BUILD_NONDISTRO
   $(call feature_check,libbfd)
   $(call feature_check,disassembler-four-args)
   $(call feature_check,disassembler-init-styled)
+  $(call feature_check,libbfd-threadsafe)
   $(call feature_check,libbfd-liberty)
   $(call feature_check,libbfd-liberty-z)
 
+  ifneq ($(feature-libbfd-threadsafe), 1)
+    $(error binutils 2.42 or later is required for non-distro builds)
+  endif
+
   # we may be on a system that requires -liberty and (maybe) -lz
   # to link against -lbfd; test each case individually here
   ifeq ($(feature-libbfd), 1)