[Buildroot] [PATCH next v6 07/10] core: implement per-package SDK and target

Thomas Petazzoni thomas.petazzoni at bootlin.com
Thu Dec 27 16:17:59 UTC 2018


Hello,

On Wed, 26 Dec 2018 18:34:22 +0100, Thomas Petazzoni wrote:

> So, without per-package directory, we fall in case (2) above.
> 
> With per-package directory, we fall in case (4) above, and therefore
> the RPATH is discarded.
> 
> At this point, I am not sure at which level and how the issue should be
> fixed. Needs some thought. Input/ideas welcome.

So for now, the way I fixed this is by rewriting the RPATH in fix-rpath
so that they don't point to per-package host directories. It is a bit
annoying that we end up rewriting RPATHs twice, but it is the easiest /
most straightforward solution to be able to move forward with the whole
per-package directory stuff.

Here is what I have locally:

diff --git a/support/scripts/fix-rpath b/support/scripts/fix-rpath
index fa138ca15a..67bf1eb1b3 100755
--- a/support/scripts/fix-rpath
+++ b/support/scripts/fix-rpath
@@ -127,14 +127,24 @@ main() {
 
     while read file ; do
         # check if it's an ELF file
-        if ${PATCHELF} --print-rpath "${file}" > /dev/null 2>&1; then
-            # make files writable if necessary
-            changed=$(chmod -c u+w "${file}")
-            # call patchelf to sanitize the rpath
-            ${PATCHELF} --make-rpath-relative "${rootdir}" ${sanitize_extra_args[@]} "${file}"
-            # restore the original permission
-            test "${changed}" != "" && chmod u-w "${file}"
+        rpath=$(${PATCHELF} --print-rpath "${file}" 2>&1)
+        if test $? -ne 0 ; then
+            continue
         fi
+
+        # make files writable if necessary
+        changed=$(chmod -c u+w "${file}")
+
+        # rewrite the per-package rpaths
+        changed_rpath=$(echo ${rpath} | sed "s@${PER_PACKAGE_DIR}/[^/]*/host@${HOST_DIR}@")
+        if test "${rpath}" != "${changed_rpath}" ; then
+            ${PATCHELF} --set-rpath ${changed_rpath} "${file}"
+        fi
+
+        # call patchelf to sanitize the rpath
+        ${PATCHELF} --make-rpath-relative "${rootdir}" ${sanitize_extra_args[@]} "${file}"
+        # restore the original permission
+        test "${changed}" != "" && chmod u-w "${file}"
     done < <(find "${rootdir}" ${find_args[@]})
 
     # Restore patched patchelf utility

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


More information about the buildroot mailing list