Repository: node
Issue: Cross compile node v14.x or v.15.x for android x86_64
Labels: build,android

<!--
Thank you for reporting an issue.

This issue tracker is for bugs and issues found within Node.js core.
If you require more general support please file an issue on our help
repo. https://github.com/nodejs/help


Please fill in as much of the template below as you're able.

Version: output of `node -v`
Platform: output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows)
Subsystem: if known, please specify affected core module name
-->

* **Version**: v14.15.1 and v15.3.0
* **Platform**: cross compile for androidx86_64. Host (5.4.0-53-generic #59~18.04.1-Ubuntu SMP Wed Oct 21 12:14:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux). Target (androidx86_64 sdk24)
* **Subsystem**: mksnapshot build fail

### What steps will reproduce the bug?

```
> source android-configure /path_to_ndk x86_64 24
> make -j8
```
The Android NDK version: Linux 64-bit (x86) r21, download from https://developer.android.com/ndk/downloads 

<!--
Enter details about your bug, preferably a simple code snippet that can be
run using `node` directly without installing third-party dependencies.
-->

### How often does it reproduce? Is there a required condition?
The build always stuck as below state.
### What is the expected behavior?
Build without error
<!--
If possible please provide textual output instead of screenshots.
-->

### What do you see instead?
```
/usr/bin/g++ -rdynamic -m64 -pthread -m64 -fPIC  -o /node/out/Release/mksnapshot -Wl,--start-group /node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/embedded/embedded-empty.o /node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/embedded/embedded-file-writer.o /node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-aix.o /node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-base.o /node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.o /node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-mac.o /node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-win.o /node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/mksnapshot.o /node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/snapshot-empty.o /node/out/Release/obj.host/tools/v8_gypfiles/libv8_base_without_compiler.a /node/out/Release/obj.host/tools/v8_gypfiles/libv8_init.a /node/out/Release/obj.host/tools/v8_gypfiles/libv8_libbase.a /node/out/Release/obj.host/tools/v8_gypfiles/libv8_libplatform.a /node/out/Release/obj.host/tools/icu/libicutools.a /node/out/Release/obj.host/tools/v8_gypfiles/libv8_libsampler.a /node/out/Release/obj.host/tools/v8_gypfiles/libv8_zlib.a /node/out/Release/obj.host/tools/v8_gypfiles/libv8_compiler.a /node/out/Release/obj.host/tools/v8_gypfiles/libv8_initializers.a -Wl,--end-group -ldl -lrt
/node/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/api/api.o: In function `v8::TryHandleWebAssemblyTrapPosix(int, siginfo_t*, void*)':
api.cc:(.text._ZN2v829TryHandleWebAssemblyTrapPosixEiP9siginfo_tPv+0x6): undefined reference to `v8::internal::trap_handler::TryHandleSignal(int, siginfo_t*, void*)'
/node/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/trap-handler/handler-outside.o: In function `v8::internal::trap_handler::EnableTrapHandler(bool)':
handler-outside.cc:(.text._ZN2v88internal12trap_handler17EnableTrapHandlerEb+0x1d): undefined reference to `v8::internal::trap_handler::RegisterDefaultTrapHandler()'
collect2: error: ld returned 1 exit status

```
<!--
If possible please provide textual output instead of screenshots.
-->

### Additional information
<!--
Tell us anything else you think we should know.
-->
I noted that in _v8_base_without_compiler_ build config at [_deps/v8/BUILD.gn_](https://github.com/nodejs/node/blob/0a23d65a629596935d525531fc15811538c1664c/deps/v8/BUILD.gn#L3481), _EnableTrapHandler_ and _RegisterDefaultTrapHandler_ are defined for Linux and x64 platform, but I don't see it generated in _out/tools/v8_gypfiles/v8_base_without_compiler.target(host).mk_ (even I change the condition to always true)

I wonder is this an expected behavior?

I fixed it temporarily by disabling undefined code paths and the node can work normally in the target platform.

```
diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc
index 3b6226b0f4..9f346bcfc8 100644
--- a/deps/v8/src/api/api.cc
+++ b/deps/v8/src/api/api.cc
@@ -5646,7 +5646,8 @@ bool v8::V8::Initialize(const int build_config) {
 bool TryHandleWebAssemblyTrapPosix(int sig_code, siginfo_t* info,
                                    void* context) {
 #if V8_TARGET_ARCH_X64 && !V8_OS_ANDROID
-  return i::trap_handler::TryHandleSignal(sig_code, info, context);
+  // return i::trap_handler::TryHandleSignal(sig_code, info, context);
+  return false;
 #else
   return false;
 #endif
diff --git a/deps/v8/src/trap-handler/handler-outside.cc b/deps/v8/src/trap-handler/handler-outside.cc
index 1efbc398d0..497cf2894c 100644
--- a/deps/v8/src/trap-handler/handler-outside.cc
+++ b/deps/v8/src/trap-handler/handler-outside.cc
@@ -256,7 +256,8 @@ bool EnableTrapHandler(bool use_v8_handler) {
     return false;
   }
   if (use_v8_handler) {
-    g_is_trap_handler_enabled = RegisterDefaultTrapHandler();
+    // g_is_trap_handler_enabled = RegisterDefaultTrapHandler();
+    g_is_trap_handler_enabled = false;
     return g_is_trap_handler_enabled;
   }
   g_is_trap_handler_enabled = true;
```
I wonder if there are any further issues if I do this. 

Thanks