Skip to content

Commit

Permalink
Only check for WebAssembly support in debug builds. NFC (#21511)
Browse files Browse the repository at this point in the history
Also, avoid the use of `abort` in this case since abort itself depends
on `WebAssembly.RuntimeError`.

Fixes: #21484
  • Loading branch information
sbc100 authored Mar 13, 2024
1 parent 0b55292 commit 5f9ee69
Show file tree
Hide file tree
Showing 77 changed files with 87 additions and 85 deletions.
4 changes: 2 additions & 2 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ if (Module['doWasm2JS']) {
#endif
#endif

#if WASM == 1
#if ASSERTIONS && WASM == 1
if (typeof WebAssembly != 'object') {
abort('no native wasm support detected');
err('no native wasm support detected');
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_ctors1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9883
9853
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_ctors1.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24310
24243
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_ctors2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9866
9836
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_ctors2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24278
24211
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_except.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10968
10931
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_except.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
28182
28115
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_except_wasm.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9850
9818
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_except_wasm.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24204
24136
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_mangle.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10979
10939
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_mangle.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
28183
28116
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_noexcept.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9883
9853
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_noexcept.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24310
24243
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5245
5212
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12122
12055
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_files_js_fs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7840
7813
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_files_js_fs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19339
19271
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_files_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3165
3134
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_files_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6875
6808
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3016
2973
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O1.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7769
7672
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2661
2616
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5530
5437
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O3.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2577
2535
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O3.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5376
5283
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_Os.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2577
2535
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_Os.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5376
5283
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_Oz.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2558
2519
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_Oz.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5343
5250
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_dylink.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6459
6428
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_dylink.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14303
14235
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1931
1888
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4162
4072
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2577
2535
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5376
5283
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2141
2099
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4596
4506
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2173
2135
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4647
4555
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2595
2563
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5496
5428
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3_grow.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2754
2712
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3_grow.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5818
5726
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2445
2403
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5206
5113
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3_standalone.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2411
2369
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3_standalone.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5136
5044
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2163
2122
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4647
4557
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2173
2135
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4647
4555
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2173
2135
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4647
4555
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_64.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1685
1640
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_64.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3541
3452
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6851
6854
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1796
1755
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O1.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4328
4232
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1627
1582
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3287
3198
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O3.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1591
1546
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O3.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3237
3148
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_Os.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1591
1546
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_Os.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3237
3148
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_Oz-ctors.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1583
1538
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_Oz-ctors.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3222
3133
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_Oz.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1591
1546
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_Oz.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3237
3148
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_pthreads.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4921
4892
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_pthreads.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13569
13501
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1591
1546
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3237
3148
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57813
57811
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size_no_asserts.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
31565
31480
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size_strict.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
56716
56714
2 changes: 1 addition & 1 deletion test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4347,7 +4347,7 @@ def test_small_js_flags(self):
print('size:', size)
# Note that this size includes test harness additions (for reporting the result, etc.).
if not self.is_wasm64() and not self.is_2gb():
self.assertLess(abs(size - 4800), 100)
self.assertLess(abs(size - 4675), 100)

# Tests that it is possible to initialize and render WebGL content in a
# pthread by using OffscreenCanvas.
Expand Down
18 changes: 10 additions & 8 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -8826,14 +8826,16 @@ def test_lto_wasm_exceptions(self):
self.emcc_args += ['-fwasm-exceptions', '-flto']
self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught')

def test_wasm_nope(self):
for opts in [[], ['-O2']]:
print(opts)
# check we show a good error message if there is no wasm support
create_file('pre.js', 'WebAssembly = undefined;\n')
self.run_process([EMCC, test_file('hello_world.c'), '--pre-js', 'pre.js'] + opts)
out = self.run_js('a.out.js', assert_returncode=NON_ZERO)
self.assertContained('no native wasm support detected', out)
@parameterized({
'': ([],),
'O2': (['-O2'],),
})
def test_missing_wasm(self, args):
# Check that in debug builds we show a good error message if there is no wasm support
create_file('pre.js', 'WebAssembly = undefined;\n')
self.run_process([EMCC, test_file('hello_world.c'), '--pre-js', 'pre.js'] + args)
out = self.run_js('a.out.js', assert_returncode=NON_ZERO)
self.assertContainedIf('no native wasm support detected', out, not args)

def test_exceptions_c_linker(self):
# Test that we don't try to create __cxa_find_matching_catch_xx function automatically
Expand Down

0 comments on commit 5f9ee69

Please sign in to comment.