[V2] glibc: improve reproducibility with multilib

Submitted by Hongxu Jia on Dec. 6, 2018, 8:56 a.m. | Patch ID: 156953

Details

Message ID 1544086575-9621-1-git-send-email-hongxu.jia@windriver.com
State Accepted
Commit 3f839c0cdfe253677ebee47838fe476a0939e0aa
Headers show

Commit Message

Hongxu Jia Dec. 6, 2018, 8:56 a.m.
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]

Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>

Improve the fix and rebase it to 2.28

Here is the log of lib32-glibc
[log.do_compile]
|Adjust ldd script
|ldd "/lib64/ld-linux-x86-64.so.2 /lib/ld-linux.so.2 /lib/ld-linux.so.2
/lib64/ld-linux-x86-64.so.2" -> "/lib/ld-linux.so.2 /lib64/ld-linux-x86-64.so.2"
[log.do_compile]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/recipes-core/glibc/glibc-ld.inc  | 4 ++--
 meta/recipes-core/glibc/glibc_2.28.bb | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta/recipes-core/glibc/glibc-ld.inc b/meta/recipes-core/glibc/glibc-ld.inc
index bb167b3..041ffbb 100644
--- a/meta/recipes-core/glibc/glibc-ld.inc
+++ b/meta/recipes-core/glibc/glibc-ld.inc
@@ -10,8 +10,8 @@  def glibc_dl_info(d):
         infos['ldconfig'].add('{"' + loader + '",' + "FLAG_ELF_LIBC6" + ' }')
         infos['lddrewrite'].add(loader)
 
-    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']}"
diff --git a/meta/recipes-core/glibc/glibc_2.28.bb b/meta/recipes-core/glibc/glibc_2.28.bb
index d072939..a107c58 100644
--- a/meta/recipes-core/glibc/glibc_2.28.bb
+++ b/meta/recipes-core/glibc/glibc_2.28.bb
@@ -122,10 +122,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 $(printf '%s\n' ${prevrtld} ${RTLDLIST} | LC_ALL=C sort -u)`
+		echo "ldd \"${prevrtld} ${RTLDLIST}\" -> \"${newrtld}\""
+		sed -i ${B}/elf/ldd -e "s#^RTLDLIST=.*\$#RTLDLIST=\"${newrtld}\"#"
 	fi
 
 }

Comments

Khem Raj Dec. 6, 2018, 4:04 p.m.
looks ok
On Thu, Dec 6, 2018 at 12:57 AM Hongxu Jia <hongxu.jia@windriver.com> wrote:
>
> 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]
>
> Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
>
> Improve the fix and rebase it to 2.28
>
> Here is the log of lib32-glibc
> [log.do_compile]
> |Adjust ldd script
> |ldd "/lib64/ld-linux-x86-64.so.2 /lib/ld-linux.so.2 /lib/ld-linux.so.2
> /lib64/ld-linux-x86-64.so.2" -> "/lib/ld-linux.so.2 /lib64/ld-linux-x86-64.so.2"
> [log.do_compile]
>
> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> ---
>  meta/recipes-core/glibc/glibc-ld.inc  | 4 ++--
>  meta/recipes-core/glibc/glibc_2.28.bb | 8 ++++----
>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/meta/recipes-core/glibc/glibc-ld.inc b/meta/recipes-core/glibc/glibc-ld.inc
> index bb167b3..041ffbb 100644
> --- a/meta/recipes-core/glibc/glibc-ld.inc
> +++ b/meta/recipes-core/glibc/glibc-ld.inc
> @@ -10,8 +10,8 @@ def glibc_dl_info(d):
>          infos['ldconfig'].add('{"' + loader + '",' + "FLAG_ELF_LIBC6" + ' }')
>          infos['lddrewrite'].add(loader)
>
> -    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']}"
> diff --git a/meta/recipes-core/glibc/glibc_2.28.bb b/meta/recipes-core/glibc/glibc_2.28.bb
> index d072939..a107c58 100644
> --- a/meta/recipes-core/glibc/glibc_2.28.bb
> +++ b/meta/recipes-core/glibc/glibc_2.28.bb
> @@ -122,10 +122,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 $(printf '%s\n' ${prevrtld} ${RTLDLIST} | LC_ALL=C sort -u)`
> +               echo "ldd \"${prevrtld} ${RTLDLIST}\" -> \"${newrtld}\""
> +               sed -i ${B}/elf/ldd -e "s#^RTLDLIST=.*\$#RTLDLIST=\"${newrtld}\"#"
>         fi
>
>  }
> --
> 2.7.4
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core