All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacob Kroon <jacob.kroon@gmail.com>
To: openembedded-core@lists.openembedded.org
Subject: [RFC PATCH 1/9] bitbake.conf: Pad rpath and remove build ID in native binaries
Date: Sun, 28 Nov 2021 10:45:24 +0100	[thread overview]
Message-ID: <20211128094532.1145820-2-jacob.kroon@gmail.com> (raw)
In-Reply-To: <20211128094532.1145820-1-jacob.kroon@gmail.com>

Try to make sure that the RUNTIME dynamic entry size is the same for all
binaries produced with the native compiler. This is necessary in order to
produce identical binaries when using differently sized buildpaths. I've
tried using only patchelf, and keeping the linker flags as they are, but
I am unable to produce identical binaries. Has anyone else managed to do
this with patchelf ? If not, maybe we can write a new tool that can handle it ?

The build-id also needs to be removed since it is calculated based on
the data present at link time. This includes STAGING_LIBDIR_NATIVE
and STAGING_BASE_LIBDIR_NATIVE. Both will differ and they need to be temporarily
preserved since some recipes will execute the binaries during do_install()
(for example python3-native). Later on these are removed in chrpath.bbclass.

This hack is the first step for producing identical native binaries when using
different build paths. 'zstd-native' is a working example.

Signed-off-by: Jacob Kroon <jacob.kroon@gmail.com>
---
 meta/classes/chrpath.bbclass | 3 +++
 meta/conf/bitbake.conf       | 6 +++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/meta/classes/chrpath.bbclass b/meta/classes/chrpath.bbclass
index 26b984c4db..3c6956304a 100644
--- a/meta/classes/chrpath.bbclass
+++ b/meta/classes/chrpath.bbclass
@@ -24,6 +24,9 @@ def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlin
     new_rpaths = []
     modified = False
     for rpath in rpaths:
+        if rpath.startswith('rpath-padding-'):
+            modified = True
+            continue
         # If rpath is already dynamic copy it to new_rpath and continue
         if rpath.find("$ORIGIN") != -1:
             new_rpaths.append(rpath)
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index fba99e8f0c..9621023354 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -580,6 +580,8 @@ BUILDSDK_CXXFLAGS = "${BUILDSDK_CFLAGS}"
 export CXXFLAGS = "${TARGET_CXXFLAGS}"
 TARGET_CXXFLAGS = "${TARGET_CFLAGS}"
 
+RPATH_PADDING ?= "rpath-padding-${@'x' * (512 - len(d.expand('${STAGING_LIBDIR_NATIVE}:${STAGING_BASE_LIBDIR_NATIVE}:rpath-padding-')))}"
+RPATH_PADDING_FLAG ?= "-Wl,-rpath,${RPATH_PADDING}"
 export BUILD_LDFLAGS = "-L${STAGING_LIBDIR_NATIVE} \
                         -L${STAGING_BASE_LIBDIR_NATIVE} \
                         -Wl,--enable-new-dtags \
@@ -587,7 +589,9 @@ export BUILD_LDFLAGS = "-L${STAGING_LIBDIR_NATIVE} \
                         -Wl,-rpath-link,${STAGING_BASE_LIBDIR_NATIVE} \
                         -Wl,-rpath,${STAGING_LIBDIR_NATIVE} \
                         -Wl,-rpath,${STAGING_BASE_LIBDIR_NATIVE} \
-                        -Wl,-O1"
+                        ${RPATH_PADDING_FLAG} \
+                        -Wl,-O1 \
+                        -Wl,--build-id=none"
 
 BUILDSDK_LDFLAGS = "-Wl,-O1"
 


  reply	other threads:[~2021-11-28  9:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-28  9:45 [RFC PATCH 0/9] Improve native/cross reproducibility Jacob Kroon
2021-11-28  9:45 ` Jacob Kroon [this message]
2021-11-28  9:45 ` [RFC PATCH 2/9] libtool: Improve native reproducibility Jacob Kroon
2021-11-28  9:45 ` [RFC PATCH 3/9] openssl: " Jacob Kroon
2021-11-28  9:45 ` [RFC PATCH 4/9] perl/perlcross: Improve native reproducability Jacob Kroon
2021-11-29  9:07   ` [OE-core] " Alexander Kanavin
2021-11-29 16:44     ` Jacob Kroon
2021-11-29 19:42       ` Alexander Kanavin
     [not found]       ` <16BC1BD946BFDDCE.26361@lists.openembedded.org>
2021-11-29 20:14         ` Alexander Kanavin
2021-11-28  9:45 ` [RFC PATCH 5/9] pkgconfig: Improve native reproducibility Jacob Kroon
2021-11-28  9:45 ` [RFC PATCH 6/9] ncurses: " Jacob Kroon
2021-11-28  9:45 ` [RFC PATCH 7/9] util-linux: " Jacob Kroon
2021-11-28  9:45 ` [RFC PATCH 8/9] python3: " Jacob Kroon
2021-11-28  9:45 ` [RFC PATCH 9/9] bitbake.conf: Avoid rpath hack for Java recipes Jacob Kroon
2021-11-29  9:16 ` [OE-core] [RFC PATCH 0/9] Improve native/cross reproducibility Alexander Kanavin
2021-11-29 16:42   ` Jacob Kroon

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=20211128094532.1145820-2-jacob.kroon@gmail.com \
    --to=jacob.kroon@gmail.com \
    --cc=openembedded-core@lists.openembedded.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.