blob: 7b938179c33da2e5dd6e0b114269f5073163ebc8 [file] [log] [blame]
Andrew Geissler595f6302022-01-24 19:11:47 +00001From 9eceb43dd676afe2f675bd65ab369ba4d14f6537 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 build/cargo-host-linker | 24 +++++++---
23 1 file changed, 21 insertions(+), 3 deletions(-)
24
25diff --git a/build/cargo-host-linker b/build/cargo-host-linker
26index cbd0472bf7..ccd8bffec1 100755
27--- a/build/cargo-host-linker
28+++ b/build/cargo-host-linker
29@@ -1,3 +1,21 @@
30-#!/bin/sh
31-# See comment in cargo-linker.
32-eval ${MOZ_CARGO_WRAP_HOST_LD} ${MOZ_CARGO_WRAP_HOST_LDFLAGS} '"$@"'
33+#!/usr/bin/env python3
34+
35+import os,sys
36+
37+if os.environ['MOZ_CARGO_WRAP_HOST_LD'].strip():
38+ binary=os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[0]
39+else:
40+ sys.exit(0)
41+
42+if os.environ['MOZ_CARGO_WRAP_HOST_LDFLAGS'].strip():
43+ if os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[1:]:
44+ 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:]
45+ else:
46+ args=[os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[0]] + [os.environ['MOZ_CARGO_WRAP_HOST_LDFLAGS']] + sys.argv[1:]
47+else:
48+ if os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[1:]:
49+ args=[os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[0]] + os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[1:] + sys.argv[1:]
50+ else:
51+ args=[os.environ['MOZ_CARGO_WRAP_HOST_LD'].split()[0]] + sys.argv[1:]
52+
53+os.execvp(binary, args)
54--
552.33.1
56