From: Harish Sadineni <[email protected]> Fixes 32-bit Cargo build failures when using multilib-enabled SDKs.
Store the generated environment setup script in a target-specific subdirectory so that sourcing the SDK environment always loads the matching script for the selected target, avoiding accidental reuse of the 64-bit configuration when building for a 32-bit target. Also update `CARGO_TARGET_<TRIPLE>_RUSTFLAGS` to add an explicit `-L` search path to the target `rustlib` directory inside the sysroot. The path is selected dynamically based on the multilib configuration, choosing `lib` for 32-bit targets and `lib64` for 64-bit targets. This ensures Cargo can locate the correct target-specific Rust libraries during cross-compilation with the cross-canadian toolchain. Signed-off-by: Harish Sadineni <[email protected]> --- .../rust/rust-cross-canadian.inc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/meta/recipes-devtools/rust/rust-cross-canadian.inc b/meta/recipes-devtools/rust/rust-cross-canadian.inc index f083bcda82..0c60a90d17 100644 --- a/meta/recipes-devtools/rust/rust-cross-canadian.inc +++ b/meta/recipes-devtools/rust/rust-cross-canadian.inc @@ -51,14 +51,26 @@ do_install () { chmod +x "$outfile" create_sdk_wrapper "${SYS_BINDIR}/target-rust-ccld-wrapper" "CC" - ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d - mkdir "${ENV_SETUP_DIR}" + ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d/${TARGET_SYS} + mkdir -p "${ENV_SETUP_DIR}" RUST_ENV_SETUP_SH="${ENV_SETUP_DIR}/${RUST_TARGET_SYS}_rust.sh" RUST_TARGET_TRIPLE=`echo ${RUST_TARGET_SYS} | tr '[:lower:]' '[:upper:]' | sed 's/-/_/g'` cat <<- EOF > "${RUST_ENV_SETUP_SH}" - export CARGO_TARGET_${RUST_TARGET_TRIPLE}_RUSTFLAGS="--sysroot=\$OECORE_TARGET_SYSROOT/usr -C link-arg=--sysroot=\$OECORE_TARGET_SYSROOT" + export RUST_TARGET_SYS_VALUE="${RUST_TARGET_SYS}" + if echo "${MULTILIBS}" | grep -q "multilib:"; then + if echo "${RUST_TARGET_SYS}" | grep -qE '(32)'; then + LIBDIR="lib" + else + LIBDIR="lib64" + fi + else + # multilib not enabled + LIBDIR="lib" + fi + LIB_PATH="\$OECORE_TARGET_SYSROOT/usr/\${LIBDIR}/rustlib/${RUST_TARGET_SYS}/lib" + export CARGO_TARGET_${RUST_TARGET_TRIPLE}_RUSTFLAGS="--sysroot=\$OECORE_TARGET_SYSROOT/usr -C link-arg=--sysroot=\$OECORE_TARGET_SYSROOT -L \$LIB_PATH" export CARGO_BUILD_TARGET="${RUST_TARGET_SYS}" export RUST_TARGET_PATH="\$OECORE_NATIVE_SYSROOT/usr/lib/${TARGET_SYS}/rustlib" EOF -- 2.51.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#241823): https://lists.openembedded.org/g/openembedded-core/message/241823 Mute This Topic: https://lists.openembedded.org/mt/120408881/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
