diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-08 15:33:41 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-09 22:42:00 +0100 |
commit | 388e7cac9f90e79ce8c3c1683d8ee0f4df1bc907 (patch) | |
tree | 6f3ca03f0aa7311136b58a0e47bd2984221e5979 /meta/recipes-devtools | |
parent | d169606c547796731f528c4649295c4c1c928ea4 (diff) | |
download | openembedded-core-contrib-388e7cac9f90e79ce8c3c1683d8ee0f4df1bc907.tar.gz |
cargo: Work around host system library conflicts
cargo ends up running target-rust-ccld with LD_LIBRARY_PATH set to libdir but not
base_libdir which breaks the SDK. You see errors like:
/bin/sh: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
On such a system, this would fail:
LD_LIBRARY_PATH="<path>/testimage-sdk/sysroots/x86_64-pokysdk-linux/usr/lib" cargo build
but this would work:
LD_LIBRARY_PATH="<path>/testimage-sdk/sysroots/x86_64-pokysdk-linux/usr/lib:<path>/testimage-sdk/sysroots/x86_64-pokysdk-linux/lib" cargo build
so wrap cargo with both paths in LD_LIBRARY_PATH.
The error depends on the versions of the host system, it reproduced on tumbleweed-ty-3.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r-- | meta/recipes-devtools/cargo/cargo.inc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/meta/recipes-devtools/cargo/cargo.inc b/meta/recipes-devtools/cargo/cargo.inc index e34554a9d7..636e9c4fe5 100644 --- a/meta/recipes-devtools/cargo/cargo.inc +++ b/meta/recipes-devtools/cargo/cargo.inc @@ -43,6 +43,14 @@ do_install () { install -m 755 "${B}/target/${CARGO_TARGET_SUBDIR}/cargo" "${D}${bindir}" } +do_install:append:class-nativesdk() { + # To quote the cargo docs, "Cargo also sets the dynamic library path when compiling + # and running binaries with commands like `cargo run` and `cargo test`". Sadly it + # sets to libdir but not base_libdir leading to symbol mismatches depending on the + # host OS. Fully set LD_LIBRARY_PATH to contain both to avoid this. + create_wrapper ${D}/${bindir}/cargo LD_LIBRARY_PATH=${libdir}:${base_libdir} +} + # Disabled due to incompatibility with libgit2 0.28.x (https://github.com/rust-lang/git2-rs/issues/458, https://bugs.gentoo.org/707746#c1) # as shipped by Yocto Dunfell. # According to https://github.com/rust-lang/git2-rs/issues/458#issuecomment-522567539, there are no compatibility guarantees between |