From nobody Sat Oct 24 14:06:33 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.198 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792701997; b=snaLYkVFrjMtXG2/1jYOKX9uoxvyeZFz93L/jfz6zozizOMnYc08cUl+ofTzMOZ01nQe B4EeE556E8ydMds0tKJUmLliWEvkJKKf6cVCA6dokq2unkF6R8x2IjVaShEhG/DujO12v Dd7e0wHQmMojxY6u3/1ioGXEkt8JFAy7z+J446Iqj1o3toPiFx73Pe0O0wZ8H0iYRz8+u 3loLTtRhOUEIrwUuaXUKFgdHx8pmxo6NJhCbCjlGmZlN1NUV0mmdOU3+kk6JRiwMRd7/d 8Yb2HVseBBIvw8ye5L1Snv4Z83qIhWXJjSvbrHBQcd+5BYcNT4s+gs7rBmzTdHi+uUA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792701997; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=3A2JvQaX6NGwVUlyd7EIgNLM6n6TvhMzrjmcQejjBKw=; b=PE8ZYd2nEpYQ20kzuuav0+RuEyvb8gTibkyjL7tT0DpmbJvXHmSEsmWM4ugxMDtBzhOX wIxmsLYkczm9lK09UUKHQcXRCoGcvnbAaav6mz+AEVo7dNwwLaUSPiLJjO2uEJsGRQaYr 28TzAjYR6PVAg1tOxFpskcXtVY06fI/HwgpSar7LHwVGUCHGkPX66hd+Xkwgr5rtKaMrA NygXGRY/A3fyqoxmiLid9UwF30hNYejllaKYn58rWzw203OtLHaKqPK4ulbxipHHlz8tp Zo4I4WgS8xupTZ4xFKf8Z9VapveOzNbs3vnZzTcSmGNx8XUDW8VvIK2n4xNKOKTV4Aw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20251104 header.b=CcQckVfB; arc=none smtp.remote-ip=74.125.82.198 Received: from mail-dy1-f198.google.com (mail-dy1-f198.google.com [74.125.82.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC4C6606A331 for ; Thu, 22 Oct 2026 20:46:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AC4C6606A331 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20251104 header.b=CcQckVfB Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-36637676140so347136eec.0 for ; Thu, 22 Oct 2026 13:46:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1792701996; x=1793306796; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=3A2JvQaX6NGwVUlyd7EIgNLM6n6TvhMzrjmcQejjBKw=; b=CcQckVfBKTPmcbhP3ybU0wHH32joYwPBrwLeFvCvE+JDcuq+zbdIeY33xFX3ApfX22 YzvZElt8+7XVkfrCpiSO678eUFata8mXxEYJDr1iRvSWSsCO7+SQWrW85M+Opq0xrpjw Q3kJrJ5kucq5tnElowu9hhASpl6pBE69A/6sugO4zEYUWeOi5G+YVKXUlfQceNyMYmQ9 IMNk0RH69wZ/kjcSOeHQ8Vc+UCrFub8Cz2j1fqNnXFzj/Mp6zlnt4q/87XrgZ6/r+oMk YBiB9PTFz9HFkKt5p7Hg0hZpnS34n8DOUEiC1Ff98UIAHXgL2Lm6Y1PEVMPybqSeJwuy e5qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792701996; x=1793306796; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3A2JvQaX6NGwVUlyd7EIgNLM6n6TvhMzrjmcQejjBKw=; b=zhlMvS9Jzdfy9INyRAHT0H57ImqQN0XvHE0ZQEOhliilvG2JxNPydfXmRxGWRmSKV1 dtu5vlR/hA7pkOSEmfk6aBmaiY9vO5XCY0IfqnG/88mRH+J8RolAXnPzBuqRGyy5ylYC bvH5pq0TisgdFGro+oUW8+ohnpH8qhqFX7YQJMInGK5b7y68+6a3s1IIwIoNJRwIeCm9 20zNxzkccUMOdEOeAnj7i/TDvUNvfoF4+Z6UcADgOsokXflf+YZqg6ZkqErBkhD2CxYl +6ldUUeJCLLb8LIBhnF1avbGltQoTIMSAhQoyUwrvFc2y28TnVip7RkN9ISlFYIDU10l hnCA== X-Forwarded-Encrypted: i=1; AKwUvBw6rN7jE9xjfzDLIFDSk2Jl8LWgfimmDI7PFmc0HlwyGoKUwexvn6Z1Mh3QHVwL/aWIfMeQzvzzQTEF9UA=@vger.kernel.org X-Gm-Message-State: AFq9FYLx+tWGH9PbwifpIkkj8p91OORq6rz9Odmb9r9OYX/ItGGDGzE9 OuBu/HKzmNk9xHEcqUm84KNfkBoqMtSwWXSzDiIYkn/5Zw95d37NZ2gf3OvftJzZlrS5zbCzJ11 G8O7Svt707A== X-Received: from dlbts17-n2.prod.google.com ([2002:a05:7022:b051:20b0:18f:4e29:3ddd]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:2052:10b0:149:1feb:6da4 with SMTP id a92af1059eb24-19599707c7emr693369c88.32.1792701995421; Thu, 22 Oct 2026 13:46:35 -0700 (PDT) Date: Thu, 22 Oct 2026 13:46:26 -0700 In-Reply-To: <20261022204627.1813821-1-irogers@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261013231430.2163505-1-irogers@google.com> <20261022204627.1813821-1-irogers@google.com> X-Mailer: git-send-email 2.56.0.307.g5fe7bd680c-goog Message-ID: <20261022204627.1813821-2-irogers@google.com> Subject: [PATCH v3 1/2] perf build: Support building BPF skeletons with bpf-gcc From: Ian Rogers 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Support building perf BPF skeletons with bpf-gcc (>=3D 14.0.0) in addition to clang (>=3D 12.0.1), similar to tools/testing/selftests/bpf/Makefile. When building perf with GCC (CC_NO_CLANG=3D1), prefer bpf-gcc and fall back to clang if bpf-gcc is unavailable or too old. When building with Clang/LLVM (CC_NO_CLANG=3D0), prefer clang and fall back to bpf-gcc. Explicit command-line overrides via BPF_GCC=3D... or CLANG=3D... are respected, and setting BPF_GCC=3D or CLANG=3D to empty disables that compiler. In bpf_skel.mak, pass the bpf-gcc flags (-mcpu=3Dv3, -fno-ident, -DBPF_NO_PRESERVE_ACCESS_INDEX, -Wno-attributes, -D__TARGET_ARCH_$(SRCARCH), and target endianness) and query system include paths from $(CC). Also update version-ge3 and version-lt3 in tools/scripts/utilities.mak to split the two version arguments separately in awk so empty or fewer-than-3-component version strings do not shift fields across arguments. Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers --- tools/perf/Makefile.config | 83 +++++++++++++++++++++++++++------- tools/perf/Makefile.perf | 8 +++- tools/perf/bpf_skel.mak | 36 ++++++++++----- tools/scripts/Makefile.include | 1 + tools/scripts/utilities.mak | 4 +- 5 files changed, 101 insertions(+), 31 deletions(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index cafc7be79643..ca045f7ff01d 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -662,27 +662,78 @@ ifeq ($(BUILD_BPF_SKEL),1) else ifeq ($(filter -DHAVE_LIBOPENSSL_SUPPORT, $(CFLAGS)),) $(warning Warning: Disabled BPF skeletons as libopenssl is required) BUILD_BPF_SKEL :=3D 0 - else ifeq ($(call get-executable,$(CLANG)),) - $(warning Warning: Disabled BPF skeletons as clang ($(CLANG)) is missi= ng) - BUILD_BPF_SKEL :=3D 0 - else - CLANG_VERSION :=3D $(shell $(CLANG) --version | head -1 | sed 's/.*cla= ng version \([[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\).*/\1/g') - ifeq ($(call version-lt3,$(CLANG_VERSION),12.0.1),1) - $(warning Warning: Disabled BPF skeletons as reliable BTF generation= needs at least $(CLANG) version 12.0.1) - BUILD_BPF_SKEL :=3D 0 - endif endif ifeq ($(BUILD_BPF_SKEL),1) - $(call feature_check,clang-bpf-co-re) - ifeq ($(feature-clang-bpf-co-re), 0) - $(warning Warning: Disabled BPF skeletons as clang is too old) + # Prefer bpf-gcc when building with gcc (CC_NO_CLANG=3D1) and clang wh= en + # building with clang, unless CLANG or BPF_GCC was explicitly specifie= d on + # the command line. Fall back to whichever compiler is available. + prefer_bpf_gcc :=3D $(CC_NO_CLANG) + ifeq ($(origin BPF_GCC),command line) + ifneq ($(BPF_GCC),) + prefer_bpf_gcc :=3D 1 + endif + else ifeq ($(origin CLANG),command line) + ifneq ($(CLANG),) + prefer_bpf_gcc :=3D 0 + endif + endif + + have_bpf_gcc :=3D 0 + have_clang_bpf :=3D 0 + + define check_bpf_gcc + ifneq ($$(call get-executable,$$(BPF_GCC)),) + BPF_GCC_VERSION :=3D $$(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 :=3D 1 + endif + endif + endif + endef + + ifeq ($(prefer_bpf_gcc),1) + $(eval $(check_bpf_gcc)) + endif + + ifeq ($(have_bpf_gcc),0) + ifneq ($(call get-executable,$(CLANG)),) + CLANG_VERSION :=3D $(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) + ifneq ($(feature-clang-bpf-co-re), 0) + have_clang_bpf :=3D 1 + endif + endif + endif + endif + + ifeq ($(prefer_bpf_gcc)$(have_clang_bpf),00) + $(eval $(check_bpf_gcc)) + endif + + ifeq ($(have_bpf_gcc),1) + $(call detected,CONFIG_PERF_BPF_SKEL_BPF_GCC) + $(call detected,CONFIG_PERF_BPF_SKEL) + CFLAGS +=3D -DHAVE_BPF_SKEL + else ifeq ($(have_clang_bpf),1) + $(call detected,CONFIG_PERF_BPF_SKEL) + CFLAGS +=3D -DHAVE_BPF_SKEL + else + ifeq ($(call get-executable,$(CLANG))$(call get-executable,$(BPF_GCC= )),) + $(warning Warning: Disabled BPF skeletons as clang ($(CLANG)) and = bpf-gcc ($(BPF_GCC)) are missing) + else ifneq ($(call get-executable,$(CLANG)),) + ifeq ($(call version-lt3,$(CLANG_VERSION),12.0.1),1) + $(warning Warning: Disabled BPF skeletons as reliable BTF genera= tion needs at least $(CLANG) version 12.0.1) + else + $(warning Warning: Disabled BPF skeletons as clang is too old) + endif + else + $(warning Warning: Disabled BPF skeletons as bpf-gcc ($(BPF_GCC)) = needs at least version 14.0.0) + endif BUILD_BPF_SKEL :=3D 0 endif endif - ifeq ($(BUILD_BPF_SKEL),1) - $(call detected,CONFIG_PERF_BPF_SKEL) - CFLAGS +=3D -DHAVE_BPF_SKEL - endif endif =20 ifndef GEN_VMLINUX_H diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 2d9379fea267..4061a79cae54 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -37,6 +37,9 @@ include ../scripts/utilities.mak # Define EXTRA_BPF_FLAGS=3D"--sysroot=3D" or other custom include pa= ths for # cross-compiling BPF skeletons # +# Define BPF_GCC to point to the bpf-gcc binary if the default `bpf-gcc' i= s not +# correct, or set BPF_GCC=3D to disable using bpf-gcc for BPF skeletons. +# # Define EXCLUDE_EXTLIBS=3D-lmylib to exclude libmylib from the auto-gener= ated # EXTLIBS. # @@ -208,6 +211,7 @@ FIND =3D find INSTALL =3D install FLEX ?=3D flex BISON ?=3D bison +BPF_GCC ?=3D bpf-gcc AWK =3D awk =20 # include Makefile.config by default and rule out @@ -321,8 +325,8 @@ ifneq ($(force_fixdep),1) endif endif =20 -export srctree OUTPUT RM CC CXX RUSTC CLANG LD AR CFLAGS CXXFLAGS RUST_FLA= GS V BISON FLEX AWK LIBBPF READELF -export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT CONFIG_PERF_= BPF_SKEL +export srctree OUTPUT RM CC CXX RUSTC CLANG BPF_GCC LD AR CFLAGS CXXFLAGS = RUST_FLAGS V BISON FLEX AWK LIBBPF READELF +export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT CONFIG_PERF_= BPF_SKEL CONFIG_PERF_BPF_SKEL_BPF_GCC =20 include $(srctree)/tools/build/Makefile.include =20 diff --git a/tools/perf/bpf_skel.mak b/tools/perf/bpf_skel.mak index f2559de39f96..7b7edf506509 100644 --- a/tools/perf/bpf_skel.mak +++ b/tools/perf/bpf_skel.mak @@ -22,21 +22,35 @@ bpf-skel-prepare: $(BPFTOOL) $(VMLINUX_H) define get_sys_includes $(shell $(1) $(2) -v -E - &1 \ | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/= .*\)|-idirafter \1|p }') \ -$(shell $(1) $(2) -dM -E - =3D (10000000 * $$4 + 10000 * $$5 + $$6)= ) }') +version-ge3 =3D $(shell awk -v v1=3D"$(1)" -v v2=3D"$(2)" 'BEGIN { split(v= 1, a, "."); split(v2, b, "."); printf("%d\n", (10000000 * a[1] + 10000 * a[= 2] + a[3]) >=3D (10000000 * b[1] + 10000 * b[2] + b[3])) }') =20 # version-lt3 # @@ -196,4 +196,4 @@ version-ge3 =3D $(shell echo "$(1).$(2)" | awk -F'.' '{= printf("%d\n", (10000000 * # check the flex version to see if we can use compiler warnings as errors = for # one of the cases flex generates code C compilers complains about. =20 -version-lt3 =3D $(shell echo "$(1).$(2)" | awk -F'.' '{ printf("%d\n", (10= 000000 * $$1 + 10000 * $$2 + $$3) < (10000000 * $$4 + 10000 * $$5 + $$6)) }= ') +version-lt3 =3D $(shell awk -v v1=3D"$(1)" -v v2=3D"$(2)" 'BEGIN { split(v= 1, a, "."); split(v2, b, "."); printf("%d\n", (10000000 * a[1] + 10000 * a[= 2] + a[3]) < (10000000 * b[1] + 10000 * b[2] + b[3])) }') --=20 2.56.0.307.g5fe7bd680c-goog From nobody Sat Oct 24 14:06:33 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792701999; b=duAxz6wqMEFUKeOBEGofyCzon9+uCzPURaruA1znEai3+Cm2s1JQNfLrKuGPdG/qQVhu FJq28nRc5eWSnf67vJOl9JptTVvER4GkVOWdIjCscQWCI8gcgSUQiOOcZp0j2U/PACDIe fXRVsoOYrV3HbTbwlPnKbzM+JPTcylNy/gQHrFUF78Bi3jNNiaHcFyBHpCW7lr7T4G5Mc gBf5CsZJ0CIGGCWfXydIIP3bwyLU9kAN++1nTMRDTkGnw6M48s4WWBKETH61tQbnFcUC/ EaGv9ByldPxfaamL4jEKVd1U+/vITZqynTqdT5HGxKvm9p/o2Z6wXHLXgu0nWMKb9sQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792701999; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type:Content-Transfer-Encoding; bh=5EXSTLNSsguQaSynPItTzP5zk0jMq4+PZis12D7icos=; b=3kGbNj/p8QvdmWv+/YXrBy9jnIl7yZKSvSGHSB5cOGIkU/1B0kL7j0vDAP6EAsLDjzEu /7ZVaBye28Ulzch64qH3xyF0341Xj9NyIUE/iCWuvAQTvpAOO7pm2H6ms+TJpSeMOfgFg uIGtocf3Q131EaAcElFRyCE97h9y48igw2gNzvlkw7X7Ab9zz7z6OQtlS0LLvmUN/3Ub1 LcWrdN/oT4uTDwIGk9p3tfHqGwGDE1k4oqxD/zD/ROPCVgHh4xi6mRveooSlmGmoOdg5D So7OpwW3GIVOHwEJdeaETsbDfwy6I90XKQnselWcBA66LTpR5cvm7P4Io2FgByKWa3w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20251104 header.b=u33GNpRG; arc=none smtp.remote-ip=74.125.82.197 Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A95F9606A31A for ; Thu, 22 Oct 2026 20:46:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A95F9606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20251104 header.b=u33GNpRG Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-35cbea41088so273479eec.1 for ; Thu, 22 Oct 2026 13:46:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1792701998; x=1793306798; darn=vger.kernel.org; h=content-transfer-encoding:content-type:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date:from:to:cc :subject:date:message-id:reply-to:content-type; bh=5EXSTLNSsguQaSynPItTzP5zk0jMq4+PZis12D7icos=; b=u33GNpRGviPmex4xNfgxzzF6v4zZMgm6KsvsrIONWfBx5RphfJB+KWNvkgdO9Lxnye V2X0kj7L0OQ/sph5Ul1MFeCAVPl3h42gPfKo2n6PpRML9pZ6X6CcKBao9hQ7k7MKz0jo YSCE77galjDfjLW+6ksA3yhgJ/p4go3+NR01Dpw29tPNePe+3axSy0oYAJL1iKIRg+fb nMnVq0uRmMzfKNjnNooz03c8yvzAaPmzlOVxD9XT0R1ncCwZ8X5Z0UAplqinyVfi6h0Z VoO3VMO8EWTzvD3ckHdFu/qSud+C+8i1kSbi5ThW5IG+cytozbaOOACAe0c54FQX66yG IedQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792701998; x=1793306798; h=content-transfer-encoding:content-type:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=5EXSTLNSsguQaSynPItTzP5zk0jMq4+PZis12D7icos=; b=E5Xe/euB6IdbXiLK2dHduNCf1BgvwW9az3GkgRWJWfTDLcLtNkqyebQbOrOZBF4LEE 0DtibYqsTZsRJqqKisIs8zkE1JXe6rgZve7LtpXCuoUm2ADJEx24IhLRIQX3veFmafB1 1nzzRL8c8yMgo2JXQBfAzBtHQeqDgZv1nPwBC0tKMZ2GQpkjDfNaccN9uhRIONFOu1/6 L3uKkuvYzhpsKez4jO20AGmX6NNF5yW/CEkDRxaNVMREIv+r/+I2uEPXP0dKD2kIzkvT F2o1Bna//2nLP0hYv5kvQzcXi01a1XyLRKvLs/4h7Ry8v2wqrL4lhf4jBXHyMkU19vrW 9wng== X-Forwarded-Encrypted: i=1; AKwUvBy2Jaof1Lh0V0y1txfdHDApLiUSKdRFsiscvPlyKC+b6D12Cv3nqzR6sh3zw15UftfTMpIcMr++vajfi2s=@vger.kernel.org X-Gm-Message-State: AFq9FYK3xzwkUUKpwfxEV3nnLnf96ZiswrZQX4vUCMiMon1VJmzyV1Ib LhT6UbitxNDKPrr3YYgRWNla5SYdKaCjbPsM34FUPxBH/dSg79m4QQ4LzLyWgetjcyTtXgY541C r15rqKgUbNw== X-Received: from dybfc19.prod.google.com ([2002:a05:7300:3e93:b0:359:198a:8046]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:608e:b0:35d:4e41:d2c2 with SMTP id 5a478bee46e88-369d98bcdaemr432842eec.33.1792701997376; Thu, 22 Oct 2026 13:46:37 -0700 (PDT) Date: Thu, 22 Oct 2026 13:46:27 -0700 In-Reply-To: <20261022204627.1813821-1-irogers@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261013231430.2163505-1-irogers@google.com> <20261022204627.1813821-1-irogers@google.com> X-Mailer: git-send-email 2.56.0.307.g5fe7bd680c-goog Message-ID: <20261022204627.1813821-3-irogers@google.com> Subject: [PATCH v3 2/2] perf test make: Add BPF skeleton build tests for clang and bpf-gcc From: Ian Rogers 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add make_bpf_skel_clang (CLANG=3Dclang BPF_GCC=3D) and make_bpf_skel_bpf_gcc (BPF_GCC=3Dbpf-gcc CLANG=3D) 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 --- 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 :=3D $(patsubst %/,%,$(dir $(srctree))) endif =20 include $(srctree)/tools/scripts/Makefile.arch +include $(srctree)/tools/scripts/utilities.mak =20 # 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 =20 has =3D $(shell which $1 2>/dev/null) python_perf_so :=3D $(shell $(MAKE) python_perf_target|grep "Target is:"|a= wk '{print $$3}') +BPF_GCC ?=3D bpf-gcc =20 # standard single make variable specified make_clean_all :=3D clean all @@ -78,6 +80,8 @@ make_extra_tests :=3D EXTRA_TESTS=3D1 make_no_jevents :=3D NO_JEVENTS=3D1 make_jevents_all :=3D JEVENTS_ARCH=3Dall make_no_bpf_skel :=3D BUILD_BPF_SKEL=3D0 +make_bpf_skel_clang :=3D CLANG=3D$(CLANG) BPF_GCC=3D +make_bpf_skel_bpf_gcc :=3D BPF_GCC=3D$(BPF_GCC) CLANG=3D make_gen_vmlinux_h :=3D GEN_VMLINUX_H=3D1 make_no_python_module :=3D NO_PYTHON_MODULE=3D1 make_no_scripts :=3D NO_PYTHON_MODULE=3D1 @@ -127,21 +131,49 @@ make_minimal +=3D NO_LIBBPF=3D1 make_minimal +=3D NO_SDT=3D1 NO_JVMTI=3D1 NO_LIBZSTD=3D1 make_minimal +=3D NO_CAPSTONE=3D1 =20 +override FEATURE_OUTPUT :=3D $(shell mktemp -d) +ifeq ($(FEATURE_OUTPUT),) +$(error Failed to create temporary directory for feature checks) +endif +saved_OUTPUT :=3D $(OUTPUT) +override OUTPUT :=3D $(FEATURE_OUTPUT)/ +FEATURE_DISPLAY_DEFERRED :=3D 1 +FEATURE_TESTS :=3D libelf zlib bpf libopenssl +FEATURE_CHECK_CFLAGS-bpf =3D -I. -I$(srctree)/tools/include -I$(srctree)/t= ools/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 :=3D $(shell echo '#include ' | $(CC) -E -x c - | grep b= fd_thread_init) +$(call feature_check,libbfd-threadsafe) =20 # Whether libLLVM can be built, which needs the llvm-devel/llvm-dev header= s 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 buil= d it. +# libraries of version 13 or newer, not just llvm-config. ifneq ($(call has,$(LLVM_CONFIG)),) -have_libllvm :=3D $(shell printf '#include \= n#include \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=3Dgnu++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 && ech= o y) + $(call feature_check,llvm-perf) +endif + +ifeq ($(feature-libelf)$(feature-zlib)$(feature-bpf)$(feature-libopenssl),= 1111) + ifneq ($(call get-executable,$(CLANG)),) + CLANG_VERSION :=3D $(shell $(CLANG) --version | head -1 | sed 's/.*cla= ng 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 :=3D 1 + endif + endif + endif + ifneq ($(call get-executable,$(BPF_GCC)),) + BPF_GCC_VERSION :=3D $(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 :=3D 1 + endif + endif + endif endif =20 +$(shell rm -rf -- "$(FEATURE_OUTPUT)") +override OUTPUT :=3D $(saved_OUTPUT) + # $(run) contains all available tests run :=3D make_pure # Targets 'clean all' can be run together only through top level @@ -155,7 +187,7 @@ MAKE_F :=3D $(MAKE) -f $(MK) endif run +=3D make_python_perf_so run +=3D make_debug -ifneq ($(new_libbfd),) +ifeq ($(feature-libbfd-threadsafe),1) run +=3D 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 +=3D make_clang -ifneq ($(new_libbfd),) +ifeq ($(feature-libbfd-threadsafe),1) run +=3D make_clang_nondistro endif endif @@ -173,6 +205,12 @@ run +=3D make_extra_tests run +=3D make_no_jevents run +=3D make_jevents_all run +=3D make_no_bpf_skel +ifeq ($(have_clang_bpf),1) +run +=3D make_bpf_skel_clang +endif +ifeq ($(have_bpf_gcc),1) +run +=3D make_bpf_skel_bpf_gcc +endif run +=3D make_gen_vmlinux_h run +=3D make_no_python_module run +=3D make_no_scripts @@ -306,13 +344,20 @@ test_make_libbpf_dynamic_O :=3D ldd $$TMP_O/perf | gr= ep -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 :=3D test -x $(PERF_O)/perf && $(PERF_O)/per= f check -q feature libLLVM test_make_clang_O :=3D test -x $$TMP_O/perf && $$TMP_O/perf ch= eck -q feature libLLVM test_make_clang_nondistro :=3D $(test_make_clang) test_make_clang_nondistro_O :=3D $(test_make_clang_O) endif =20 +test_make_no_bpf_skel :=3D test -x $(PERF_O)/perf && ($(PERF_O)/pe= rf check -q feature bpf_skeletons; test $$? -eq 1) +test_make_no_bpf_skel_O :=3D test -x $$TMP_O/perf && ($$TMP_O/perf c= heck -q feature bpf_skeletons; test $$? -eq 1) +test_make_bpf_skel_clang :=3D test -x $(PERF_O)/perf && $(PERF_O)/per= f check -q feature bpf_skeletons +test_make_bpf_skel_clang_O :=3D test -x $$TMP_O/perf && $$TMP_O/perf ch= eck -q feature bpf_skeletons +test_make_bpf_skel_bpf_gcc :=3D test -x $(PERF_O)/perf && $(PERF_O)/per= f check -q feature bpf_skeletons +test_make_bpf_skel_bpf_gcc_O :=3D test -x $$TMP_O/perf && $$TMP_O/perf ch= eck -q feature bpf_skeletons + test_make_python_perf_so_O :=3D test -f $$TMP_O/python/perf.so test_make_perf_o_O :=3D test -f $$TMP_O/perf.o test_make_util_map_o_O :=3D 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 t= he # dependency and the 'FEATURES_DUMP=3D' append below. -no_features_dump :=3D make_clang make_clang_nondistro +no_features_dump :=3D make_clang make_clang_nondistro make_bpf_skel_clang = make_bpf_skel_bpf_gcc no_features_dump +=3D $(addsuffix _O,$(no_features_dump)) =20 # Add feature dump dependency for run/run_O targets --=20 2.56.0.307.g5fe7bd680c-goog