--- a/tools/v8_gypfiles/v8.gyp
+++ b/tools/v8_gypfiles/v8.gyp
@@ -797,6 +797,15 @@
                   '<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn"  "v8_header_set.\\"v8_internal_headers\\".*?v8_enable_i18n_support.*?v8_current_cpu == \\"riscv64\\".*?v8_enable_sparkplug.*?sources \\+= ")',
                 ],
               }],
+              ['v8_enable_webassembly==1', {
+                'conditions': [
+                  ['OS=="linux"', {
+                    'sources': [
+                      '<(V8_ROOT)/src/trap-handler/handler-inside-posix.h',
+                    ],
+                  }],
+                ],
+              }],
             ],
           }],
           ['v8_target_arch=="loong64"', {
@@ -1167,6 +1176,18 @@
         ['v8_target_arch=="riscv64"', {
           'sources': [
             '<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn"  "\\"v8_base_without_compiler.*?v8_enable_wasm_gdb_remote_debugging.*?v8_current_cpu == \\"riscv64\\".*?sources \\+= ")',
+          ],
+          'conditions': [
+            ['v8_enable_webassembly==1', {
+              'conditions': [
+                ['OS=="linux"', {
+                  'sources': [
+                    '<(V8_ROOT)/src/trap-handler/handler-inside-posix.cc',
+                    '<(V8_ROOT)/src/trap-handler/handler-outside-posix.cc',
+                  ],
+                }],
+              ],
+            }],
           ],
         }],
         ['v8_target_arch=="loong64"', {