Skip to content

Commit d4b5c33

Browse files
authored
Create 0003-ldpreload-libffi7.patch
1 parent 5f14d18 commit d4b5c33

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--- a/build/gn_run_binary.py
2+
+++ b/build/gn_run_binary.py
3+
@@ -23,7 +23,19 @@
4+
# The rest of the arguments are passed directly to the executable.
5+
args = [path] + sys.argv[2:]
6+
7+
-ret = subprocess.call(args)
8+
+# Modified by Termux: When building for termux, this wrapper will
9+
+# be used to run the binary which is built for host machine, using
10+
+# the rootfs provided by Google. We need to set LD_PRELOAD with
11+
+# libffi.so.7 as the host machine (Ubuntu 24.04) doesn't provide it.
12+
+envs = os.environ.copy()
13+
+if "./clang_x86_v8_arm/" in path or "./clang_x86/" in path:
14+
+ base_sysroot = os.path.join(os.path.dirname(__file__), "linux", "debian_bullseye_i386-sysroot")
15+
+ envs["LD_PRELOAD"] = base_sysroot + "/usr/lib/i386-linux-gnu/libffi.so.7"
16+
+elif "./host/" in path or "./clang_x64_v8_arm64/" in path or "./clang_x64/" in path:
17+
+ base_sysroot = os.path.join(os.path.dirname(__file__), "linux", "debian_bullseye_amd64-sysroot")
18+
+ envs["LD_PRELOAD"] = base_sysroot + "/usr/lib/x86_64-linux-gnu/libffi.so.7"
19+
+
20+
+ret = subprocess.call(args, env=envs)
21+
if ret != 0:
22+
if ret <= -100:
23+
# Windows error codes such as 0xC0000005 and 0xC0000409 are much easier to

0 commit comments

Comments
 (0)