All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sasha Levin" <sashal@kernel.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nicolas Schier" <nsc@kernel.org>,
	linux-kbuild@vger.kernel.org
Cc: "Shuah Khan" <shuah@kernel.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Arnaldo Carvalho de Melo" <acme@kernel.org>,
	"Namhyung Kim" <namhyung@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
	"Jiri Olsa" <jolsa@kernel.org>, "Ian Rogers" <irogers@google.com>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	"James Clark" <james.clark@linaro.org>,
	linux-perf-users@vger.kernel.org,
	"Thomas Weißschuh" <linux@weissschuh.net>,
	"Andrew Morton" <akpm@linux-foundation.org>
Subject: Re: [RFC PATCH v2 2/7] kbuild: add "make tools_build" to build userspace tools from tools/
Date: Sat, 17 Oct 2026 14:32:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-175553@kernel.org> (raw)
In-Reply-To: <20261016143143.3613501-3-sashal@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] kbuild: flawed dry-run detection breaks incremental rebuilds
--

commit af4d0e2311f445e8ceb17d3fd81b05fa2c242614
Author: Sasha Levin <sashal@kernel.org>

kbuild: add "make tools_build" to build userspace tools from tools/

This commit adds a new target to build userspace tools from the tools/
directory as part of the kernel build process. It introduces a Kconfig
menu and a Makefile for building the selected programs independently.

> diff --git a/tools/Makefile.kbuild b/tools/Makefile.kbuild
> new file mode 100644
> index 0000000000000..8cfa7f80039cd
> --- /dev/null
> +++ b/tools/Makefile.kbuild

[ ... ]

> +# $(call build,<output directory>,<make arguments>,<files to check>,<CONFIG_ symbol>)
> +# Builds in an empty directory when the make arguments or LDFLAGS changed, or
> +# when one of the files is newer than the last build. "make -n" only shows
> +# the build.
> +build-key = $(call escsq,$(2) LDFLAGS=$(USERLDFLAGS))
> +dry-run := $(findstring n,$(firstword -$(MAKEFLAGS)))

[Severity: Medium]
Could this dry-run detection logic produce a false positive for common make
arguments?

If MAKEFLAGS starts with a long option containing 'n' (such as Kbuild's
frequent default --no-print-directory), -$(MAKEFLAGS) evaluates to something
like ---no-print-directory, and findstring erroneously matches the letter 'n'.

When evaluated as a dry run, the Makefile silently skips creating the
.tools_build tracking file and refuses to clear out stale objects, which breaks
incremental rebuilds.

Is it possible to use the standard Kbuild idiom here, like
$(findstring n,$(filter-out --%,$(MAKEFLAGS))), to properly check the flags?

> +
> +define build
> +	+$(Q)$(if $(dry-run),,if [ "$$(cat $(1)/.tools_build 2>/dev/null)" != '$(build-key)' ] $(if $(3),|| \
> +	   [ -n "$$(find $(3) -newer $(1)/.tools_build -print -quit 2>/dev/null)" ]); then \
> +		rm -rf $(1); \
> +	fi;) \
> +	mkdir -p $(1) && $(MAKE) $(2) && \
> +	$(if $(dry-run),:,printf '%s' '$(build-key)' > $(1)/.tools_build) || \
> +	{ echo >&2 "tools_build: $(patsubst $(outdir)/%,%,$(1)) failed to build; set CONFIG_$(4)=n to skip it"; false; }
> +endef

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261016143143.3613501-1-sashal@kernel.org?part=2

  reply	other threads:[~2026-10-17 14:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16 14:31 [RFC PATCH v2 0/7] kbuild: build the userspace tools in tools/ with the kernel Sasha Levin
2026-10-16 14:31 ` [RFC PATCH v2 1/7] kbuild: factor the userspace ABI flags out into KBUILD_USERABI Sasha Levin
2026-10-17 14:32   ` sashiko-bot
2026-10-16 14:31 ` [RFC PATCH v2 2/7] kbuild: add "make tools_build" to build userspace tools from tools/ Sasha Levin
2026-10-17 14:32   ` sashiko-bot [this message]
2026-10-16 14:31 ` [RFC PATCH v2 3/7] perf build: Add MINIMAL=1 to build without optional features Sasha Levin
2026-10-16 15:41   ` Ian Rogers
2026-10-17 14:32   ` sashiko-bot
2026-10-16 14:31 ` [RFC PATCH v2 4/7] tools: build perf in tools_build Sasha Levin
2026-10-17 14:32   ` sashiko-bot
2026-10-16 14:31 ` [RFC PATCH v2 5/7] tools: build kernel selftests " Sasha Levin
2026-10-16 16:17   ` Shuah Khan
2026-10-17 14:32   ` sashiko-bot
2026-10-16 14:31 ` [RFC PATCH v2 6/7] kbuild: build the tools selected in tools/Kconfig as part of "make all" Sasha Levin
2026-10-17 14:32   ` sashiko-bot
2026-10-16 14:31 ` [RFC PATCH v2 7/7] Documentation: describe building tools with the kernel Sasha Levin
2026-10-17 14:32   ` 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=sashiko-outbox-175553@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sashal@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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.