Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1 | From 8e318c4e7e732327dabf51027860de45b6fb731e Mon Sep 17 00:00:00 2001 |
| 2 | From: Changqing Li <changqing.li@windriver.com> |
| 3 | Date: Thu, 18 Nov 2021 07:16:39 +0000 |
| 4 | Subject: [PATCH] Rewrite cargo-host-linker in python3 |
| 5 | |
| 6 | Mozjs compile failed with this failure: |
| 7 | /bin/sh: /lib64/libc.so.6: version `GLIBC_2.33' not found (required by /build/tmp-glibc/work/corei7-64-wrs-linux/mozjs/91.1.0-r0/recipe-sysroot-native/usr/lib/libtinfo.so.5) |
| 8 | |
| 9 | Root Cause: |
| 10 | cargo-host-linker has /bin/sh as it's interpreter, but cargo run the cmd |
| 11 | with LD_LIBRARY_PATH set to recipe-sysroot-native. The host /bin/sh links |
| 12 | libtinfo.so.5 under recipe-sysroot-native, which needs higher libc. But |
| 13 | host libc is older libc. So the incompatible problem occurred. |
| 14 | |
| 15 | Solution: |
| 16 | rewrite cargo-host-linker in python3 |
| 17 | |
| 18 | Upstream-Status: Inappropriate [oe specific] |
| 19 | |
| 20 | Signed-off-by: Changqing Li <changqing.li@windriver.com> |
| 21 | |
| 22 | --- |
| 23 | build/cargo-host-linker | 24 +++++++++++++++++++++--- |
| 24 | 1 file changed, 21 insertions(+), 3 deletions(-) |
| 25 | |
| 26 | diff --git a/build/cargo-host-linker b/build/cargo-host-linker |
| 27 | index cbd0472bf7..87d43ce9ec 100755 |
| 28 | --- a/build/cargo-host-linker |
| 29 | +++ b/build/cargo-host-linker |
| 30 | @@ -1,3 +1,21 @@ |
| 31 | -#!/bin/sh |
| 32 | -# See comment in cargo-linker. |
| 33 | -eval ${MOZ_CARGO_WRAP_HOST_LD} ${MOZ_CARGO_WRAP_HOST_LDFLAGS} '"$@"' |
| 34 | +#!/usr/bin/env python3 |
| 35 | + |
| 36 | +import os,sys |
| 37 | + |
| 38 | +if os.environ['MOZ_CARGO_WRAP_HOST_LD'].strip(): |
| 39 | + binary=os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[0] |
| 40 | +else: |
| 41 | + sys.exit(0) |
| 42 | + |
| 43 | +if os.environ['MOZ_CARGO_WRAP_HOST_LDFLAGS'].strip(): |
| 44 | + if os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[1:]: |
| 45 | + args=[os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[0]] + os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[1:] + [os.environ['MOZ_CARGO_WRAP_HOST_LDFLAGS']] + sys.argv[1:] |
| 46 | + else: |
| 47 | + args=[os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[0]] + [os.environ['MOZ_CARGO_WRAP_HOST_LDFLAGS']] + sys.argv[1:] |
| 48 | +else: |
| 49 | + if os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[1:]: |
| 50 | + args=[os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[0]] + os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[1:] + sys.argv[1:] |
| 51 | + else: |
| 52 | + args=[os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[0]] + sys.argv[1:] |
| 53 | + |
| 54 | +os.execvp(binary, args) |