All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] rust-common: Remove conflict with utils create_wrapper
@ 2022-08-08 14:46 Richard Purdie
  2022-08-08 14:46 ` [PATCH 2/2] cargo: Work around host system library conflicts Richard Purdie
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Purdie @ 2022-08-08 14:46 UTC (permalink / raw)
  To: openembedded-core

utils already has a create_wrapper function which I tried to use from cargo
and got unexpected results. Rename the rust function to avoid this conflict
of named.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/rust-common.bbclass | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/meta/classes/rust-common.bbclass b/meta/classes/rust-common.bbclass
index 8ee05f57f86..4c1a63df0dc 100644
--- a/meta/classes/rust-common.bbclass
+++ b/meta/classes/rust-common.bbclass
@@ -114,7 +114,7 @@ RUST_TARGET_CXX = "${WRAPPER_DIR}/target-rust-cxx"
 RUST_TARGET_CCLD = "${WRAPPER_DIR}/target-rust-ccld"
 RUST_TARGET_AR = "${WRAPPER_DIR}/target-rust-ar"
 
-create_wrapper () {
+create_wrapper_rust () {
 	file="$1"
 	shift
 	extras="$1"
@@ -148,22 +148,22 @@ do_rust_create_wrappers () {
 	mkdir -p "${WRAPPER_DIR}"
 
 	# Yocto Build / Rust Host C compiler
-	create_wrapper "${RUST_BUILD_CC}" "" "${BUILD_CC}"
+	create_wrapper_rust "${RUST_BUILD_CC}" "" "${BUILD_CC}"
 	# Yocto Build / Rust Host C++ compiler
-	create_wrapper "${RUST_BUILD_CXX}" "" "${BUILD_CXX}"
+	create_wrapper_rust "${RUST_BUILD_CXX}" "" "${BUILD_CXX}"
 	# Yocto Build / Rust Host linker
-	create_wrapper "${RUST_BUILD_CCLD}" "" "${BUILD_CCLD}" "${BUILD_LDFLAGS}"
+	create_wrapper_rust "${RUST_BUILD_CCLD}" "" "${BUILD_CCLD}" "${BUILD_LDFLAGS}"
 	# Yocto Build / Rust Host archiver
-	create_wrapper "${RUST_BUILD_AR}" "" "${BUILD_AR}"
+	create_wrapper_rust "${RUST_BUILD_AR}" "" "${BUILD_AR}"
 
 	# Yocto Target / Rust Target C compiler
-	create_wrapper "${RUST_TARGET_CC}" "${WRAPPER_TARGET_EXTRALD}" "${WRAPPER_TARGET_CC}" "${WRAPPER_TARGET_LDFLAGS}"
+	create_wrapper_rust "${RUST_TARGET_CC}" "${WRAPPER_TARGET_EXTRALD}" "${WRAPPER_TARGET_CC}" "${WRAPPER_TARGET_LDFLAGS}"
 	# Yocto Target / Rust Target C++ compiler
-	create_wrapper "${RUST_TARGET_CXX}" "${WRAPPER_TARGET_EXTRALD}" "${WRAPPER_TARGET_CXX}" "${CXXFLAGS}"
+	create_wrapper_rust "${RUST_TARGET_CXX}" "${WRAPPER_TARGET_EXTRALD}" "${WRAPPER_TARGET_CXX}" "${CXXFLAGS}"
 	# Yocto Target / Rust Target linker
-	create_wrapper "${RUST_TARGET_CCLD}" "${WRAPPER_TARGET_EXTRALD}" "${WRAPPER_TARGET_CCLD}" "${WRAPPER_TARGET_LDFLAGS}"
+	create_wrapper_rust "${RUST_TARGET_CCLD}" "${WRAPPER_TARGET_EXTRALD}" "${WRAPPER_TARGET_CCLD}" "${WRAPPER_TARGET_LDFLAGS}"
 	# Yocto Target / Rust Target archiver
-	create_wrapper "${RUST_TARGET_AR}" "" "${WRAPPER_TARGET_AR}"
+	create_wrapper_rust "${RUST_TARGET_AR}" "" "${WRAPPER_TARGET_AR}"
 
 }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] cargo: Work around host system library conflicts
  2022-08-08 14:46 [PATCH 1/2] rust-common: Remove conflict with utils create_wrapper Richard Purdie
@ 2022-08-08 14:46 ` Richard Purdie
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Purdie @ 2022-08-08 14:46 UTC (permalink / raw)
  To: openembedded-core

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>
---
 meta/recipes-devtools/cargo/cargo.inc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/meta/recipes-devtools/cargo/cargo.inc b/meta/recipes-devtools/cargo/cargo.inc
index e34554a9d78..636e9c4fe51 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
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-08 14:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-08 14:46 [PATCH 1/2] rust-common: Remove conflict with utils create_wrapper Richard Purdie
2022-08-08 14:46 ` [PATCH 2/2] cargo: Work around host system library conflicts Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.