xref: /OK3568_Linux_fs/buildroot/package/nodejs/0001-add-qemu-wrapper-support.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From fa09fa3ad6a21ae0b35fb860f76d1762e5f29972 Mon Sep 17 00:00:00 2001
2From: Adam Duskett <aduskett@gmail.com>
3Date: Mon, 27 Sep 2021 12:55:09 -0700
4Subject: [PATCH] add qemu-wrapper support
5
6V8's JIT infrastructure requires binaries such as mksnapshot and mkpeephole to
7be run in the host during the build. However, these binaries must have the
8same bit-width as the target (e.g. a x86_64 host targeting ARMv6 needs to
9produce a 32-bit binary). To work around this issue, cross-compile the
10binaries for the target and run them on the host with QEMU, much like
11gobject-introspection.
12
13However, for the host-variant we do not want to use a
14qemu-wrapper, so add @MAYBE_WRAPPER@ to the needed files and sed the path to
15the qemu-wrapper on target builds, and remove @MAYBE_WRAPPER@ entirely on
16host-builds.
17
18Signed-off-by: Adam Duskett <aduskett@gmail.com>
19---
20 node.gyp                 | 4 ++--
21 tools/v8_gypfiles/v8.gyp | 8 ++++----
22 2 files changed, 6 insertions(+), 6 deletions(-)
23
24diff --git a/node.gyp b/node.gyp
25index 8ba0dfeb..c77f6f7d 100644
26--- a/node.gyp
27+++ b/node.gyp
28@@ -491,7 +491,7 @@
29               'action_name': 'run_mkcodecache',
30               'process_outputs_as_sources': 1,
31               'inputs': [
32-                '<(mkcodecache_exec)',
33+                @MAYBE_WRAPPER@ '<(mkcodecache_exec)',
34               ],
35               'outputs': [
36                 '<(SHARED_INTERMEDIATE_DIR)/node_code_cache.cc',
37@@ -516,7 +516,7 @@
38               'action_name': 'node_mksnapshot',
39               'process_outputs_as_sources': 1,
40               'inputs': [
41-                '<(node_mksnapshot_exec)',
42+                @MAYBE_WRAPPER@ '<(node_mksnapshot_exec)',
43               ],
44               'outputs': [
45                 '<(SHARED_INTERMEDIATE_DIR)/node_snapshot.cc',
46diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp
47index 48ec392b..f9bb0fbe 100644
48--- a/tools/v8_gypfiles/v8.gyp
49+++ b/tools/v8_gypfiles/v8.gyp
50@@ -220,7 +220,7 @@
51         {
52           'action_name': 'run_torque_action',
53           'inputs': [  # Order matters.
54-            '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)torque<(EXECUTABLE_SUFFIX)',
55+            @MAYBE_WRAPPER@ '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)torque<(EXECUTABLE_SUFFIX)',
56             '<@(torque_files)',
57           ],
58           'outputs': [
59@@ -351,7 +351,7 @@
60         {
61           'action_name': 'generate_bytecode_builtins_list_action',
62           'inputs': [
63-            '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)bytecode_builtins_list_generator<(EXECUTABLE_SUFFIX)',
64+            @MAYBE_WRAPPER@ '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)bytecode_builtins_list_generator<(EXECUTABLE_SUFFIX)',
65           ],
66           'outputs': [
67             '<(generate_bytecode_builtins_list_output)',
68@@ -533,7 +533,7 @@
69             ],
70           },
71           'inputs': [
72-            '<(mksnapshot_exec)',
73+            @MAYBE_WRAPPER@ '<(mksnapshot_exec)',
74           ],
75           'outputs': [
76             '<(INTERMEDIATE_DIR)/snapshot.cc',
77@@ -1448,7 +1448,7 @@
78         {
79           'action_name': 'run_gen-regexp-special-case_action',
80           'inputs': [
81-            '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)gen-regexp-special-case<(EXECUTABLE_SUFFIX)',
82+            @MAYBE_WRAPPER@ '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)gen-regexp-special-case<(EXECUTABLE_SUFFIX)',
83           ],
84           'outputs': [
85             '<(SHARED_INTERMEDIATE_DIR)/src/regexp/special-case.cc',
86--
872.31.1
88
89