RPATH fixes: libtool & binutils
cover RPATH fixes: libtool & binutils
Current RPATH work:
Patch 1 just updates the libtool work to use the built-in normalization function instead of sed, as requested.
Patch 2 is to binutils ld, to fix the underlying host pollution issue:
the -rpath argument was not sysroot aware, so setting "/usr/lib/../lib" as an RPATH would add the host /usr/lib to the link time search path instead of the sysroot directory.
Note that the previous warning fix to insane.bbclass is still producing unmasked warnings in a few cases (the rpm utilities are one that I know), mostly in programs instead of libraries. These will need to be audited independently. It's possible that they are liking with -rpath directly and not using libtool, or that a needed normalization in libtool is still missing. But with the current patches these warnings are benign now, they can't break the build.
Andy
PATCH 1/2 libtool: update rpath normalization to use builtin
Use the built-in normalization function instead of the sed hack.
--- meta/recipes-devtools/libtool/libtool-2.4.2.inc | 2 +- .../libtool/libtool/norm-rpath.patch | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 15 deletions(-)
meta/recipes-devtools/libtool/libtool-2.4.2.inc +1 -1
@@ -8,7 +8,7 @@ LICENSE = "GPLv2 & LGPLv2.1" LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe \ file://libltdl/COPYING.LIB;md5=e3eda01d9815f8d24aae2dbd89b68b06" -INC_PR = "r4" +INC_PR = "r5" SRC_URI = "${GNU_MIRROR}/libtool/libtool-${PV}.tar.gz \ file://trailingslash.patch \
meta/recipes-devtools/libtool/libtool/norm-rpath.patch +8 -14
@@ -7,33 +7,27 @@ RPATH in the generated binary. Normalize before comparision. Signed-off-by: Andy Ross <[email protected]> Upstream-Status: Pending -diff -ru a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh +diff -ur a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh --- a/libltdl/config/ltmain.m4sh 2012-08-16 13:58:55.058900363 -0700 -+++ b/libltdl/config/ltmain.m4sh 2012-08-16 16:34:54.616627821 -0700 -@@ -7288,8 +7288,13 @@ ++++ b/libltdl/config/ltmain.m4sh 2012-08-22 11:01:34.191345989 -0700 +@@ -7288,8 +7288,10 @@ else # We only want to hardcode in an rpath if it isn't in the # default dlsearch path. -+ libdir_norm=`echo $libdir \ -+ | sed 's/\/\+\.\(\/\+\|$\)/\//g' \ -+ | sed 's/[^\/]\+\/\+\.\.\(\/\+\|$\)//g' \ -+ | sed 's/\/\+/\//g' \ -+ | sed 's/\(.\)\/$/\1/g'` ++ func_normal_abspath "$libdir" ++ libdir_norm=$func_normal_abspath_result case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; + *" $libdir_norm "*) ;; *) eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" ;; -@@ -8027,8 +8032,13 @@ +@@ -8027,8 +8029,10 @@ else # We only want to hardcode in an rpath if it isn't in the # default dlsearch path. -+ libdir_norm=`echo $libdir \ -+ | sed 's/\/\+\.\(\/\+\|$\)/\//g' \ -+ | sed 's/[^\/]\+\/\+\.\.\(\/\+\|$\)//g' \ -+ | sed 's/\/\+/\//g' \ -+ | sed 's/\(.\)\/$/\1/g'` ++ func_normal_abspath "$libdir" ++ libdir_norm=$func_normal_abspath_result case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; + *" $libdir_norm "*) ;;
Signature · 1 line
1.7.11.4
PATCH 2/2 ld: -rpath must search under sysroot
The -rpath argument would search the host filesystem for libraries, even when a sysroot was defined. For cross toolchains with targets compatible with the host architecture this can find incorrect libraries. Leave -rpath-link unmodified, as build systems in the wild are already using this to point to host directories.
[YOCTO #2965]
--- meta/recipes-devtools/binutils/binutils-2.22.inc | 3 +- .../binutils/binutils/rpath-sysroot.patch | 38 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-devtools/binutils/binutils/rpath-sysroot.patch
meta/recipes-devtools/binutils/binutils-2.22.inc +2 -1
@@ -1,4 +1,4 @@ -PR = "r14" +PR = "r15" LIC_FILES_CHKSUM="\ file://src-release;endline=17;md5=4830a9ef968f3b18dd5e9f2c00db2d35\
@@ -31,6 +31,7 @@ SRC_URI = "\ file://binutils-armv5e.patch \ file://mips64-default-ld-emulation.patch \ file://0001-PR-ld-13470.patch \ + file://rpath-sysroot.patch \ " SRC_URI[md5sum] = "ee0f10756c84979622b992a4a61ea3f5"
meta/recipes-devtools/binutils/binutils/rpath-sysroot.patch new file +38 -0
@@ -0,0 +1,38 @@ +ld: -rpath must search under sysroot + +The -rpath argument would search the host filesystem for libraries, +even when a sysroot was defined. For cross toolchains with targets +compatible with the host architecture this can find incorrect +libraries. Leave -rpath-link unmodified, as build systems in the wild +are already using this to point to host directories. + +Signed-off-by: Andy Ross <[email protected]> +Upstream-Status: submitted ([email protected] 2012-08-22) +--- + ld/emultempl/elf32.em | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em +index de51050..35e0e7e 100644 +--- a/ld/emultempl/elf32.em ++++ b/ld/emultempl/elf32.em +@@ -1263,9 +1263,13 @@ fragment <<EOF + EOF + if [ "x${USE_LIBPATH}" = xyes ] ; then + fragment <<EOF +- if (gld${EMULATION_NAME}_search_needed (command_line.rpath, +- &n, force)) +- break; ++ if (command_line.rpath) { ++ char *tmprp = gld${EMULATION_NAME}_add_sysroot (command_line.rpath); ++ found = gld${EMULATION_NAME}_search_needed (tmprp, &n, force); ++ free(tmprp); ++ if (found) ++ break; ++ } + EOF + fi + if [ "x${NATIVE}" = xyes ] ; then +-- +1.7.11.2 +
Signature · 1 line
1.7.11.4
Quoted 18 lines · Andy Ross
Current RPATH work:
Patch 1 just updates the libtool work to use the built-in normalization function instead of sed, as requested.
Patch 2 is to binutils ld, to fix the underlying host pollution issue:
the -rpath argument was not sysroot aware, so setting "/usr/lib/../lib" as an RPATH would add the host/usr/libto the link time search path instead of the sysroot directory.Note that the previous warning fix to insane.bbclass is still producing unmasked warnings in a few cases (the rpm utilities are one that I know), mostly in programs instead of libraries. These will need to be audited independently. It's possible that they are liking with -rpath directly and not using libtool, or that a needed normalization in libtool is still missing. But with the current patches these warnings are benign now, they can't break the build.
Quoted 8 lines
Andy
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Merged this patch set into OE-Core
Thanks
Sau!