All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>,
	Nicolas Schier <nsc@kernel.org>,
	linux-kbuild@vger.kernel.org
Cc: Shuah Khan <shuah@kernel.org>,
	linux-kselftest@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Ian Rogers <irogers@google.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	Sasha Levin <sashal@kernel.org>
Subject: [RFC PATCH 3/6] tools: build perf in tools_build
Date: Sun, 11 Oct 2026 19:36:42 -0400	[thread overview]
Message-ID: <20261011233647.2454648-4-sashal@kernel.org> (raw)
In-Reply-To: <20261011233647.2454648-1-sashal@kernel.org>

Add CONFIG_TOOLS_BUILD_PERF. perf is built as it is built standalone,
with optional features enabled when their libraries are installed, and
with -Werror following CONFIG_WERROR. The feature table is left out of
the kernel build log.

CONFIG_TOOLS_BUILD_PERF_MINIMAL turns every optional feature off
instead, so the result does not depend on the build machine. allmodconfig
and allyesconfig turn it on.

Assisted-by: LLM
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/Kconfig         | 15 +++++++++++++++
 tools/Makefile.kbuild | 19 +++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/tools/Kconfig b/tools/Kconfig
index bf0643b39b86e..488f439592150 100644
--- a/tools/Kconfig
+++ b/tools/Kconfig
@@ -59,6 +59,21 @@ config TOOLS_BUILD_IIO
 	help
 	  Build tools/iio (lsiio, iio_event_monitor, iio_generic_buffer).
 
+config TOOLS_BUILD_PERF
+	bool "perf"
+	help
+	  Build tools/perf. As in a standalone perf build, optional
+	  features are enabled when the libraries they need are installed.
+
+config TOOLS_BUILD_PERF_MINIMAL
+	bool "Build perf with all optional features disabled"
+	depends on TOOLS_BUILD_PERF
+	help
+	  Turn off every optional perf feature, so that the result does
+	  not depend on which libraries the build machine has installed.
+	  allmodconfig and allyesconfig turn this on, which keeps their
+	  builds the same on every machine.
+
 config TOOLS_BUILD_SPI
 	bool "SPI tools"
 	help
diff --git a/tools/Makefile.kbuild b/tools/Makefile.kbuild
index 820a2d9a3893b..62fd494253eca 100644
--- a/tools/Makefile.kbuild
+++ b/tools/Makefile.kbuild
@@ -73,6 +73,25 @@ PHONY += $(tool-targets)
 $(tool-targets): tool-%: FORCE
 	$(call build,$(outdir)/$*,-C $(toolsdir)/$* O=$(outdir)/$* CC='$(call escsq,$(tools-cc))',,TOOLS_BUILD_$(shell echo $* | tr a-z A-Z))
 
+# perf, without the feature table in the kernel build log
+perf-flags := CC='$(call escsq,$(tools-cc))' FEATURE_DISPLAY= WERROR=$(if $(CONFIG_WERROR),1,0)
+
+# Every optional feature off, so the result does not depend on which
+# libraries are installed
+perf-flags-$(CONFIG_TOOLS_BUILD_PERF_MINIMAL) += \
+	NO_LIBELF=1 NO_LIBTRACEEVENT=1 NO_JEVENTS=1 NO_LIBPYTHON=1 NO_LIBDW=1 \
+	NO_LIBBPF=1 BUILD_BPF_SKEL=0 NO_SLANG=1 NO_GTK2=1 NO_AIO=1 \
+	NO_BACKTRACE=1 NO_DEMANGLE=1 NO_LZMA=1 NO_LIBZSTD=1 NO_ZLIB=1 \
+	NO_LIBNUMA=1 NO_LIBUNWIND=1 NO_LIBLLVM=1 NO_CAPSTONE=1 NO_LIBPFM4=1 \
+	NO_SDT=1 NO_JVMTI=1 NO_LIBDEBUGINFOD=1 NO_BABELTRACE2=1 NO_RUST=1 \
+	NO_SHELLCHECK=1 NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1
+
+__tools_build: $(if $(CONFIG_TOOLS_BUILD_PERF),perf)
+
+PHONY += perf
+perf: FORCE
+	$(call build,$(outdir)/perf,-C $(toolsdir)/perf -f Makefile.perf O=$(outdir)/perf $(perf-flags) $(perf-flags-y),,TOOLS_BUILD_PERF)
+
 PHONY += FORCE
 FORCE:
 
-- 
2.53.0


  parent reply	other threads:[~2026-10-11 23:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-11 23:36 [RFC PATCH 0/6] kbuild: build the userspace tools in tools/ with the kernel Sasha Levin
2026-10-11 23:36 ` [RFC PATCH 1/6] kbuild: factor the userspace ABI flags out into KBUILD_USERABI Sasha Levin
2026-10-11 23:39   ` sashiko-bot
2026-10-13 20:31   ` Thomas Weißschuh
2026-10-11 23:36 ` [RFC PATCH 2/6] kbuild: add "make tools_build" to build userspace tools from tools/ Sasha Levin
2026-10-11 23:45   ` sashiko-bot
2026-10-13 20:38   ` Thomas Weißschuh
2026-10-11 23:36 ` Sasha Levin [this message]
2026-10-11 23:43   ` [RFC PATCH 3/6] tools: build perf in tools_build sashiko-bot
2026-10-12 22:07   ` Ian Rogers
2026-10-13 17:08     ` Sasha Levin
2026-10-13 20:21       ` Arnaldo Carvalho de Melo
2026-10-11 23:36 ` [RFC PATCH 4/6] tools: build kernel selftests " Sasha Levin
2026-10-11 23:46   ` sashiko-bot
2026-10-13 19:29   ` Shuah Khan
2026-10-13 20:41   ` Thomas Weißschuh
2026-10-11 23:36 ` [RFC PATCH 5/6] kbuild: build the tools selected in tools/Kconfig as part of "make all" Sasha Levin
2026-10-11 23:44   ` sashiko-bot
2026-10-11 23:36 ` [RFC PATCH 6/6] Documentation: describe building tools with the kernel Sasha Levin
2026-10-11 23:39   ` 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=20261011233647.2454648-4-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=acme@kernel.org \
    --cc=irogers@google.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=shuah@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.