[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251223-james-libbfd-feat-check-v1-4-0e901ba32ed9@linaro.org>
Date: Tue, 23 Dec 2025 17:00:27 +0000
From: James Clark <james.clark@...aro.org>
To: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>, Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <nick.desaulniers+lkml@...il.com>,
Bill Wendling <morbo@...gle.com>, Leo Yan <leo.yan@....com>,
Justin Stitt <justinstitt@...gle.com>
Cc: linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
James Clark <james.clark@...aro.org>
Subject: [PATCH 4/5] perf build: Feature test for libbfd thread safety API
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@...aro.org>
---
tools/build/Makefile.feature | 1 +
tools/build/feature/Makefile | 4 ++++
tools/build/feature/test-libbfd-threadsafe.c | 18 ++++++++++++++++++
tools/perf/Makefile.config | 5 +++++
4 files changed, 28 insertions(+)
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 20422853d1ac..d94548fff489 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -71,6 +71,7 @@ FEATURE_TESTS_BASIC := \
gettid \
glibc \
libbfd \
+ libbfd-threadsafe \
libelf \
libelf-getphdrnum \
libelf-gelf_getnote \
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 63a97cdf78a3..731b19b84f4f 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -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 \
@@ -266,6 +267,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
index 000000000000..fe97f95f6f06
--- /dev/null
+++ b/tools/build/feature/test-libbfd-threadsafe.c
@@ -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);
+}
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 5ff98b89c39a..1e35fbb5215d 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -927,9 +927,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)
--
2.34.1
Powered by blists - more mailing lists