rust: Use patchelf in place of chrpath to edit rpaths
PATCH v2 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
Signed-off-by Khem Raj <[email protected]>
---
v2: Use patchelf-native to provide patchelf instead of assuming uninative
meta/recipes-devtools/rust/rust_1.85.1.bb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
meta/recipes-devtools/rust/rust_1.85.1.bb +6 -5
@@ -64,7 +64,7 @@ do_rust_setup_snapshot () { # are used internally by rust and result in symbol mismatches if we don't if [ ! -z "${UNINATIVE_LOADER}" -a -e "${UNINATIVE_LOADER}" ]; then for bin in cargo rustc rustdoc; do - patchelf-uninative ${WORKDIR}/rust-snapshot/bin/$bin --set-interpreter ${UNINATIVE_LOADER} + patchelf ${WORKDIR}/rust-snapshot/bin/$bin --set-interpreter ${UNINATIVE_LOADER} done fi }
@@ -72,6 +72,7 @@ addtask rust_setup_snapshot after do_unpack before do_configure addtask do_test_compile after do_configure do_rust_gen_targets do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot" do_rust_setup_snapshot[vardepsexclude] += "UNINATIVE_LOADER" +do_rust_setup_snapshot[depends] += "patchelf-native:do_populate_sysroot" RUSTC_BOOTSTRAP = "${STAGING_BINDIR_NATIVE}/rustc" CARGO_BOOTSTRAP = "${STAGING_BINDIR_NATIVE}/cargo"
@@ -207,9 +208,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 --set-rpath \$ORIGIN/../../../../../`basename ${STAGING_DIR_NATIVE}`${libdir_native} ${RUST_ALTERNATE_EXE_PATH} else - chrpath -d ${RUST_ALTERNATE_EXE_PATH} + patchelf --remove-rpath ${RUST_ALTERNATE_EXE_PATH} fi fi
@@ -266,7 +267,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 --set-rpath "\$ORIGIN/../lib" ${D}${bindir}/$i done chown root:root ${D}/ -R
@@ -301,7 +302,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 --set-rpath "\$ORIGIN/../lib" ${D}${bindir}/$i done install -d ${D}${libdir}/rustlib/${RUST_HOST_SYS}