diff options
-rw-r--r-- | meta/classes/rust-common.bbclass | 5 | ||||
-rw-r--r-- | meta/files/rust-ccld-wrapper.c | 29 |
2 files changed, 34 insertions, 0 deletions
diff --git a/meta/classes/rust-common.bbclass b/meta/classes/rust-common.bbclass index e1bc0193c3..a8803d61b6 100644 --- a/meta/classes/rust-common.bbclass +++ b/meta/classes/rust-common.bbclass @@ -169,6 +169,11 @@ do_rust_create_wrappers () { # Yocto Target / Rust Target archiver create_wrapper "${RUST_TARGET_AR}" "${WRAPPER_TARGET_AR}" + # Need to filter out LD_LIBRARY_PATH from the linker without using shell + mv ${RUST_BUILD_CCLD} ${RUST_BUILD_CCLD}.real + ${BUILD_CC} ${COREBASE}/meta/files/rust-ccld-wrapper.c -o ${RUST_BUILD_CCLD} + mv ${RUST_TARGET_CCLD} ${RUST_TARGET_CCLD}.real + ${BUILD_CC} ${COREBASE}/meta/files/rust-ccld-wrapper.c -o ${RUST_TARGET_CCLD} } addtask rust_create_wrappers before do_configure after do_patch diff --git a/meta/files/rust-ccld-wrapper.c b/meta/files/rust-ccld-wrapper.c new file mode 100644 index 0000000000..6bc9958b90 --- /dev/null +++ b/meta/files/rust-ccld-wrapper.c @@ -0,0 +1,29 @@ +/* + * Copyright 2021 Richard Purdie + * + * SPDX-License-Identifier: GPL-2.0-only + */ + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +/* + * Run the original script (argv[0] + ".real") with LD_LIBRARY_PATH unset + * This avoids issues where cargo is running a wrapper script using /bin/sh from the host + * which links to something which has an incompatible version in in recipe-sysroot-native + * such as libtinfo on centos 7. + */ + +int main(int argc, char* argv[]) { + char *real = malloc(strlen(argv[0] + 5)); + strcpy(real, argv[0]); + strcpy(real + strlen(argv[0]), ".real"); + putenv("LD_LIBRARY_PATH="); + if(execv(real, argv) == -1) { + printf("Wrapper failed to execute, error: %s\n", strerror(errno)); + return -1; + } +} |