blob: 73bcffe94a5afb7204da14dc1284ff0de1f58764 [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001From 8e318c4e7e732327dabf51027860de45b6fb731e Mon Sep 17 00:00:00 2001
2From: Changqing Li <changqing.li@windriver.com>
3Date: Thu, 18 Nov 2021 07:16:39 +0000
4Subject: [PATCH] Rewrite cargo-host-linker in python3
5
6Mozjs 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
9Root Cause:
10cargo-host-linker has /bin/sh as it's interpreter, but cargo run the cmd
11with LD_LIBRARY_PATH set to recipe-sysroot-native. The host /bin/sh links
12libtinfo.so.5 under recipe-sysroot-native, which needs higher libc. But
13host libc is older libc. So the incompatible problem occurred.
14
15Solution:
16rewrite cargo-host-linker in python3
17
18Upstream-Status: Inappropriate [oe specific]
19
20Signed-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
26diff --git a/build/cargo-host-linker b/build/cargo-host-linker
27index 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)