diff options
author | Khem Raj <raj.khem@gmail.com> | 2025-05-19 15:51:54 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-05-22 14:36:49 +0100 |
commit | 522af6e5cee5b3434ab3a19ad8d98c9977be249c (patch) | |
tree | 458c306d5baa5e0938b400dbc2e86cf75e92f0a0 | |
parent | 94019980ea12c603ba242f4a547e32d6aabd5192 (diff) | |
download | poky-522af6e5cee5b3434ab3a19ad8d98c9977be249c.tar.gz |
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
(From OE-Core rev: 22b903f6620455e142e836412d3f7f6a4f03bea7)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/recipes-devtools/rust/rust_1.85.1.bb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/meta/recipes-devtools/rust/rust_1.85.1.bb b/meta/recipes-devtools/rust/rust_1.85.1.bb index dc4f564855..b238f20726 100644 --- a/meta/recipes-devtools/rust/rust_1.85.1.bb +++ b/meta/recipes-devtools/rust/rust_1.85.1.bb | |||
@@ -64,7 +64,7 @@ do_rust_setup_snapshot () { | |||
64 | # are used internally by rust and result in symbol mismatches if we don't | 64 | # are used internally by rust and result in symbol mismatches if we don't |
65 | if [ ! -z "${UNINATIVE_LOADER}" -a -e "${UNINATIVE_LOADER}" ]; then | 65 | if [ ! -z "${UNINATIVE_LOADER}" -a -e "${UNINATIVE_LOADER}" ]; then |
66 | for bin in cargo rustc rustdoc; do | 66 | for bin in cargo rustc rustdoc; do |
67 | patchelf-uninative ${WORKDIR}/rust-snapshot/bin/$bin --set-interpreter ${UNINATIVE_LOADER} | 67 | patchelf ${WORKDIR}/rust-snapshot/bin/$bin --set-interpreter ${UNINATIVE_LOADER} |
68 | done | 68 | done |
69 | fi | 69 | fi |
70 | } | 70 | } |
@@ -72,6 +72,7 @@ addtask rust_setup_snapshot after do_unpack before do_configure | |||
72 | addtask do_test_compile after do_configure do_rust_gen_targets | 72 | addtask do_test_compile after do_configure do_rust_gen_targets |
73 | do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot" | 73 | do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot" |
74 | do_rust_setup_snapshot[vardepsexclude] += "UNINATIVE_LOADER" | 74 | do_rust_setup_snapshot[vardepsexclude] += "UNINATIVE_LOADER" |
75 | do_rust_setup_snapshot[depends] += "patchelf-native:do_populate_sysroot" | ||
75 | 76 | ||
76 | RUSTC_BOOTSTRAP = "${STAGING_BINDIR_NATIVE}/rustc" | 77 | RUSTC_BOOTSTRAP = "${STAGING_BINDIR_NATIVE}/rustc" |
77 | CARGO_BOOTSTRAP = "${STAGING_BINDIR_NATIVE}/cargo" | 78 | CARGO_BOOTSTRAP = "${STAGING_BINDIR_NATIVE}/cargo" |
@@ -207,9 +208,9 @@ rust_runx () { | |||
207 | mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}` | 208 | mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}` |
208 | cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH} | 209 | cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH} |
209 | if [ -e ${STAGING_LIBDIR_NATIVE}/libc++.so.1 ]; then | 210 | if [ -e ${STAGING_LIBDIR_NATIVE}/libc++.so.1 ]; then |
210 | chrpath -r \$ORIGIN/../../../../../`basename ${STAGING_DIR_NATIVE}`${libdir_native} ${RUST_ALTERNATE_EXE_PATH} | 211 | patchelf --set-rpath \$ORIGIN/../../../../../`basename ${STAGING_DIR_NATIVE}`${libdir_native} ${RUST_ALTERNATE_EXE_PATH} |
211 | else | 212 | else |
212 | chrpath -d ${RUST_ALTERNATE_EXE_PATH} | 213 | patchelf --remove-rpath ${RUST_ALTERNATE_EXE_PATH} |
213 | fi | 214 | fi |
214 | fi | 215 | fi |
215 | 216 | ||
@@ -266,7 +267,7 @@ rust_do_install:class-nativesdk() { | |||
266 | install -d ${D}${bindir} | 267 | install -d ${D}${bindir} |
267 | for i in cargo-clippy clippy-driver rustfmt; do | 268 | for i in cargo-clippy clippy-driver rustfmt; do |
268 | cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} | 269 | cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} |
269 | chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i | 270 | patchelf --set-rpath "\$ORIGIN/../lib" ${D}${bindir}/$i |
270 | done | 271 | done |
271 | 272 | ||
272 | chown root:root ${D}/ -R | 273 | chown root:root ${D}/ -R |
@@ -301,7 +302,7 @@ rust_do_install:class-target() { | |||
301 | install -d ${D}${bindir} | 302 | install -d ${D}${bindir} |
302 | for i in ${EXTRA_TOOLS}; do | 303 | for i in ${EXTRA_TOOLS}; do |
303 | cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} | 304 | cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} |
304 | chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i | 305 | patchelf --set-rpath "\$ORIGIN/../lib" ${D}${bindir}/$i |
305 | done | 306 | done |
306 | 307 | ||
307 | install -d ${D}${libdir}/rustlib/${RUST_HOST_SYS} | 308 | install -d ${D}${libdir}/rustlib/${RUST_HOST_SYS} |