Linux Perf Users
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: irogers@google.com, acme@kernel.org, namhyung@kernel.org
Cc: adrian.hunter@intel.com, andrii@kernel.org,
	cupertino.miranda@oracle.com,  eddyz87@gmail.com,
	james.clark@linaro.org, jolsa@kernel.org,
	 jose.marchesi@oracle.com, linux-kernel@vger.kernel.org,
	 linux-perf-users@vger.kernel.org, mingo@redhat.com,
	peterz@infradead.org,  yonghong.song@linux.dev
Subject: [PATCH v4 4/5] perf test make: Reuse Makefile.feature for libbfd and llvm probes
Date: Wed, 11 Nov 2026 17:15:13 -0800	[thread overview]
Message-ID: <20261112011514.4032822-5-irogers@google.com> (raw)
In-Reply-To: <20261112011514.4032822-1-irogers@google.com>

Include tools/build/Makefile.feature in tools/perf/tests/make (using a
temporary OUTPUT directory that is removed immediately after probing)
and replace the open-coded new_libbfd and have_libllvm compiler
invocations with the existing libbfd-threadsafe and llvm-perf feature
checks.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/tests/make | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 7524de522802..805d1074cfa8 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -127,19 +127,31 @@ make_minimal        += NO_LIBBPF=1
 make_minimal        += NO_SDT=1 NO_JVMTI=1 NO_LIBZSTD=1
 make_minimal        += NO_CAPSTONE=1
 
+override FEATURE_OUTPUT := $(shell mktemp -d)
+ifeq ($(FEATURE_OUTPUT),)
+$(error Failed to create temporary directory for feature checks)
+endif
+saved_OUTPUT_origin := $(origin OUTPUT)
+saved_OUTPUT := $(OUTPUT)
+override OUTPUT := $(FEATURE_OUTPUT)/
+FEATURE_DISPLAY_DEFERRED := 1
+FEATURE_TESTS :=
+include $(srctree)/tools/build/Makefile.feature
+
 # binutils 2_42 and newer have bfd_thread_init()
-new_libbfd := $(shell echo '#include <bfd.h>' | $(CC) -E -x c - | grep bfd_thread_init)
+$(call feature_check,libbfd-threadsafe)
 
 # Whether libLLVM can be built, which needs the llvm-devel/llvm-dev headers and
-# libraries of version 13 or newer, not just llvm-config. This mirrors the
-# llvm-perf feature test in tools/build/feature/test-llvm-perf.cpp so that
-# libLLVM is only asserted below when the default compiler can really build it.
+# libraries of version 13 or newer, not just llvm-config.
 ifneq ($(call has,$(LLVM_CONFIG)),)
-have_libllvm := $(shell printf '#include <llvm/Support/ManagedStatic.h>\n#include <llvm/Support/raw_ostream.h>\n#if LLVM_VERSION_MAJOR < 13\n#error "llvm-devel/llvm-dev version 13 or greater is required"\n#endif\nint main(){llvm::errs()<<"";llvm::llvm_shutdown();return 0;}\n' | \
-	$(CXX) -x c++ -std=gnu++17 -I$(shell $(LLVM_CONFIG) --includedir 2>/dev/null) - -o /dev/null \
-		-L$(shell $(LLVM_CONFIG) --libdir 2>/dev/null) \
-		$(shell $(LLVM_CONFIG) --libs Core BPF 2>/dev/null) \
-		$(shell $(LLVM_CONFIG) --system-libs 2>/dev/null) >/dev/null 2>&1 && echo y)
+  $(call feature_check,llvm-perf)
+endif
+
+$(shell rm -rf -- "$(FEATURE_OUTPUT)")
+ifeq ($(saved_OUTPUT_origin),undefined)
+override undefine OUTPUT
+else
+override OUTPUT := $(saved_OUTPUT)
 endif
 
 # $(run) contains all available tests
@@ -155,7 +167,7 @@ MAKE_F := $(MAKE) -f $(MK)
 endif
 run += make_python_perf_so
 run += make_debug
-ifneq ($(new_libbfd),)
+ifeq ($(feature-libbfd-threadsafe),1)
 run += make_nondistro
 # Demangling with libbfd is only built when the C++ ABI's __cxa_demangle
 # isn't available, so it needs a build of its own to be compiled at all.
@@ -165,7 +177,7 @@ endif
 # a C compiler and a C++ compiler that don't match.
 ifneq ($(call has,clang),)
 run += make_clang
-ifneq ($(new_libbfd),)
+ifeq ($(feature-libbfd-threadsafe),1)
 run += make_clang_nondistro
 endif
 endif
@@ -306,7 +318,7 @@ test_make_libbpf_dynamic_O := ldd $$TMP_O/perf | grep -q libbpf
 # doesn't fail the build, it just quietly turns off everything that needs a
 # C++ compiler. Check a feature that does, otherwise these tests would pass
 # while producing a perf with less in it than the default build has.
-ifneq ($(have_libllvm),)
+ifeq ($(feature-llvm-perf),1)
 test_make_clang               := test -x $(PERF_O)/perf && $(PERF_O)/perf check -q feature libLLVM
 test_make_clang_O             := test -x $$TMP_O/perf && $$TMP_O/perf check -q feature libLLVM
 test_make_clang_nondistro     := $(test_make_clang)
-- 
2.56.0.567.gdb80ae8cd5-goog


  parent reply	other threads:[~2026-11-12  1:15 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 22:16 [PATCH v1 0/2] perf build: Support building BPF skeletons with bpf-gcc Ian Rogers
2026-10-13 22:16 ` [PATCH v1 1/2] " Ian Rogers
2026-10-13 22:27   ` sashiko-bot
2026-10-13 22:16 ` [PATCH v1 2/2] perf test make: Add BPF skeleton build tests for clang and bpf-gcc Ian Rogers
2026-10-13 22:23   ` sashiko-bot
2026-10-13 23:14 ` [PATCH v2 0/2] perf build: Support building BPF skeletons with bpf-gcc Ian Rogers
2026-10-13 23:14   ` [PATCH v2 1/2] " Ian Rogers
2026-10-13 23:22     ` sashiko-bot
2026-10-13 23:14   ` [PATCH v2 2/2] perf test make: Add BPF skeleton build tests for clang and bpf-gcc Ian Rogers
2026-10-13 23:24     ` sashiko-bot
2026-10-22 20:46   ` [PATCH v3 0/2] perf build: Support building BPF skeletons with bpf-gcc Ian Rogers
2026-10-22 20:46     ` [PATCH v3 1/2] " Ian Rogers
2026-10-22 20:54       ` sashiko-bot
2026-11-11  6:01       ` Namhyung Kim
2026-10-22 20:46     ` [PATCH v3 2/2] perf test make: Add BPF skeleton build tests for clang and bpf-gcc Ian Rogers
2026-10-22 20:53       ` sashiko-bot
2026-11-04  3:52     ` [PATCH v3 0/2] perf build: Support building BPF skeletons with bpf-gcc Ian Rogers
2026-11-10 22:10       ` Ian Rogers
2026-11-12  1:15     ` [PATCH v4 0/5] " Ian Rogers
2026-11-12  1:15       ` [PATCH v4 1/5] tools build: Fix version-ge3 and version-lt3 for <3-part versions Ian Rogers
2026-11-12  1:18         ` sashiko-bot
2026-11-12  1:15       ` [PATCH v4 2/5] perf build: Sync bpf_skel.mak get_sys_includes with selftests/bpf Ian Rogers
2026-11-12  1:18         ` sashiko-bot
2026-11-12  1:15       ` [PATCH v4 3/5] perf build: Support building BPF skeletons with bpf-gcc Ian Rogers
2026-11-12  1:38         ` sashiko-bot
2026-11-12  1:15       ` Ian Rogers [this message]
2026-11-12  1:32         ` [PATCH v4 4/5] perf test make: Reuse Makefile.feature for libbfd and llvm probes sashiko-bot
2026-11-12  1:15       ` [PATCH v4 5/5] perf test make: Add BPF skeleton build tests for clang and bpf-gcc Ian Rogers
2026-11-12  1:38         ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261112011514.4032822-5-irogers@google.com \
    --to=irogers@google.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=andrii@kernel.org \
    --cc=cupertino.miranda@oracle.com \
    --cc=eddyz87@gmail.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=jose.marchesi@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox