From 251f55374d26b5c24d8833aa87c95432be8b81b2 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 5 Aug 2022 13:39:43 +0100 Subject: cargo: Drop cross-canadian variant and fix/use nativesdk The cargo-cross-candian variant made no sense as one version of cargo in the SDK can work for all targets. Replace it with nativesdk-cargo instead. Move the SDK env to rust-cross-canadian. (From OE-Core rev: 6d6d135924eff5993736ee58ba8cc5d00ca635f3) Signed-off-by: Richard Purdie --- meta/recipes-devtools/rust/rust-cross-canadian.inc | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'meta/recipes-devtools/rust') diff --git a/meta/recipes-devtools/rust/rust-cross-canadian.inc b/meta/recipes-devtools/rust/rust-cross-canadian.inc index 8bbbd61bdc..677bd8842c 100644 --- a/meta/recipes-devtools/rust/rust-cross-canadian.inc +++ b/meta/recipes-devtools/rust/rust-cross-canadian.inc @@ -16,6 +16,18 @@ do_compile () { rust_runx build --stage 2 } +create_sdk_wrapper () { + file="$1" + shift + + cat <<- EOF > "${file}" + #!/bin/sh + \$$1 \$@ + EOF + + chmod +x "$file" +} + do_install () { # Rust requires /usr/lib to contain the libs. # Similar story is with /usr/bin ruquiring `lib` to be at the same level. @@ -51,6 +63,11 @@ do_install () { # Remove executable bit from any files so then SDK doesn't try to relocate. chmod -R -x+X ${SRC_DIR} + + # Uses SDK's CC as linker so linked binaries works out of box. + install -d ${SYS_BINDIR} + create_sdk_wrapper "${SYS_BINDIR}/target-rust-ccld" "CC" + ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d mkdir "${ENV_SETUP_DIR}" ENV_SETUP_SH="${ENV_SETUP_DIR}/rust.sh" @@ -61,6 +78,26 @@ do_install () { EOF chown -R root.root ${D} + + ENV_SETUP_SH="${ENV_SETUP_DIR}/cargo.sh" + cat <<- EOF > "${ENV_SETUP_SH}" + export CARGO_HOME="\$OECORE_TARGET_SYSROOT/home/cargo" + mkdir -p "\$CARGO_HOME" + # Init the default target once, it might be otherwise user modified. + if [ ! -f "\$CARGO_HOME/config" ]; then + touch "\$CARGO_HOME/config" + echo "[build]" >> "\$CARGO_HOME/config" + echo 'target = "'${RUST_TARGET_SYS}'"' >> "\$CARGO_HOME/config" + echo '# TARGET_SYS' >> "\$CARGO_HOME/config" + echo '[target.'${RUST_TARGET_SYS}']' >> "\$CARGO_HOME/config" + echo 'linker = "target-rust-ccld"' >> "\$CARGO_HOME/config" + fi + + # Keep the below off as long as HTTP/2 is disabled. + export CARGO_HTTP_MULTIPLEXING=false + + export CARGO_HTTP_CAINFO="\$OECORE_NATIVE_SYSROOT/etc/ssl/certs/ca-certificates.crt" + EOF } PKG_SYS_LIBDIR = "${SDKPATHNATIVE}/usr/lib" -- cgit v1.2.3-54-g00ecf