diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-09-01 15:28:26 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-09-02 21:22:54 +0100 |
commit | 63b1fd2226b5f146d6c853cc57417704df378438 (patch) | |
tree | e31c04a62f47f317feb0f7296a78446425e7719b /meta/files | |
parent | 640136a72b3bb6f832b08ca0e12f774c925d36c8 (diff) | |
download | poky-63b1fd2226b5f146d6c853cc57417704df378438.tar.gz |
rust-common: Hack around LD_LIBRARY_PATH issues on centos7
When building cargo-native on centos7 with buildtools tarball installed,
we see failures:
/bin/sh: /lib64/libc.so.6: version `GLIBC_2.33' not found (required by /home/pokybuild/yocto-worker/reproducible-centos/build/build-st/tmp/work/x86_64-linux/cargo-native/1.54.0-r0/recipe-sysroot-native/usr/lib/libtinfo.so.5)
We also see this for libstd-rs once cargo-native is fixed.
The reason for this is that the wrapper script
cargo-native/1.54.0-r0/wrapper/target-rust-ccld has /bin/sh as it's
interpreter and cargo calls this with LD_LIBRARY_PATH set to include the
recipe-sysroot-native. The host /bin/sh links to libtinfo from the host
but it finds the version in the sysroot which needs a newer libc. This
results in the above error since the loader is an older libc and the two
are incompatible.
Our ccld wrapper calls gcc/ld which don't need the LD_LIBRARY_PATH
variable set. We can't patch this out the source since we're using
a prebuilt binary to generate a new cargo binary so this is impossible
to bootstrap.
Instead, put a binary wrapper into place which removes LD_LIBRARY_PATH
from the environment before calling the original wrapper (left in shell
as it is simpler to maintain).
(From OE-Core rev: 8feeeb7f76c6725e5226458c8f22999b67c52694)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/files')
-rw-r--r-- | meta/files/rust-ccld-wrapper.c | 29 |
1 files changed, 29 insertions, 0 deletions
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 @@ | |||
1 | /* | ||
2 | * Copyright 2021 Richard Purdie | ||
3 | * | ||
4 | * SPDX-License-Identifier: GPL-2.0-only | ||
5 | */ | ||
6 | |||
7 | #include <errno.h> | ||
8 | #include <stdio.h> | ||
9 | #include <stdlib.h> | ||
10 | #include <string.h> | ||
11 | #include <unistd.h> | ||
12 | |||
13 | /* | ||
14 | * Run the original script (argv[0] + ".real") with LD_LIBRARY_PATH unset | ||
15 | * This avoids issues where cargo is running a wrapper script using /bin/sh from the host | ||
16 | * which links to something which has an incompatible version in in recipe-sysroot-native | ||
17 | * such as libtinfo on centos 7. | ||
18 | */ | ||
19 | |||
20 | int main(int argc, char* argv[]) { | ||
21 | char *real = malloc(strlen(argv[0] + 5)); | ||
22 | strcpy(real, argv[0]); | ||
23 | strcpy(real + strlen(argv[0]), ".real"); | ||
24 | putenv("LD_LIBRARY_PATH="); | ||
25 | if(execv(real, argv) == -1) { | ||
26 | printf("Wrapper failed to execute, error: %s\n", strerror(errno)); | ||
27 | return -1; | ||
28 | } | ||
29 | } | ||