rust: Use patchelf in place of chrpath to edit rpaths
PATCH 1/1 rust: Use patchelf in place of chrpath to edit rpaths
chrpath has limitations e.g. the original rpath in ELF have to bigger in size than the one being edited into it by chrpath, some toolchains do not use RPATH but emit the RUNPATHs into ELF files and chrpath is not able to handle the runpaths, this is the case with mips and pp32 build of rust, especially when using clang compiler to build them.
patchelf can do more:
Modify RUNPATH entries
Add RPATH/RUNPATH where none existed
Set longer paths than the original
Convert between RPATH and RUNPATH
--- meta/recipes-devtools/rust/rust_1.85.1.bb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
meta/recipes-devtools/rust/rust_1.85.1.bb +4 -4
@@ -207,9 +207,9 @@ rust_runx () { mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}` cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH} if [ -e ${STAGING_LIBDIR_NATIVE}/libc++.so.1 ]; then - chrpath -r \$ORIGIN/../../../../../`basename ${STAGING_DIR_NATIVE}`${libdir_native} ${RUST_ALTERNATE_EXE_PATH} + patchelf-uninative --set-rpath \$ORIGIN/../../../../../`basename ${STAGING_DIR_NATIVE}`${libdir_native} ${RUST_ALTERNATE_EXE_PATH} else - chrpath -d ${RUST_ALTERNATE_EXE_PATH} + patchelf-uninative --remove-rpath ${RUST_ALTERNATE_EXE_PATH} fi fi
@@ -266,7 +266,7 @@ rust_do_install:class-nativesdk() { install -d ${D}${bindir} for i in cargo-clippy clippy-driver rustfmt; do cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} - chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i + patchelf-uninative --set-rpath "\$ORIGIN/../lib" ${D}${bindir}/$i done chown root:root ${D}/ -R
@@ -301,7 +301,7 @@ rust_do_install:class-target() { install -d ${D}${bindir} for i in ${EXTRA_TOOLS}; do cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} - chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i + patchelf-uninative --set-rpath "\$ORIGIN/../lib" ${D}${bindir}/$i done install -d ${D}${libdir}/rustlib/${RUST_HOST_SYS}
I don't think patchelf-uninative is available if uninative is not in use. Probably better to DEPENDS += "patchelf-native" instead
Quoted 62 lines · Khem Raj via lists.openembedded.org
chrpath has limitations e.g. the original rpath in ELF have to bigger in size than the one being edited into it by chrpath, some toolchains do not use RPATH but emit the RUNPATHs into ELF files and chrpath is not able to handle the runpaths, this is the case with mips and pp32 build of rust, especially when using clang compiler to build them.
patchelf can do more:
Modify RUNPATH entries
Add RPATH/RUNPATH where none existed
Set longer paths than the original
Convert between RPATH and RUNPATHSigned-off-by Khem Raj <[email protected]>--- meta/recipes-devtools/rust/rust_1.85.1.bb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)meta/recipes-devtools/rust/rust_1.85.1.bb +4
-5@@ -207,9 +207,9 @@ rust_runx () { mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}` cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH} if [ -e ${STAGING_LIBDIR_NATIVE}/libc++.so.1 ]; then - chrpath -r \$ORIGIN/../../../../../`basename ${STAGING_DIR_NATIVE}`${libdir_native} ${RUST_ALTERNATE_EXE_PATH} + patchelf-uninative --set-rpath \$ORIGIN/../../../../../`basename ${STAGING_DIR_NATIVE}`${libdir_native} ${RUST_ALTERNATE_EXE_PATH} else - chrpath -d ${RUST_ALTERNATE_EXE_PATH} + patchelf-uninative --remove-rpath ${RUST_ALTERNATE_EXE_PATH} fi fi@@ -266,7 +266,7 @@ rust_do_install:class-nativesdk() { install -d ${D}${bindir} for i in cargo-clippy clippy-driver rustfmt; do cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} - chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i + patchelf-uninative --set-rpath "\$ORIGIN/../lib" ${D}${bindir}/$i done chown root:root ${D}/ -R@@ -301,7 +301,7 @@ rust_do_install:class-target() { install -d ${D}${bindir} for i in ${EXTRA_TOOLS}; do cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} - chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i + patchelf-uninative --set-rpath "\$ORIGIN/../lib" ${D}${bindir}/$i done install -d ${D}${libdir}/rustlib/${RUST_HOST_SYS} -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group.
View/Reply Online (#216772): https://lists.openembedded.org/g/openembedded-core/message/216772
Mute This Topic: https://lists.openembedded.org/mt/113168136/3616693
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Quoted 4 lines · Joshua Watt
I don't think patchelf-uninative is available if uninative is not in use. Probably better to DEPENDS += "patchelf-native" instead
there was another place in rust recipe using patchelf from uninative but this perhaps makes sense.
Quoted 64 lines
Quoted 62 lines · Khem Raj via lists.openembedded.org
chrpath has limitations e.g. the original rpath in ELF have to bigger in size than the one being edited into it by chrpath, some toolchains do not use RPATH but emit the RUNPATHs into ELF files and chrpath is not able to handle the runpaths, this is the case with mips and pp32 build of rust, especially when using clang compiler to build them.
patchelf can do more:
Modify RUNPATH entries
Add RPATH/RUNPATH where none existed
Set longer paths than the original
Convert between RPATH and RUNPATHSigned-off-by Khem Raj <[email protected]>--- meta/recipes-devtools/rust/rust_1.85.1.bb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)meta/recipes-devtools/rust/rust_1.85.1.bb +4
-5@@ -207,9 +207,9 @@ rust_runx () { mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}` cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH} if [ -e ${STAGING_LIBDIR_NATIVE}/libc++.so.1 ]; then - chrpath -r \$ORIGIN/../../../../../`basename ${STAGING_DIR_NATIVE}`${libdir_native} ${RUST_ALTERNATE_EXE_PATH} + patchelf-uninative --set-rpath \$ORIGIN/../../../../../`basename ${STAGING_DIR_NATIVE}`${libdir_native} ${RUST_ALTERNATE_EXE_PATH} else - chrpath -d ${RUST_ALTERNATE_EXE_PATH} + patchelf-uninative --remove-rpath ${RUST_ALTERNATE_EXE_PATH} fi fi@@ -266,7 +266,7 @@ rust_do_install:class-nativesdk() { install -d ${D}${bindir} for i in cargo-clippy clippy-driver rustfmt; do cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} - chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i + patchelf-uninative --set-rpath "\$ORIGIN/../lib" ${D}${bindir}/$i done chown root:root ${D}/ -R@@ -301,7 +301,7 @@ rust_do_install:class-target() { install -d ${D}${bindir} for i in ${EXTRA_TOOLS}; do cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} - chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i + patchelf-uninative --set-rpath "\$ORIGIN/../lib" ${D}${bindir}/$i done install -d ${D}${libdir}/rustlib/${RUST_HOST_SYS} -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group.
View/Reply Online (#216772): https://lists.openembedded.org/g/openembedded-core/message/216772
Mute This Topic: https://lists.openembedded.org/mt/113168136/3616693
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-