diff options
author | Alexander Kanavin <alex.kanavin@gmail.com> | 2021-10-10 21:10:06 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-14 11:48:45 +0100 |
commit | 4abd6ee9d480437010e589ce215e20b835d3dad4 (patch) | |
tree | c32b141da327ef42bb53f75a355d10b061940fbb /meta | |
parent | bcab6dd34ff3bf045fae474e883423015469482e (diff) | |
download | poky-4abd6ee9d480437010e589ce215e20b835d3dad4.tar.gz |
rust-common.bbclass: rewrite toolchain wrappers in (native) python
librsvg on centos 7 and friends exhibits the same libtinfo leakage
problem, this time coming from the compiler and not the linker.
Simply covering the compiler by the existing C wrapper-of-wrapper
does not work, as rust-native builds put Important Stuff into
LD_LIBRARY_PATH and unsetting it breaks things badly.
Rather than try to figure out which combination of wrappers and
LD_LIBRARY_PATH settings works for which situation, or provide
some kind of sh-native, let's simply use python3-native for the
wrappers, which should insulate builds from the the host shell.
rust-native already depends on python3-native, so this does not
lengthen the builds.
This also reverts:
rust-common: Hack around LD_LIBRARY_PATH issues on centos7
(commit 63b1fd2226b5f146d6c853cc57417704df378438).
I'd also like to say boo to Red Hat (or GNU?) for breaking ABI
compatibility for stat() in glibc 2.33, we ended up sorting
this mess because of it.
(From OE-Core rev: 997d54363a3cb3a0e949b3626855f2fa41afeb2b)
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/rust-common.bbclass | 15 | ||||
-rw-r--r-- | meta/files/rust-ccld-wrapper.c | 29 |
2 files changed, 8 insertions, 36 deletions
diff --git a/meta/classes/rust-common.bbclass b/meta/classes/rust-common.bbclass index f7f9cbbb2e..98d65970e8 100644 --- a/meta/classes/rust-common.bbclass +++ b/meta/classes/rust-common.bbclass | |||
@@ -1,3 +1,5 @@ | |||
1 | inherit python3native | ||
2 | |||
1 | # Common variables used by all Rust builds | 3 | # Common variables used by all Rust builds |
2 | export rustlibdir = "${libdir}/rust" | 4 | export rustlibdir = "${libdir}/rust" |
3 | FILES:${PN} += "${rustlibdir}/*.so" | 5 | FILES:${PN} += "${rustlibdir}/*.so" |
@@ -133,8 +135,12 @@ create_wrapper () { | |||
133 | shift | 135 | shift |
134 | 136 | ||
135 | cat <<- EOF > "${file}" | 137 | cat <<- EOF > "${file}" |
136 | #!/bin/sh | 138 | #!/usr/bin/env python3 |
137 | exec $@ "\$@" | 139 | import os, sys |
140 | orig_binary = "$@" | ||
141 | binary = orig_binary.split()[0] | ||
142 | args = orig_binary.split() + sys.argv[1:] | ||
143 | os.execvp(binary, args) | ||
138 | EOF | 144 | EOF |
139 | chmod +x "${file}" | 145 | chmod +x "${file}" |
140 | } | 146 | } |
@@ -169,11 +175,6 @@ do_rust_create_wrappers () { | |||
169 | # Yocto Target / Rust Target archiver | 175 | # Yocto Target / Rust Target archiver |
170 | create_wrapper "${RUST_TARGET_AR}" "${WRAPPER_TARGET_AR}" | 176 | create_wrapper "${RUST_TARGET_AR}" "${WRAPPER_TARGET_AR}" |
171 | 177 | ||
172 | # Need to filter out LD_LIBRARY_PATH from the linker without using shell | ||
173 | mv ${RUST_BUILD_CCLD} ${RUST_BUILD_CCLD}.real | ||
174 | ${BUILD_CC} ${COREBASE}/meta/files/rust-ccld-wrapper.c -o ${RUST_BUILD_CCLD} | ||
175 | mv ${RUST_TARGET_CCLD} ${RUST_TARGET_CCLD}.real | ||
176 | ${BUILD_CC} ${COREBASE}/meta/files/rust-ccld-wrapper.c -o ${RUST_TARGET_CCLD} | ||
177 | } | 178 | } |
178 | 179 | ||
179 | addtask rust_create_wrappers before do_configure after do_patch do_prepare_recipe_sysroot | 180 | addtask rust_create_wrappers before do_configure after do_patch do_prepare_recipe_sysroot |
diff --git a/meta/files/rust-ccld-wrapper.c b/meta/files/rust-ccld-wrapper.c deleted file mode 100644 index 6bc9958b90..0000000000 --- a/meta/files/rust-ccld-wrapper.c +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
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 | } | ||