Skip to content

Commit fb5c529

Browse files
fix: node android add wasm trap-handler sources to v8.gyp
host mksnapshot link failed with undefined references to trap_handler::TryHandleSignal / RegisterDefaultTrapHandler and v8_internal_simulator_ProbeMemory. v8.gyp gates those sources (handler-inside-posix.cc, handler-outside-posix.cc, handler-outside-simulator.cc) on OS in linux/mac/ios/win/openharmony but omits android (upstream fix nodejs/node#52888); patch the OS lists to include android before configure.
1 parent 4873080 commit fb5c529

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

‎scripts/node/build-android.sh‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,45 @@ export AR_host="${AR_host:-ar}"
6060
# so drop it BEFORE configure (gyp reads the gypi at configure time).
6161
sed -i.bak '/openssl.gyp:openssl-cli/d' node.gypi
6262

63+
# v8.gyp (tools/v8_gypfiles) adds the wasm trap-handler sources
64+
# (handler-inside-posix.cc / handler-outside-posix.cc) and the simulator probe
65+
# helper (handler-outside-simulator.cc) to v8_base_without_compiler only under
66+
# OS in "linux mac ios openharmony" / "linux mac win openharmony" (upstream
67+
# riscv64/loong64 fix, nodejs/node#52888). OS=="android" is missing, so when
68+
# cross-compiling for Android arm64 the host mksnapshot (built under the arm64
69+
# simulator on x64) links v8_base_without_compiler WITHOUT those objects and
70+
# fails with undefined references to trap_handler::TryHandleSignal /
71+
# RegisterDefaultTrapHandler and v8_internal_simulator_ProbeMemory. Patch the
72+
# OS lists to include android BEFORE configure (gyp reads v8.gyp to emit the
73+
# Makefiles). Exact-string replacements; each pattern appears only in the
74+
# arm64 blocks (both the .cc sources and the v8_internal_headers .h lists).
75+
python3 - <<'PY'
76+
import io
77+
78+
path = 'tools/v8_gypfiles/v8.gyp'
79+
with io.open(path, encoding='utf-8') as f:
80+
s = f.read()
81+
82+
repls = [
83+
('and (OS in "linux mac ios openharmony")',
84+
'and (OS in "linux mac ios openharmony android")'),
85+
('and (OS in "linux mac openharmony")',
86+
'and (OS in "linux mac openharmony android")'),
87+
('and (OS in "linux mac win openharmony")',
88+
'and (OS in "linux mac win openharmony android")'),
89+
]
90+
for old, new in repls:
91+
n = s.count(old)
92+
if n == 0:
93+
print('WARNING: v8.gyp pattern not found: %s' % old)
94+
else:
95+
print('v8.gyp: patched %d occurrence(s) of %s' % (n, old))
96+
s = s.replace(old, new)
97+
98+
with io.open(path, 'w', encoding='utf-8') as f:
99+
f.write(s)
100+
PY
101+
63102
# node v24 android builds are driven by ./android-configure (sets GYP_DEFINES
64103
# android_ndk_path). Usage: android-configure <ndk_path> <api> <arch>
65104
./android-configure "$NDK_ROOT" "$ANDROID_API" "$NDK_ARCH"

0 commit comments

Comments
 (0)