* [PATCH] libperf: fix parallel build race with header install
@ 2026-04-14 7:12 Gaurav Sharma
2026-04-14 13:13 ` Ian Rogers
0 siblings, 1 reply; 2+ messages in thread
From: Gaurav Sharma @ 2026-04-14 7:12 UTC (permalink / raw)
To: linux-perf-users
Cc: acme, namhyung, irogers, stable, linux-kernel, Gaurav Sharma
When perf is built with high parallelism (-j128), there is a race
condition between the install_headers and libperf.a targets in the
libperf sub-build. Both are invoked as targets of a single make
invocation from Makefile.perf:
$(MAKE) -C $(LIBPERF_DIR) ... $@ install_headers
The perf tool's exported CFLAGS includes -I$(LIBPERF_OUTPUT)/include
which points to the header install destination. The coreutils install
command creates the destination file (truncated) before writing content.
If the compiler runs between file creation and content write, it
includes an empty header, causing incomplete type and missing prototype
errors in the libperf source files.
Fix this by making the libperf compilation target depend on
install_headers, ensuring all headers are fully installed before any
source files are compiled.
Fixes: 91009a3a9913 ("perf build: Install libperf locally when building")
Cc: stable@vger.kernel.org
Signed-off-by: Gaurav Sharma <mgsharm@amazon.com>
---
tools/lib/perf/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lib/perf/Makefile b/tools/lib/perf/Makefile
index 32301a1d8f0c..8372cd9919b7 100644
--- a/tools/lib/perf/Makefile
+++ b/tools/lib/perf/Makefile
@@ -99,7 +99,7 @@ $(LIBAPI)-clean:
$(call QUIET_CLEAN, libapi)
$(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
-$(LIBPERF_IN): FORCE
+$(LIBPERF_IN): install_headers FORCE
$(Q)$(MAKE) $(build)=libperf
$(LIBPERF_A): $(LIBPERF_IN)
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] libperf: fix parallel build race with header install
2026-04-14 7:12 [PATCH] libperf: fix parallel build race with header install Gaurav Sharma
@ 2026-04-14 13:13 ` Ian Rogers
0 siblings, 0 replies; 2+ messages in thread
From: Ian Rogers @ 2026-04-14 13:13 UTC (permalink / raw)
To: Gaurav Sharma
Cc: linux-perf-users, acme, namhyung, stable, linux-kernel,
Gaurav Sharma
On Tue, Apr 14, 2026 at 12:13 AM Gaurav Sharma <sgaurav00719@gmail.com> wrote:
>
> When perf is built with high parallelism (-j128), there is a race
> condition between the install_headers and libperf.a targets in the
> libperf sub-build. Both are invoked as targets of a single make
> invocation from Makefile.perf:
>
> $(MAKE) -C $(LIBPERF_DIR) ... $@ install_headers
>
> The perf tool's exported CFLAGS includes -I$(LIBPERF_OUTPUT)/include
> which points to the header install destination. The coreutils install
> command creates the destination file (truncated) before writing content.
> If the compiler runs between file creation and content write, it
> includes an empty header, causing incomplete type and missing prototype
> errors in the libperf source files.
>
> Fix this by making the libperf compilation target depend on
> install_headers, ensuring all headers are fully installed before any
> source files are compiled.
>
> Fixes: 91009a3a9913 ("perf build: Install libperf locally when building")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gaurav Sharma <mgsharm@amazon.com>
I believe this was addressed by:
https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/commit/tools/lib/perf/Makefile?h=perf-tools-next&id=8c5b40678c63be6b85f1c2dc8c8b89d632faf988
Thanks,
Ian
> ---
> tools/lib/perf/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/lib/perf/Makefile b/tools/lib/perf/Makefile
> index 32301a1d8f0c..8372cd9919b7 100644
> --- a/tools/lib/perf/Makefile
> +++ b/tools/lib/perf/Makefile
> @@ -99,7 +99,7 @@ $(LIBAPI)-clean:
> $(call QUIET_CLEAN, libapi)
> $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
>
> -$(LIBPERF_IN): FORCE
> +$(LIBPERF_IN): install_headers FORCE
> $(Q)$(MAKE) $(build)=libperf
>
> $(LIBPERF_A): $(LIBPERF_IN)
> --
> 2.50.1 (Apple Git-155)
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-14 13:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-14 7:12 [PATCH] libperf: fix parallel build race with header install Gaurav Sharma
2026-04-14 13:13 ` Ian Rogers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox