diff mbox series

perf: Fix reproducibility issue

Message ID 20250911113830.1488467-1-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit 0a886fcacaab0fbce1306c0f99d482f940a8f705
Headers show
Series perf: Fix reproducibility issue | expand

Commit Message

Richard Purdie Sept. 11, 2025, 11:38 a.m. UTC
Perf's build process generates two copies of its internal headers,
one at tools/lib/perf/include/internal and one at libperf/include/internal
with files like xyarray.h. Although the files are identical, the binaries including
them would see them at different paths and have different debuginfo data.

To avoid this, build libperf.a first, which will ensure the libperf
headers directory exists. This is used in preference to the other by
the build process and results in consistent binaries.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/recipes-kernel/perf/perf.bb | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Bruce Ashfield Sept. 11, 2025, 1:01 p.m. UTC | #1
On Thu, Sep 11, 2025 at 7:38 AM Richard Purdie via lists.openembedded.org
<richard.purdie=linuxfoundation.org@lists.openembedded.org> wrote:

> Perf's build process generates two copies of its internal headers,
> one at tools/lib/perf/include/internal and one at libperf/include/internal
> with files like xyarray.h. Although the files are identical, the binaries
> including
> them would see them at different paths and have different debuginfo data.
>
> To avoid this, build libperf.a first, which will ensure the libperf
> headers directory exists. This is used in preference to the other by
> the build process and results in consistent binaries.
>

That explains the race.  I was looking at the Makefile's yesterday
and hadn't quite put my finger on what it was yet.

I've fought with the copies of those headers for years as well. It
was worse before we started copying the perf source code out
the way we do now.

I don't see any issues with the approach, I've done the same in
the past. It is better than options like moving them, removing them
or messing with -j1 builds, or new Makefile targets, etc.

With your comment explaining the situation in the code, we won't
even undo it by mistake :)

Acked-by: Bruce Ashfield <bruce.ashfield@gmail.com>


>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  meta/recipes-kernel/perf/perf.bb | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/
> perf.bb
> index b142b090b55..e1915207eed 100644
> --- a/meta/recipes-kernel/perf/perf.bb
> +++ b/meta/recipes-kernel/perf/perf.bb
> @@ -171,6 +171,10 @@ do_compile() {
>              sed -i -e
> 's|\$(libdir)/traceevent/plugins|\$(libdir)/traceevent_${KERNEL_VERSION}/plugins|g'
> ${S}/tools/lib/traceevent/plugins/Makefile
>         test -e ${S}/tools/perf/Makefile.config && \
>              sed -i -e
> 's|\$(libdir)/traceevent/plugins|\$(libdir)/traceevent_${KERNEL_VERSION}/plugins|g'
> ${S}/tools/perf/Makefile.config
> +       # There are two copies of internal headers such as:
> +       # libperf/include/internal/xyarray.h and
> tools/lib/perf/include/internal/xyarray.h
> +       # For reproducibile binaries, we need to find one copy, hence
> force libperf to be created first
> +       oe_runmake ${B}/libperf/libperf.a
>         oe_runmake all
>  }
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#223269):
> https://lists.openembedded.org/g/openembedded-core/message/223269
> Mute This Topic: https://lists.openembedded.org/mt/115186108/1050810
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> bruce.ashfield@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
diff mbox series

Patch

diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb
index b142b090b55..e1915207eed 100644
--- a/meta/recipes-kernel/perf/perf.bb
+++ b/meta/recipes-kernel/perf/perf.bb
@@ -171,6 +171,10 @@  do_compile() {
             sed -i -e 's|\$(libdir)/traceevent/plugins|\$(libdir)/traceevent_${KERNEL_VERSION}/plugins|g' ${S}/tools/lib/traceevent/plugins/Makefile
 	test -e ${S}/tools/perf/Makefile.config && \
             sed -i -e 's|\$(libdir)/traceevent/plugins|\$(libdir)/traceevent_${KERNEL_VERSION}/plugins|g' ${S}/tools/perf/Makefile.config
+	# There are two copies of internal headers such as:
+	# libperf/include/internal/xyarray.h and tools/lib/perf/include/internal/xyarray.h
+	# For reproducibile binaries, we need to find one copy, hence force libperf to be created first
+	oe_runmake ${B}/libperf/libperf.a
 	oe_runmake all
 }