1Backport V8_TRAP_HANDLER_SUPPORTED conditional compilation for trap
2handler implementation.
3
4See https://github.com/v8/v8/commit/e7bef8d4cc4f38cc3d5a532fbcc445dc62adc08f
5
6E.g. when cross-compiling from aarch64-linux for x86_64-linux target,
7handler-inside-posix.cc is built on aarch64-linux even though it is not
8supported; see src/trap-handler/trap-handler.h in v8 for (host, target)
9combinations where trap handler is supported.
10
11Note that handler-inside-posix.cc fails to build in the case above.
12
13diff --git a/deps/v8/src/trap-handler/handler-inside-posix.cc b/deps/v8/src/trap-handler/handler-inside-posix.cc
14index e4454c378f..17af3d75dc 100644
15--- a/deps/v8/src/trap-handler/handler-inside-posix.cc
16+++ b/deps/v8/src/trap-handler/handler-inside-posix.cc
17@@ -47,6 +47,8 @@ namespace v8 {
18 namespace internal {
19 namespace trap_handler {
20
21+#if V8_TRAP_HANDLER_SUPPORTED
22+
23 #if V8_OS_LINUX
24 #define CONTEXT_REG(reg, REG) &uc->uc_mcontext.gregs[REG_##REG]
25 #elif V8_OS_DARWIN
26@@ -181,6 +183,8 @@ void HandleSignal(int signum, siginfo_t* info, void* context) {
27 // TryHandleSignal modifies context to change where we return to.
28 }
29
30+#endif
31+
32 } // namespace trap_handler
33 } // namespace internal
34 } // namespace v8
35diff --git a/deps/v8/src/trap-handler/handler-inside-win.cc b/deps/v8/src/trap-handler/handler-inside-win.cc
36index fcccc78ee5..3d7a2c416a 100644
37--- a/deps/v8/src/trap-handler/handler-inside-win.cc
38+++ b/deps/v8/src/trap-handler/handler-inside-win.cc
39@@ -38,6 +38,8 @@ namespace v8 {
40 namespace internal {
41 namespace trap_handler {
42
43+#if V8_TRAP_HANDLER_SUPPORTED
44+
45 // The below struct needed to access the offset in the Thread Environment Block
46 // to see if the thread local storage for the thread has been allocated yet.
47 //
48@@ -129,6 +131,8 @@ LONG HandleWasmTrap(EXCEPTION_POINTERS* exception) {
49 return EXCEPTION_CONTINUE_SEARCH;
50 }
51
52+#endif
53+
54 } // namespace trap_handler
55 } // namespace internal
56 } // namespace v8
57diff --git a/deps/v8/src/trap-handler/handler-outside-simulator.cc b/deps/v8/src/trap-handler/handler-outside-simulator.cc
58index 179eab0659..5e58719e7f 100644
59--- a/deps/v8/src/trap-handler/handler-outside-simulator.cc
60+++ b/deps/v8/src/trap-handler/handler-outside-simulator.cc
61@@ -4,6 +4,9 @@
62
63 #include "include/v8config.h"
64 #include "src/trap-handler/trap-handler-simulator.h"
65+#include "src/trap-handler/trap-handler.h"
66+
67+#if V8_TRAP_HANDLER_SUPPORTED
68
69 #if V8_OS_DARWIN
70 #define SYMBOL(name) "_" #name
71@@ -35,3 +38,5 @@ asm(
72 SYMBOL(v8_probe_memory_continuation) ": \n"
73 // If the trap handler continues here, it wrote the landing pad in %rax.
74 " ret \n");
75+
76+#endif