Skip to contentSkip to conversation

glibc: improve reproducibility with multilib

PATCH In review Juro Bystricky 2 participants 3 messages Feb 5, 2018 – Feb 6, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 glibc: improve reproducibility with multilib

Multilib builds specify several loaders which will end up embedded in some binaries or script files. To support reproducible builds, we must ensure the loaders are always in deterministic order.

[YOCTO #2655]
[YOCTO #12478]
[YOCTO #12480]

---
 meta/recipes-core/glibc/glibc-ld.inc  | 4 ++--
 meta/recipes-core/glibc/glibc_2.26.bb | 8 +++-----
 2 files changed, 5 insertions(+), 7 deletions(-)
meta/recipes-core/glibc/glibc-ld.inc +2 -2
index c1d635d..607b27c 100644
@@ -38,8 +38,8 @@ def glibc_dl_info(d):
         overrides = localdata.getVar("OVERRIDES", False) + ":virtclass-multilib-" + item
         localdata.setVar("OVERRIDES", overrides)
         ld_append_if_tune_exists(localdata, infos, ld_info_all)
-    infos['ldconfig'] = ','.join(infos['ldconfig'])
-    infos['lddrewrite'] = ' '.join(infos['lddrewrite'])
+    infos['ldconfig'] = ','.join(sorted(infos['ldconfig']))
+    infos['lddrewrite'] = ' '.join(sorted(infos['lddrewrite']))
     return infos
 
 EGLIBC_KNOWN_INTERPRETER_NAMES = "${@glibc_dl_info(d)['ldconfig']}"
meta/recipes-core/glibc/glibc_2.26.bb +3 -5
index 7eb56b3..df520bd 100644
@@ -133,12 +133,10 @@ do_compile () {
 	if [ -n "${RTLDLIST}" ]
 	then
 		prevrtld=`cat ${B}/elf/ldd | grep "^RTLDLIST=" | sed 's#^RTLDLIST="\?\([^"]*\)"\?$#\1#'`
-		if [ "${prevrtld}" != "${RTLDLIST}" ]
-		then
-			sed -i ${B}/elf/ldd -e "s#^RTLDLIST=.*\$#RTLDLIST=\"${prevrtld} ${RTLDLIST}\"#"
-		fi
+		# remove duplicate entries
+		newrtld=`echo "${prevrtld} ${RTLDLIST}" | xargs -n1 | sort -u | xargs`
+		sed -i ${B}/elf/ldd -e "s#^RTLDLIST=.*\$#RTLDLIST=\"${newrtld}\"#"
 	fi
-
 }
 
 # Use the host locale archive when built for nativesdk so that we don't need to
Signature · 1 line
2.7.4
#1 lore raw
Quoted 46 lines · Juro Bystricky

Multilib builds specify several loaders which will end up embedded in some binaries or script files. To support reproducible builds, we must ensure the loaders are always in deterministic order.

[YOCTO #2655]
[YOCTO #12478]
[YOCTO #12480]

---
 meta/recipes-core/glibc/glibc-ld.inc  | 4 ++--
 meta/recipes-core/glibc/glibc_2.26.bb | 8 +++-----
 2 files changed, 5 insertions(+), 7 deletions(-)
meta/recipes-core/glibc/glibc-ld.inc +0 -0
index c1d635d..607b27c 100644
@@ -38,8 +38,8 @@ def glibc_dl_info(d):
         overrides = localdata.getVar("OVERRIDES", False) +

":virtclass-multilib-" + item
localdata.setVar("OVERRIDES", overrides) ld_append_if_tune_exists(localdata, infos, ld_info_all)

meta/recipes-core/glibc/glibc-ld.inc +2 -2
-    infos['ldconfig'] = ','.join(infos['ldconfig'])
-    infos['lddrewrite'] = ' '.join(infos['lddrewrite'])
+    infos['ldconfig'] = ','.join(sorted(infos['ldconfig']))
+    infos['lddrewrite'] = ' '.join(sorted(infos['lddrewrite']))
     return infos
 
 EGLIBC_KNOWN_INTERPRETER_NAMES = "${@glibc_dl_info(d)['ldconfig']}"
meta/recipes-core/glibc/glibc_2.26.bb +0 -0
index 7eb56b3..df520bd 100644
@@ -133,12 +133,10 @@ do_compile () {
        if [ -n "${RTLDLIST}" ]
        then
                prevrtld=`cat ${B}/elf/ldd | grep "^RTLDLIST=" | sed

's#^RTLDLIST="\?\([^"]*\)"\?$#\1#'`

meta/recipes-core/glibc/glibc_2.26.bb +0 -3
-               if [ "${prevrtld}" != "${RTLDLIST}" ]
-               then
-                       sed -i ${B}/elf/ldd -e

"s#^RTLDLIST=.*\$#RTLDLIST=\"${prevrtld} ${RTLDLIST}\"#"

meta/recipes-core/glibc/glibc_2.26.bb do_compile () {

Quoted 4 lines
meta/recipes-core/glibc/glibc_2.26.bb +2 -2
-               fi
+               # remove duplicate entries
+               newrtld=`echo "${prevrtld} ${RTLDLIST}" | xargs -n1 | sort
-u | xargs`

This “| xargs” at the end seems redundant. xargs what? xargs is used to run a command on each word of the input..

Signature · 4 lines
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics
#2 lore raw
Quoted 2 lines

This “| xargs” at the end seems redundant. xargs what? xargs is used to run a command on each word of > the input..

It forces the words into one line:

$ echo "zebra fox elephant elephant lion wolf fox " | xargs -n1 | sort -u | xargs
elephant fox lion wolf zebra

$echo "zebra fox elephant elephant lion wolf fox " | xargs -n1 | sort -u elephant
fox
lion
wolf
zebra