Re: [RFC PATCH v2 4/7] tools: build perf in tools_build

From: Namhyung Kim

Date: Wed Oct 21 2026 - 19:24:11 EST


On Fri, Oct 16, 2026 at 10:31:40AM -0400, Sasha Levin wrote:
> Add CONFIG_TOOLS_BUILD_PERF. perf is built as it is built standalone,
> with optional features enabled when their libraries are installed, and
> with perf's WERROR setting following CONFIG_WERROR. The feature table is
> left out of the kernel build log.
>
> CONFIG_TOOLS_BUILD_PERF_MINIMAL builds it with MINIMAL=1 instead, which
> turns every optional feature off, 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@xxxxxxxxxx>

Acked-by: Namhyung Kim <namhyung@xxxxxxxxxx>

Thanks,
Namhyung

> ---
> tools/Kconfig | 16 ++++++++++++++++
> tools/Makefile.kbuild | 10 ++++++++++
> 2 files changed, 26 insertions(+)
>
> diff --git a/tools/Kconfig b/tools/Kconfig
> index 2d05c8e593e21..4f13e3b104377 100644
> --- a/tools/Kconfig
> +++ b/tools/Kconfig
> @@ -60,6 +60,22 @@ 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
> + Build perf with MINIMAL=1, which turns off every optional
> + 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 8cfa7f80039cd..4b3ea73bc8ab9 100644
> --- a/tools/Makefile.kbuild
> +++ b/tools/Makefile.kbuild
> @@ -79,6 +79,16 @@ 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)
> +perf-flags-$(CONFIG_TOOLS_BUILD_PERF_MINIMAL) += MINIMAL=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
>