diff options
Diffstat (limited to 'meta/recipes-devtools/rust')
| -rw-r--r-- | meta/recipes-devtools/rust/files/target-rust-ccld.c | 19 | ||||
| -rw-r--r-- | meta/recipes-devtools/rust/rust-cross-canadian.inc | 20 |
2 files changed, 36 insertions, 3 deletions
diff --git a/meta/recipes-devtools/rust/files/target-rust-ccld.c b/meta/recipes-devtools/rust/files/target-rust-ccld.c new file mode 100644 index 0000000000..d3d491fb60 --- /dev/null +++ b/meta/recipes-devtools/rust/files/target-rust-ccld.c | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | /* | ||
| 2 | * | ||
| 3 | * Copyright (C) 2022 Wind River Systems | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: MIT | ||
| 6 | * | ||
| 7 | */ | ||
| 8 | |||
| 9 | #include <string.h> | ||
| 10 | #include <stdlib.h> | ||
| 11 | #include <unistd.h> | ||
| 12 | |||
| 13 | int main (int argc, char *argv[]) | ||
| 14 | { | ||
| 15 | unsetenv("LD_LIBRARY_PATH"); | ||
| 16 | execvp("target-rust-ccld-wrapper", argv); | ||
| 17 | |||
| 18 | return 0; | ||
| 19 | } | ||
diff --git a/meta/recipes-devtools/rust/rust-cross-canadian.inc b/meta/recipes-devtools/rust/rust-cross-canadian.inc index 7bf75a4712..17f933959f 100644 --- a/meta/recipes-devtools/rust/rust-cross-canadian.inc +++ b/meta/recipes-devtools/rust/rust-cross-canadian.inc | |||
| @@ -7,13 +7,18 @@ LICENSE = "MIT" | |||
| 7 | 7 | ||
| 8 | MODIFYTOS = "0" | 8 | MODIFYTOS = "0" |
| 9 | 9 | ||
| 10 | DEPENDS += "virtual/${SDK_PREFIX}gcc-crosssdk virtual/nativesdk-libc virtual/nativesdk-${SDK_PREFIX}compilerlibs" | ||
| 11 | |||
| 12 | SRC_URI += "file://target-rust-ccld.c" | ||
| 13 | LIC_FILES_CHKSUM = "file://target-rust-ccld.c;md5=af4e0e29f81a34cffe05aa07c89e93e9;endline=7" | ||
| 14 | S = "${WORKDIR}" | ||
| 15 | |||
| 10 | # Need to use our SDK's sh here, see #14878 | 16 | # Need to use our SDK's sh here, see #14878 |
| 11 | create_sdk_wrapper () { | 17 | create_sdk_wrapper () { |
| 12 | file="$1" | 18 | file="$1" |
| 13 | shift | 19 | shift |
| 14 | |||
| 15 | cat <<- EOF > "${file}" | 20 | cat <<- EOF > "${file}" |
| 16 | #!${base_prefix}/bin/sh | 21 | #!/bin/sh |
| 17 | \$$1 \$@ | 22 | \$$1 \$@ |
| 18 | EOF | 23 | EOF |
| 19 | 24 | ||
| @@ -32,8 +37,17 @@ do_install () { | |||
| 32 | install -m 0644 "${RUST_TARGETS_DIR}/${RUST_TARGET_SYS}.json" "${RUSTLIB_DIR}" | 37 | install -m 0644 "${RUST_TARGETS_DIR}/${RUST_TARGET_SYS}.json" "${RUSTLIB_DIR}" |
| 33 | 38 | ||
| 34 | # Uses SDK's CC as linker so linked binaries works out of box. | 39 | # Uses SDK's CC as linker so linked binaries works out of box. |
| 40 | # We have a problem as rust sets LD_LIBRARY_PATH and this will break running host | ||
| 41 | # binaries (even /bin/sh) in the SDK as they detect a newer glibc from the SDK | ||
| 42 | # in those paths and we hit symbol errors. We saw particular problems with symbol | ||
| 43 | # mismatch on ubuntu1804 during development. To avoid this we have an SDK built | ||
| 44 | # binary which unsets LD_LIBRARY_PATH, which can then call the wrapper script | ||
| 45 | # where the context is easier to do the env maniupations needed | ||
| 35 | install -d ${SYS_BINDIR} | 46 | install -d ${SYS_BINDIR} |
| 36 | create_sdk_wrapper "${SYS_BINDIR}/target-rust-ccld" "CC" | 47 | outfile="${SYS_BINDIR}/target-rust-ccld" |
| 48 | ${CC} ${WORKDIR}/target-rust-ccld.c -o $outfile | ||
| 49 | chmod +x "$outfile" | ||
| 50 | create_sdk_wrapper "${SYS_BINDIR}/target-rust-ccld-wrapper" "CC" | ||
| 37 | 51 | ||
| 38 | ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d | 52 | ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d |
| 39 | mkdir "${ENV_SETUP_DIR}" | 53 | mkdir "${ENV_SETUP_DIR}" |
