[RFC,v3,3/4] bitbake.conf: Use dummy rpaths in native binaries

Message ID 20211204212940.3787349-4-jacob.kroon@gmail.com
State New
Headers show
Series Improve native/cross reproducibility | expand

Commit Message

Jacob Kroon Dec. 4, 2021, 9:29 p.m. UTC
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.

This is a 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 | 5 ++++-
 meta/conf/bitbake.conf       | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

Patch

diff --git a/meta/classes/chrpath.bbclass b/meta/classes/chrpath.bbclass
index 26b984c4db..a0f2cf0598 100644
--- a/meta/classes/chrpath.bbclass
+++ b/meta/classes/chrpath.bbclass
@@ -2,7 +2,7 @@  CHRPATH_BIN ?= "chrpath"
 PREPROCESS_RELOCATE_DIRS ?= ""
 
 def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlinks = False):
-    import subprocess, oe.qa
+    import subprocess, oe.qa, re
 
     with oe.qa.ELFFile(fpath) as elf:
         try:
@@ -20,6 +20,9 @@  def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d, break_hardlin
     # Throw away everything other than the rpath list
     curr_rpath = out.partition("RPATH=")[2]
     #bb.note("Current rpath for %s is %s" % (fpath, curr_rpath.strip()))
+    # Inject native libdir and baselibdir
+    curr_rpath = re.sub(r'/non/existent/libdir-native-marker-x+', d.expand('${STAGING_LIBDIR_NATIVE}'), curr_rpath)
+    curr_rpath = re.sub(r'/non/existent/base-libdir-native-marker-x+', d.expand('${STAGING_BASE_LIBDIR_NATIVE}'), curr_rpath)
     rpaths = curr_rpath.strip().split(":")
     new_rpaths = []
     modified = False
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index fba99e8f0c..1799127c2a 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -585,8 +585,8 @@  export BUILD_LDFLAGS = "-L${STAGING_LIBDIR_NATIVE} \
                         -Wl,--enable-new-dtags \
                         -Wl,-rpath-link,${STAGING_LIBDIR_NATIVE} \
                         -Wl,-rpath-link,${STAGING_BASE_LIBDIR_NATIVE} \
-                        -Wl,-rpath,${STAGING_LIBDIR_NATIVE} \
-                        -Wl,-rpath,${STAGING_BASE_LIBDIR_NATIVE} \
+                        -Wl,-rpath,${@'/non/existent/libdir-native-marker-'.ljust(256, 'x')} \
+                        -Wl,-rpath,${@'/non/existent/base-libdir-native-marker-'.ljust(256, 'x')} \
                         -Wl,-O1"
 
 BUILDSDK_LDFLAGS = "-Wl,-O1"