]> code.ossystems Code Review - openembedded-core.git/commitdiff
rust-common.bbclass: rewrite toolchain wrappers in (native) python
authorAlexander Kanavin <alex.kanavin@gmail.com>
Sun, 10 Oct 2021 19:10:06 +0000 (21:10 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 14 Oct 2021 10:48:35 +0000 (11:48 +0100)
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.

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>
meta/classes/rust-common.bbclass
meta/files/rust-ccld-wrapper.c [deleted file]

index f7f9cbbb2e032666d74b78773cabf017a7b3f760..98d65970e8c077c7aa23543b99abbd191f1dd629 100644 (file)
@@ -1,3 +1,5 @@
+inherit python3native
+
 # Common variables used by all Rust builds
 export rustlibdir = "${libdir}/rust"
 FILES:${PN} += "${rustlibdir}/*.so"
@@ -133,8 +135,12 @@ create_wrapper () {
        shift
 
        cat <<- EOF > "${file}"
-       #!/bin/sh
-       exec $@ "\$@"
+       #!/usr/bin/env python3
+       import os, sys
+       orig_binary = "$@"
+       binary = orig_binary.split()[0]
+       args = orig_binary.split() + sys.argv[1:]
+       os.execvp(binary, args)
        EOF
        chmod +x "${file}"
 }
@@ -169,11 +175,6 @@ 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 do_prepare_recipe_sysroot
diff --git a/meta/files/rust-ccld-wrapper.c b/meta/files/rust-ccld-wrapper.c
deleted file mode 100644 (file)
index 6bc9958..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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;
-    }
-}