mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: irogers@google.com, acme@kernel.org,
	cupertino.miranda@oracle.com,  jose.marchesi@oracle.com,
	namhyung@kernel.org
Cc: adrian.hunter@intel.com, andrii@kernel.org, eddyz87@gmail.com,
	 james.clark@linaro.org, jolsa@kernel.org,
	linux-kernel@vger.kernel.org,  linux-perf-users@vger.kernel.org,
	mingo@redhat.com, peterz@infradead.org,  yonghong.song@linux.dev
Subject: [PATCH v3 2/2] perf test make: Add BPF skeleton build tests for clang and bpf-gcc
Date: Thu, 22 Oct 2026 13:46:27 -0700	[thread overview]
Message-ID: <20261022204627.1813821-3-irogers@google.com> (raw)
In-Reply-To: <20261022204627.1813821-1-irogers@google.com>

Add make_bpf_skel_clang (CLANG=clang BPF_GCC=) and make_bpf_skel_bpf_gcc
(BPF_GCC=bpf-gcc CLANG=) targets to tools/perf/tests/make when the
corresponding compiler and BPF skeleton dependencies are available on
the host.

Include tools/build/Makefile.feature and tools/scripts/utilities.mak in
tools/perf/tests/make to reuse the existing feature checks
(libelf, zlib, bpf, libopenssl, clang-bpf-co-re, libbfd-threadsafe, and
llvm-perf) instead of open-coding compiler invocations.

Verify with 'perf check -q feature bpf_skeletons' that BPF skeleton
support is enabled for both targets and disabled (exit code 1) for
make_no_bpf_skel.

Assisted-by: Antigravity:gemini-3.1-pro
Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/tests/make | 71 +++++++++++++++++++++++++++++++++++--------
 1 file changed, 58 insertions(+), 13 deletions(-)

diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 7524de522802..a40390ed47f1 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -54,6 +54,7 @@ srctree := $(patsubst %/,%,$(dir $(srctree)))
 endif
 
 include $(srctree)/tools/scripts/Makefile.arch
+include $(srctree)/tools/scripts/utilities.mak
 
 # FIXME looks like x86 is the only arch running tests ;-)
 # we need some IS_(32/64) flag to make this generic
@@ -65,6 +66,7 @@ endif
 
 has = $(shell which $1 2>/dev/null)
 python_perf_so := $(shell $(MAKE) python_perf_target|grep "Target is:"|awk '{print $$3}')
+BPF_GCC ?= bpf-gcc
 
 # standard single make variable specified
 make_clean_all      := clean all
@@ -78,6 +80,8 @@ make_extra_tests    := EXTRA_TESTS=1
 make_no_jevents     := NO_JEVENTS=1
 make_jevents_all    := JEVENTS_ARCH=all
 make_no_bpf_skel    := BUILD_BPF_SKEL=0
+make_bpf_skel_clang := CLANG=$(CLANG) BPF_GCC=
+make_bpf_skel_bpf_gcc := BPF_GCC=$(BPF_GCC) CLANG=
 make_gen_vmlinux_h  := GEN_VMLINUX_H=1
 make_no_python_module := NO_PYTHON_MODULE=1
 make_no_scripts     := NO_PYTHON_MODULE=1
@@ -127,21 +131,49 @@ 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 := $(OUTPUT)
+override OUTPUT := $(FEATURE_OUTPUT)/
+FEATURE_DISPLAY_DEFERRED := 1
+FEATURE_TESTS := libelf zlib bpf libopenssl
+FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
+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
+
+ifeq ($(feature-libelf)$(feature-zlib)$(feature-bpf)$(feature-libopenssl),1111)
+  ifneq ($(call get-executable,$(CLANG)),)
+    CLANG_VERSION := $(shell $(CLANG) --version | head -1 | sed 's/.*clang version \([[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\).*/\1/g')
+    ifneq ($(call version-lt3,$(CLANG_VERSION),12.0.1),1)
+      $(call feature_check,clang-bpf-co-re)
+      ifeq ($(feature-clang-bpf-co-re),1)
+        have_clang_bpf := 1
+      endif
+    endif
+  endif
+  ifneq ($(call get-executable,$(BPF_GCC)),)
+    BPF_GCC_VERSION := $(shell $(BPF_GCC) -dumpfullversion 2>/dev/null)
+    ifneq ($(BPF_GCC_VERSION),)
+      ifneq ($(call version-lt3,$(BPF_GCC_VERSION),14.0.0),1)
+        have_bpf_gcc := 1
+      endif
+    endif
+  endif
 endif
 
+$(shell rm -rf -- "$(FEATURE_OUTPUT)")
+override OUTPUT := $(saved_OUTPUT)
+
 # $(run) contains all available tests
 run := make_pure
 # Targets 'clean all' can be run together only through top level
@@ -155,7 +187,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 +197,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
@@ -173,6 +205,12 @@ run += make_extra_tests
 run += make_no_jevents
 run += make_jevents_all
 run += make_no_bpf_skel
+ifeq ($(have_clang_bpf),1)
+run += make_bpf_skel_clang
+endif
+ifeq ($(have_bpf_gcc),1)
+run += make_bpf_skel_bpf_gcc
+endif
 run += make_gen_vmlinux_h
 run += make_no_python_module
 run += make_no_scripts
@@ -306,13 +344,20 @@ 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)
 test_make_clang_nondistro_O   := $(test_make_clang_O)
 endif
 
+test_make_no_bpf_skel         := test -x $(PERF_O)/perf && ($(PERF_O)/perf check -q feature bpf_skeletons; test $$? -eq 1)
+test_make_no_bpf_skel_O       := test -x $$TMP_O/perf && ($$TMP_O/perf check -q feature bpf_skeletons; test $$? -eq 1)
+test_make_bpf_skel_clang      := test -x $(PERF_O)/perf && $(PERF_O)/perf check -q feature bpf_skeletons
+test_make_bpf_skel_clang_O    := test -x $$TMP_O/perf && $$TMP_O/perf check -q feature bpf_skeletons
+test_make_bpf_skel_bpf_gcc    := test -x $(PERF_O)/perf && $(PERF_O)/perf check -q feature bpf_skeletons
+test_make_bpf_skel_bpf_gcc_O  := test -x $$TMP_O/perf && $$TMP_O/perf check -q feature bpf_skeletons
+
 test_make_python_perf_so_O    := test -f $$TMP_O/python/perf.so
 test_make_perf_o_O            := test -f $$TMP_O/perf.o
 test_make_util_map_o_O        := test -f $$TMP_O/util/map.o
@@ -445,7 +490,7 @@ $(FEATURES_DUMP_FILE_STATIC):
 # The clang tests exist to run feature detection with a compiler other than
 # the default one, so they have to do their own and are left out of both the
 # dependency and the 'FEATURES_DUMP=' append below.
-no_features_dump := make_clang make_clang_nondistro
+no_features_dump := make_clang make_clang_nondistro make_bpf_skel_clang make_bpf_skel_bpf_gcc
 no_features_dump += $(addsuffix _O,$(no_features_dump))
 
 # Add feature dump dependency for run/run_O targets
-- 
2.56.0.307.g5fe7bd680c-goog


      parent reply	other threads:[~2026-10-22 20:46 UTC|newest]

Thread overview: 9+ 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:16 ` [PATCH v1 2/2] perf test make: Add BPF skeleton build tests for clang and bpf-gcc Ian Rogers
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:14   ` [PATCH v2 2/2] perf test make: Add BPF skeleton build tests for clang and bpf-gcc Ian Rogers
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:46     ` Ian Rogers [this message]

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=20261022204627.1813821-3-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

all inboxes | Powered by JetHome®