rust-cross-canadian: Fix environment setup script conflicts for multilibs
PATCH 1/1 rust-cross-canadian: Fix environment setup script conflicts for multilibs
From: Deepthi Hemraj <[email protected]>
YOCTO [#15061]
Rust multilib sdks broken because of the conflicts between attempted installs of rust-cross-canadian for arm and aarch64.
Multilibs trying to install cargo.sh
and rust.sh in the same path which resulted in the issue
This patch implements architecture specific environment setup scripts using RUST_TARGET_SYS to create unique filenames.
The changes ensure that these scripts do not overwrite each other. Additionally, all target-independent variables previously defined in the rust and cargo scripts have been moved to their respective nativesdk recipe files
--- meta/recipes-devtools/rust/cargo_1.80.0.bb | 24 +++++++++++++++++++ .../rust/rust-cross-canadian.inc | 24 ++++--------------- meta/recipes-devtools/rust/rust_1.80.0.bb | 14 +++++++++++ 3 files changed, 43 insertions(+), 19 deletions(-)
meta/recipes-devtools/rust/cargo_1.80.0.bb +24 -0
@@ -50,7 +50,31 @@ do_install:append:class-nativesdk() { # 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} + + ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d + mkdir "${ENV_SETUP_DIR}" + CARGO_ENV_SETUP_SH="${ENV_SETUP_DIR}/${RUST_TARGET_SYS}_cargo.sh" + + RUST_HOST_TRIPLE=`echo ${RUST_HOST_SYS} | tr '[:lower:]' '[:upper:]' | sed 's/-/_/g'` + + cat <<- EOF > "${CARGO_ENV_SETUP_SH}" + export CARGO_TARGET_${RUST_HOST_TRIPLE}_RUNNER="\$OECORE_NATIVE_SYSROOT/lib/${SDKLOADER}" + export CARGO_HOME="\$OECORE_TARGET_SYSROOT/home/cargo" + mkdir -p "\$CARGO_HOME" + if ! grep -q '^\[build\]' "\$CARGO_HOME/config"; then + touch "\$CARGO_HOME/config" + echo "[build]" >> "\$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 + } +FILES:${PN} += "${base_prefix}/environment-setup.d" # 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.
meta/recipes-devtools/rust/rust-cross-canadian.inc +5 -19
@@ -54,39 +54,25 @@ do_install () { ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d mkdir "${ENV_SETUP_DIR}" - RUST_ENV_SETUP_SH="${ENV_SETUP_DIR}/rust.sh" + 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'` - RUST_HOST_TRIPLE=`echo ${RUST_HOST_SYS} | tr '[:lower:]' '[:upper:]' | sed 's/-/_/g'` SDKLOADER=${@bb.utils.contains('SDK_ARCH', 'x86_64', 'ld-linux-x86-64.so.2', '', d)}${@bb.utils.contains('SDK_ARCH', 'i686', 'ld-linux.so.2', '', d)}${@bb.utils.contains('SDK_ARCH', 'aarch64', 'ld-linux-aarch64.so.1', '', d)}${@bb.utils.contains('SDK_ARCH', 'ppc64le', 'ld64.so.2', '', d)}${@bb.utils.contains('SDK_ARCH', 'riscv64', 'ld-linux-riscv64-lp64d.so.1', '', d)} 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 CARGO_TARGET_${RUST_HOST_TRIPLE}_RUNNER="\$OECORE_NATIVE_SYSROOT/lib/${SDKLOADER}" - export RUST_TARGET_PATH="\$OECORE_NATIVE_SYSROOT/usr/lib/${TARGET_SYS}/rustlib" - EOF - - chown -R root.root ${D} - - CARGO_ENV_SETUP_SH="${ENV_SETUP_DIR}/cargo.sh" - cat <<- EOF > "${CARGO_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" + if ! grep -q '^\[target\.' "\$CARGO_HOME/config"; then 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 + + chown -R root.root ${D} + } FILES:${PN} += "${base_prefix}/environment-setup.d"
meta/recipes-devtools/rust/rust_1.80.0.bb +14 -0
@@ -271,8 +271,22 @@ rust_do_install:class-nativesdk() { rm ${D}${libdir}/rustlib/uninstall.sh rm ${D}${libdir}/rustlib/install.log rm ${D}${libdir}/rustlib/manifest* + + ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d + mkdir "${ENV_SETUP_DIR}" + RUST_ENV_SETUP_SH="${ENV_SETUP_DIR}/${RUST_TARGET_SYS}_rust.sh" + + cat <<- EOF > "${RUST_ENV_SETUP_SH}" + export RUST_TARGET_PATH="\$OECORE_NATIVE_SYSROOT/usr/lib/${TARGET_SYS}/rustlib" + + EOF + + chown -R root.root ${D} + } +FILES:${PN} += "${base_prefix}/environment-setup.d" + EXTRA_TOOLS ?= "cargo-clippy clippy-driver rustfmt" rust_do_install:class-target() { export PSEUDO_UNLOAD=1
Signature · 1 line
2.43.0
Hi Deepthi,
Thanks for working through this. This is the right direction but there are still some issues.
Quoted 27 lines · Deepthi via lists.openembedded.org
From: Deepthi Hemraj <[email protected]>
YOCTO [#15061]
Rust multilib sdks broken because of the conflicts between attempted installs of rust-cross-canadian for arm and aarch64.Multilibs trying to install
cargo.sh
andrust.shin the same path which resulted in the issueThis patch implements architecture specific environment setup scripts using
RUST_TARGET_SYSto create unique filenames.
The changes ensure that these scripts do not overwrite each other. Additionally, all target-independent variables previously defined in the rust and cargo scripts have been moved to their respective nativesdk recipe filesSigned-off-by Deepthi Hemraj <[email protected]>---
meta/recipes-devtools/rust/cargo_1.80.0.bb | 24 +++++++++++++++++++ .../rust/rust-cross-canadian.inc | 24 ++++--------------- meta/recipes-devtools/rust/rust_1.80.0.bb | 14 +++++++++++3 files changed, 43 insertions(+), 19 deletions(-)meta/recipes-devtools/rust/cargo_1.80.0.bb +0
-0
meta/recipes-devtools/rust/cargo_1.80.0.bb do_install:append:class-nativesdk() { · line 56
Quoted 7 lines
meta/recipes-devtools/rust/cargo_1.80.0.bb +4
-0@@ -50,7 +50,31 @@ do_install:append:class-nativesdk() { # 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} + + ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d + mkdir "${ENV_SETUP_DIR}" + CARGO_ENV_SETUP_SH="${ENV_SETUP_DIR}/${RUST_TARGET_SYS}_cargo.sh"
This should just be called cargo.sh, with no "${RUST_TARGET_SYS}_" prefix?
Quoted 11 lines
meta/recipes-devtools/rust/cargo_1.80.0.bb +11
-0+ + RUST_HOST_TRIPLE=`echo ${RUST_HOST_SYS} | tr '[:lower:]' '[:upper:]' | sed 's/-/_/g'` + + cat <<- EOF > "${CARGO_ENV_SETUP_SH}" + export CARGO_TARGET_${RUST_HOST_TRIPLE}_RUNNER="\$OECORE_NATIVE_SYSROOT/lib/${SDKLOADER}" + export CARGO_HOME="\$OECORE_TARGET_SYSROOT/home/cargo" + mkdir -p "\$CARGO_HOME" + if ! grep -q '^\[build\]' "\$CARGO_HOME/config"; then + touch "\$CARGO_HOME/config" + echo "[build]" >> "\$CARGO_HOME/config" + echo 'linker = "target-rust-ccld"' >> "\$CARGO_HOME/config"
meta/recipes-devtools/rust/cargo_1.80.0.bb do_install:append:class-nativesdk() { · line 77
Quoted 10 lines
meta/recipes-devtools/rust/cargo_1.80.0.bb +9
-0+ 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 + } +FILES:${PN} += "${base_prefix}/environment-setup.d"
I'd suggest in the interests of getting some parts of this merged, this cargo change be separated out from the rest of the change (removing just these bits from rust-cross-canadian and adding as above). We can then handle the other pieces in a second patch.
Quoted 31 lines
# 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.meta/recipes-devtools/rust/rust-cross-canadian.inc +0
-0@@ -54,39 +54,25 @@ do_install () {
ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d
mkdir "${ENV_SETUP_DIR}"
- RUST_ENV_SETUP_SH="${ENV_SETUP_DIR}/rust.sh"
+ 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'
- RUST_HOST_TRIPLE=echo ${RUST_HOST_SYS} | tr '[:lower:]' '[:upper:]' | sed 's/-/_/g'
SDKLOADER=${@bb.utils.contains('SDK_ARCH', 'x86_64', 'ld-linux-x86-64.so.2', '', d)}${@bb.utils.contains('SDK_ARCH', 'i686', 'ld-linux.so.2', '', d)}${@bb.utils.contains('SDK_ARCH', 'aarch64', 'ld-linux-aarch64.so.1', '', d)}${@bb.utils.contains('SDK_ARCH', 'ppc64le', 'ld64.so.2', '', d)}${@bb.utils.contains('SDK_ARCH', 'riscv64', 'ld-linux-riscv64-lp64d.so.1', '', d)}
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"meta/recipes-devtools/rust/rust-cross-canadian.inc +0
-8- export CARGO_TARGET_${RUST_HOST_TRIPLE}_RUNNER="\$OECORE_NATIVE_SYSROOT/lib/${SDKLOADER}" - export RUST_TARGET_PATH="\$OECORE_NATIVE_SYSROOT/usr/lib/${TARGET_SYS}/rustlib" - EOF - - chown -R root.root ${D} - - CARGO_ENV_SETUP_SH="${ENV_SETUP_DIR}/cargo.sh" - cat <<- EOF > "${CARGO_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.
meta/recipes-devtools/rust/rust-cross-canadian.inc do_install () { · line 66
Quoted 4 lines
meta/recipes-devtools/rust/rust-cross-canadian.inc +1
-3- if [ ! -f "\$CARGO_HOME/config" ]; then - touch "\$CARGO_HOME/config" - echo "[build]" >> "\$CARGO_HOME/config" + if ! grep -q '^\[target\.' "\$CARGO_HOME/config"; then
This needs to search for the item with RUST_TARGET_SYS included.
Quoted 25 lines
echo 'target = "'${RUST_TARGET_SYS}'"' >> "\$CARGO_HOME/config" echo '#
TARGET_SYS' >> "\$CARGO_HOME/config"
echo '[target.'${RUST_TARGET_SYS}']' >> "\$CARGO_HOME/config"meta/recipes-devtools/rust/rust-cross-canadian.inc +0
-1- echo 'linker = "target-rust-ccld"' >> "\$CARGO_HOME/config"fi
meta/recipes-devtools/rust/rust-cross-canadian.inc +0
-4- # 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
meta/recipes-devtools/rust/rust-cross-canadian.inc +3
-0+ + chown -R root.root ${D} +}
FILES:${PN} += "${base_prefix}/environment-setup.d"meta/recipes-devtools/rust/rust_1.80.0.bb +0
-0@@ -271,8 +271,22 @@ rust_do_install:class-nativesdk() {rm
${D}${libdir}/rustlib/uninstall.sh
rm ${D}${libdir}/rustlib/install.log
rm ${D}${libdir}/rustlib/manifest*
meta/recipes-devtools/rust/rust_1.80.0.bb rust_do_install:class-nativesdk() { · line 280
Quoted 7 lines
meta/recipes-devtools/rust/rust_1.80.0.bb +7
-0+ + ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d + mkdir "${ENV_SETUP_DIR}" + RUST_ENV_SETUP_SH="${ENV_SETUP_DIR}/${RUST_TARGET_SYS}_rust.sh" + + cat <<- EOF > "${RUST_ENV_SETUP_SH}" + export RUST_TARGET_PATH="\$OECORE_NATIVE_SYSROOT/usr/lib/${TARGET_SYS}/rustlib"
I think this may need to append to RUST_TARGET_PATH, i.e.:
export RUST_TARGET_PATH="${RUST_TARGET_PATH}:\$OECORE_NATIVE_SYSROOT/usr/lib/${TARGET_SYS}/rustlib"
but I'm unsure how rust is using this or if than makes sense...
Cheers,
Richard