* [PATCH v1] tools build: Fix feature checks to touch target files on success
@ 2026-05-31 1:09 Ian Rogers
2026-06-04 13:38 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2026-05-31 1:09 UTC (permalink / raw)
To: Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Arnaldo Carvalho de Melo, Namhyung Kim, Dmitrii Dolgov,
James Clark, Leo Yan, Costa Shulyupin, Yuzhuo Jing, linux-kernel,
bpf, llvm
Cc: linux-perf-users, Ian Rogers
In tools/build/feature/Makefile, test-clang-bpf-co-re.bin and
test-bpftool-skeletons.bin redirected grep output but never touched or
created the $@ target file upon success.
Because the target file was never created on disk, Kbuild could never cache
the result of the check. Consequently, Make treated the prerequisite as
missing and continuously re-executed the Clang BPF backend and bpftool
feature checks on every single sub-make evaluation during build startup, or
on every incremental build.
Refactor both feature check recipes to touch $@ on success. For
test-clang-bpf-co-re.bin, group the shell pipeline within curly braces
and redirect both stdout and stderr to .make.output to allow errors to
be inspected and not appear in build output. List
test-clang-bpf-co-re.bin's input C file as a dependency so
modification triggers a rebuild. For test-bpftool-skeletons.bin, add
it to the FILES list so that it will be cleaned.
Tested-by: James Clark <james.clark@linaro.org>
Assisted-by: Gemini:gemini-3.1-pro-preview
Signed-off-by: Ian Rogers <irogers@google.com>
---
This patch originally appeared in the now merged perf patch series:
https://lore.kernel.org/linux-perf-users/20260518154638.2798789-1-irogers@google.com/
---
tools/build/feature/Makefile | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 704c687ed3ad..5b4a984973c4 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -75,7 +75,8 @@ FILES= \
test-file-handle.bin \
test-libpfm4.bin \
test-rust.bin \
- test-libopenssl.bin
+ test-libopenssl.bin \
+ test-bpftool-skeletons.bin
FILES := $(addprefix $(OUTPUT),$(FILES))
@@ -383,9 +384,9 @@ $(OUTPUT)test-libaio.bin:
$(OUTPUT)test-libzstd.bin:
$(BUILD) -lzstd
-$(OUTPUT)test-clang-bpf-co-re.bin:
- $(CLANG) -S -g --target=bpf -o - $(patsubst %.bin,%.c,$(@F)) | \
- grep BTF_KIND_VAR
+$(OUTPUT)test-clang-bpf-co-re.bin: test-clang-bpf-co-re.c
+ { $(CLANG) -S -g --target=bpf -o - $< | \
+ grep BTF_KIND_VAR; } > $(@:.bin=.make.output) 2>&1 && touch $@
$(OUTPUT)test-file-handle.bin:
$(BUILD)
@@ -397,8 +398,8 @@ $(OUTPUT)test-libopenssl.bin:
$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags openssl 2>/dev/null)
$(OUTPUT)test-bpftool-skeletons.bin:
- $(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons' \
- > $(@:.bin=.make.output) 2>&1
+ { $(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons'; } \
+ > $(@:.bin=.make.output) 2>&1 && touch $@
# Testing Rust is special: we don't compile anything, it's enough to check the
# compiler presence. Compiling a test code for this purposes is problematic,
--
2.54.0.823.g6e5bcc1fc9-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] tools build: Fix feature checks to touch target files on success
2026-05-31 1:09 [PATCH v1] tools build: Fix feature checks to touch target files on success Ian Rogers
@ 2026-06-04 13:38 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-06-04 13:38 UTC (permalink / raw)
To: Ian Rogers
Cc: Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Namhyung Kim, Dmitrii Dolgov, James Clark, Leo Yan,
Costa Shulyupin, Yuzhuo Jing, linux-kernel, bpf, llvm,
linux-perf-users
On Sat, May 30, 2026 at 06:09:24PM -0700, Ian Rogers wrote:
> In tools/build/feature/Makefile, test-clang-bpf-co-re.bin and
> test-bpftool-skeletons.bin redirected grep output but never touched or
> created the $@ target file upon success.
>
> Because the target file was never created on disk, Kbuild could never cache
> the result of the check. Consequently, Make treated the prerequisite as
> missing and continuously re-executed the Clang BPF backend and bpftool
> feature checks on every single sub-make evaluation during build startup, or
> on every incremental build.
>
> Refactor both feature check recipes to touch $@ on success. For
> test-clang-bpf-co-re.bin, group the shell pipeline within curly braces
> and redirect both stdout and stderr to .make.output to allow errors to
> be inspected and not appear in build output. List
> test-clang-bpf-co-re.bin's input C file as a dependency so
> modification triggers a rebuild. For test-bpftool-skeletons.bin, add
> it to the FILES list so that it will be cleaned.
>
> Tested-by: James Clark <james.clark@linaro.org>
Thanks, applied to perf-tools-next, for v7.2.
- Arnaldo
> Assisted-by: Gemini:gemini-3.1-pro-preview
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> This patch originally appeared in the now merged perf patch series:
> https://lore.kernel.org/linux-perf-users/20260518154638.2798789-1-irogers@google.com/
> ---
> tools/build/feature/Makefile | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> index 704c687ed3ad..5b4a984973c4 100644
> --- a/tools/build/feature/Makefile
> +++ b/tools/build/feature/Makefile
> @@ -75,7 +75,8 @@ FILES= \
> test-file-handle.bin \
> test-libpfm4.bin \
> test-rust.bin \
> - test-libopenssl.bin
> + test-libopenssl.bin \
> + test-bpftool-skeletons.bin
>
> FILES := $(addprefix $(OUTPUT),$(FILES))
>
> @@ -383,9 +384,9 @@ $(OUTPUT)test-libaio.bin:
> $(OUTPUT)test-libzstd.bin:
> $(BUILD) -lzstd
>
> -$(OUTPUT)test-clang-bpf-co-re.bin:
> - $(CLANG) -S -g --target=bpf -o - $(patsubst %.bin,%.c,$(@F)) | \
> - grep BTF_KIND_VAR
> +$(OUTPUT)test-clang-bpf-co-re.bin: test-clang-bpf-co-re.c
> + { $(CLANG) -S -g --target=bpf -o - $< | \
> + grep BTF_KIND_VAR; } > $(@:.bin=.make.output) 2>&1 && touch $@
>
> $(OUTPUT)test-file-handle.bin:
> $(BUILD)
> @@ -397,8 +398,8 @@ $(OUTPUT)test-libopenssl.bin:
> $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags openssl 2>/dev/null)
>
> $(OUTPUT)test-bpftool-skeletons.bin:
> - $(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons' \
> - > $(@:.bin=.make.output) 2>&1
> + { $(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons'; } \
> + > $(@:.bin=.make.output) 2>&1 && touch $@
>
> # Testing Rust is special: we don't compile anything, it's enough to check the
> # compiler presence. Compiling a test code for this purposes is problematic,
> --
> 2.54.0.823.g6e5bcc1fc9-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-04 13:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-31 1:09 [PATCH v1] tools build: Fix feature checks to touch target files on success Ian Rogers
2026-06-04 13:38 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox