Skip to content

Commit 8779ae3

Browse files
committed
[esm-integration] Add a new core test mode and either fix or disable all test.
This is fairly larger change which can likely to split up before landing.
1 parent 5fd73d6 commit 8779ae3

10 files changed

+119
-22
lines changed

.circleci/config.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,21 @@ jobs:
659659
steps:
660660
- run-tests-linux:
661661
test_targets: "instance"
662+
test-esm-integration:
663+
# We don't use `bionic` here since its too old to run recent node versions:
664+
# `/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found`
665+
executor: linux-python
666+
steps:
667+
- prepare-for-tests
668+
# The linux-python image uses /home/circleci rather than /root and jsvu
669+
# hardcodes /root into its launcher scripts so we need to reinstall v8.
670+
- run: rm -rf $HOME/.jsvu
671+
- install-v8
672+
- install-node-canary
673+
- run-tests:
674+
title: "esm-integration"
675+
test_targets: "esm-integration"
676+
- upload-test-results
662677
test-wasm2js1:
663678
environment:
664679
EMTEST_SKIP_NODE_CANARY: "1"
@@ -667,7 +682,7 @@ jobs:
667682
- run-tests-linux:
668683
test_targets: "wasm2js1"
669684
test-wasm64:
670-
# We don't use `bionic` here since its tool old to run recent node versions:
685+
# We don't use `bionic` here since its too old to run recent node versions:
671686
# `/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found`
672687
executor: linux-python
673688
steps:
@@ -811,10 +826,6 @@ jobs:
811826
core0.test_pthread_join_and_asyncify
812827
core0.test_async_ccall_promise_jspi*
813828
core0.test_cubescript_jspi
814-
esm_integration.test_fs_js_api*
815-
esm_integration.test_inlinejs3
816-
esm_integration.test_embind_val_basics
817-
esm_integration.test_undefined_main
818829
"
819830
# Run some basic tests with the minimum version of node that we currently
820831
# support in the generated code.
@@ -1142,6 +1153,9 @@ workflows:
11421153
- test-modularize-instance:
11431154
requires:
11441155
- build-linux
1156+
- test-esm-integration:
1157+
requires:
1158+
- build-linux
11451159
- test-browser-chrome
11461160
- test-browser-chrome-2gb:
11471161
requires:

site/source/docs/compiling/Modularized-Output.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ fix in future releses. Current limitations include:
138138
* The output of file_packager is not compatible so :ref:`emcc-preload-file` and
139139
:ref:`emcc-embed-file` do not work.
140140

141+
141142
Source Phase Imports (experimental)
142143
===================================
143144

@@ -167,5 +168,14 @@ This setting implicitly enables :ref:`export_es6` and sets :ref:`MODULARIZE` to
167168
``instance``. Because of this all the same limitations mentioned above for
168169
``-sMODULARIZE=intance`` apply.
169170

171+
Some additional limitations are:
172+
173+
- ``-pthread`` / :ref:`wasm_workers` are not yet supported.
174+
175+
- Setting :ref:`wasm` to ``0`` is not supported.
176+
177+
- Setting :ref:`wasm_async_compilation` to ``0`` is not supported.
178+
179+
170180
.. _Source phase imports: https://github.com/tc39/proposal-source-phase-imports
171181
.. _Wasm ESM integration: https://github.com/WebAssembly/esm-integration

test/common.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def metafunc(self, with_minimal_runtime, *args, **kwargs):
522522
print('parameterize:minimal_runtime=%s' % with_minimal_runtime)
523523
assert self.get_setting('MINIMAL_RUNTIME') is None
524524
if with_minimal_runtime:
525-
if self.get_setting('MODULARIZE') == 'instance':
525+
if self.get_setting('MODULARIZE') == 'instance' or self.get_setting('WASM_ESM_INTEGRATION'):
526526
self.skipTest('MODULARIZE=instance is not compatible with MINIMAL_RUNTIME')
527527
self.set_setting('MINIMAL_RUNTIME', 1)
528528
# This extra helper code is needed to cleanly handle calls to exit() which throw
@@ -604,6 +604,7 @@ def can_do_standalone(self, impure=False):
604604
return self.is_wasm() and \
605605
self.get_setting('STACK_OVERFLOW_CHECK', 0) < 2 and \
606606
not self.get_setting('MINIMAL_RUNTIME') and \
607+
not self.get_setting('WASM_ESM_INTEGRATION') and \
607608
not self.get_setting('SAFE_HEAP') and \
608609
not any(a.startswith('-fsanitize=') for a in self.emcc_args)
609610

@@ -1138,6 +1139,8 @@ def require_wasm2js(self):
11381139
self.skipTest('wasm2js is not compatible with MEMORY64')
11391140
if self.is_2gb() or self.is_4gb():
11401141
self.skipTest('wasm2js does not support over 2gb of memory')
1142+
if self.get_setting('WASM_ESM_INTEGRATION'):
1143+
self.skipTest('wasm2js is not compatible with WASM_ESM_INTEGRATION')
11411144

11421145
def setup_nodefs_test(self):
11431146
self.require_node()
@@ -1160,6 +1163,8 @@ def setup_node_pthreads(self):
11601163
self.emcc_args += ['-Wno-pthreads-mem-growth', '-pthread']
11611164
if self.get_setting('MINIMAL_RUNTIME'):
11621165
self.skipTest('node pthreads not yet supported with MINIMAL_RUNTIME')
1166+
if self.get_setting('WASM_ESM_INTEGRATION'):
1167+
self.skipTest('pthreads not yet supported with WASM_ESM_INTEGRATION')
11631168
nodejs = self.get_nodejs()
11641169
self.js_engines = [nodejs]
11651170
self.node_args += shared.node_pthread_flags(nodejs)

test/core/test_demangle_stacks.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <emscripten.h>
1010

11+
EM_JS_DEPS(deps, "$jsStackTrace");
12+
1113
namespace NameSpace {
1214
class Class {
1315
public:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
53704
1+
53737
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
26959
1+
26992
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
51754
1+
51787

test/test_core.py

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ def decorated(self, *args, **kwargs):
6767
return decorator
6868

6969

70+
def no_esm_integration(note):
71+
assert not callable(note)
72+
73+
def decorator(f):
74+
assert callable(f)
75+
76+
@wraps(f)
77+
def decorated(self, *args, **kwargs):
78+
if self.get_setting('WASM_ESM_INTEGRATION'):
79+
self.skipTest(note)
80+
f(self, *args, **kwargs)
81+
return decorated
82+
83+
return decorator
84+
85+
7086
def wasm_simd(f):
7187
assert callable(f)
7288

@@ -189,6 +205,8 @@ def with_asyncify_and_jspi(f):
189205

190206
@wraps(f)
191207
def metafunc(self, jspi, *args, **kwargs):
208+
if self.get_setting('WASM_ESM_INTEGRATION'):
209+
self.skipTest('WASM_ESM_INTEGRATION is not compatible with ASYNCIFY')
192210
if jspi:
193211
self.set_setting('ASYNCIFY', 2)
194212
self.require_jspi()
@@ -208,6 +226,8 @@ def also_with_asyncify_and_jspi(f):
208226

209227
@wraps(f)
210228
def metafunc(self, asyncify, *args, **kwargs):
229+
if asyncify and self.get_setting('WASM_ESM_INTEGRATION'):
230+
self.skipTest('WASM_ESM_INTEGRATION is not compatible with ASYNCIFY')
211231
if asyncify == 2:
212232
self.set_setting('ASYNCIFY', 2)
213233
self.require_jspi()
@@ -424,6 +444,7 @@ def get_bullet_library(self, use_cmake):
424444
def test_hello_world(self):
425445
self.do_core_test('test_hello_world.c')
426446

447+
@no_esm_integration('WASM_ASYNC_COMPILATION=0')
427448
def test_wasm_synchronous_compilation(self):
428449
if self.get_setting('MODULARIZE') != 'instance':
429450
self.set_setting('STRICT_JS')
@@ -914,6 +935,7 @@ def test_longjmp(self):
914935
self.do_core_test('test_longjmp.c')
915936

916937
@no_sanitize('sanitizers do not support WASM_WORKERS')
938+
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with WASM_WORKERS')
917939
def test_longjmp_wasm_workers(self):
918940
self.do_core_test('test_longjmp.c', emcc_args=['-sWASM_WORKERS'])
919941

@@ -1995,7 +2017,11 @@ def test_em_js(self, args, force_c):
19952017
self.setup_node_pthreads()
19962018

19972019
self.do_core_test('test_em_js.cpp', force_c=force_c)
1998-
self.assertContained('no args returning int', read_file(self.output_name('test_em_js')))
2020+
if self.get_setting('WASM_ESM_INTEGRATION'):
2021+
js_out = 'test_em_js.support.mjs'
2022+
else:
2023+
js_out = self.output_name('test_em_js')
2024+
self.assertContained('no args returning int', read_file(js_out))
19992025

20002026
@no_wasm2js('test depends on WASM_BIGINT which is not compatible with wasm2js')
20012027
def test_em_js_i64(self):
@@ -2173,6 +2199,7 @@ def test_nothrow_new(self, args):
21732199
@no_lsan('LSan alters the memory size')
21742200
@no_4gb('depends on memory size')
21752201
@no_2gb('depends on memory size')
2202+
@no_esm_integration('external wasmMemory')
21762203
def test_module_wasm_memory(self):
21772204
self.emcc_args += ['--pre-js', test_file('core/test_module_wasm_memory.js')]
21782205
self.set_setting('IMPORTED_MEMORY')
@@ -6982,7 +7009,6 @@ def test_EXPORTED_RUNTIME_METHODS(self):
69827009

69837010
@also_with_minimal_runtime
69847011
@no_modularize_instance('uses dynCallLegacy')
6985-
@no_wasm64('not compatible with MEMORY64')
69867012
def test_dyncall_specific(self):
69877013
if self.get_setting('WASM_BIGINT') != 0 and not self.is_wasm2js():
69887014
# define DYNCALLS because this test does test calling them directly, and
@@ -7446,6 +7472,7 @@ def test_embind_negative_constants(self):
74467472
self.do_run_in_out_file_test('embind/test_negative_constants.cpp', emcc_args=['-lembind'])
74477473

74487474
@also_with_wasm_bigint
7475+
@no_esm_integration('embind is not compatible with WASM_ESM_INTEGRATION')
74497476
def test_embind_unsigned(self):
74507477
self.do_run_in_out_file_test('embind/test_unsigned.cpp', emcc_args=['-lembind'])
74517478

@@ -7621,6 +7648,7 @@ def test_embind_no_rtti_followed_by_rtti(self):
76217648
self.do_run(src, '418\ndotest returned: 42\n')
76227649

76237650
@no_sanitize('sanitizers do not support WASM_WORKERS')
7651+
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with WASM_WORKERS')
76247652
def test_embind_wasm_workers(self):
76257653
self.do_run_in_out_file_test('embind/test_embind_wasm_workers.cpp', emcc_args=['-lembind', '-sWASM_WORKERS'])
76267654

@@ -7796,6 +7824,7 @@ def test_embind_dylink_visibility_hidden(self):
77967824
self.do_runf('main.cpp', 'done\n', emcc_args=['--bind'])
77977825

77987826
@no_wasm2js('TODO: source maps in wasm2js')
7827+
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with dwarf output')
77997828
def test_dwarf(self):
78007829
self.emcc_args.append('-g')
78017830

@@ -8238,6 +8267,7 @@ def test_asyncify_lists(self, args, should_pass, response=None):
82388267
binary = read_binary(filename)
82398268
self.assertFalse(b'main' in binary)
82408269

8270+
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with ASYNCIFY')
82418271
@parameterized({
82428272
'normal': ([], True),
82438273
'ignoreindirect': (['-sASYNCIFY_IGNORE_INDIRECT'], False),
@@ -8629,7 +8659,10 @@ def test_environment(self):
86298659

86308660
def test(assert_returncode=0):
86318661
self.do_core_test('test_hello_world.c', assert_returncode=assert_returncode)
8632-
js = read_file(self.output_name('test_hello_world'))
8662+
if self.get_setting('WASM_ESM_INTEGRATION'):
8663+
js = read_file(self.output_name('test_hello_world.support'))
8664+
else:
8665+
js = read_file(self.output_name('test_hello_world'))
86338666
assert ('require(' in js) == ('node' in self.get_setting('ENVIRONMENT')), 'we should have require() calls only if node js specified'
86348667

86358668
for engine in config.JS_ENGINES:
@@ -8754,11 +8787,13 @@ def test_minimal_runtime_global_initializer(self):
87548787
self.do_runf('test_global_initializer.cpp', 't1 > t0: 1')
87558788

87568789
@no_wasm2js('wasm2js does not support PROXY_TO_PTHREAD (custom section support)')
8790+
@no_esm_integration('USE_OFFSET_CONVERTER')
87578791
def test_return_address(self):
87588792
self.set_setting('USE_OFFSET_CONVERTER')
87598793
self.do_runf('core/test_return_address.c', 'passed')
87608794

87618795
@no_wasm2js('TODO: sanitizers in wasm2js')
8796+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
87628797
@no_asan('-fsanitize-minimal-runtime cannot be used with ASan')
87638798
@no_lsan('-fsanitize-minimal-runtime cannot be used with LSan')
87648799
def test_ubsan_minimal_too_many_errors(self):
@@ -8768,6 +8803,7 @@ def test_ubsan_minimal_too_many_errors(self):
87688803
regex=True)
87698804

87708805
@no_wasm2js('TODO: sanitizers in wasm2js')
8806+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
87718807
@no_asan('-fsanitize-minimal-runtime cannot be used with ASan')
87728808
@no_lsan('-fsanitize-minimal-runtime cannot be used with LSan')
87738809
def test_ubsan_minimal_errors_same_place(self):
@@ -8782,6 +8818,7 @@ def test_ubsan_minimal_errors_same_place(self):
87828818
'fsanitize_overflow': (['-fsanitize=signed-integer-overflow'],),
87838819
})
87848820
@no_wasm2js('TODO: sanitizers in wasm2js')
8821+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
87858822
def test_ubsan_full_overflow(self, args):
87868823
self.emcc_args += args
87878824
self.do_runf(
@@ -8797,6 +8834,7 @@ def test_ubsan_full_overflow(self, args):
87978834
'fsanitize_return': (['-fsanitize=return'],),
87988835
})
87998836
@no_wasm2js('TODO: sanitizers in wasm2js')
8837+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
88008838
def test_ubsan_full_no_return(self, args):
88018839
self.emcc_args += ['-Wno-return-type'] + args
88028840
self.do_runf('core/test_ubsan_full_no_return.cpp',
@@ -8808,6 +8846,7 @@ def test_ubsan_full_no_return(self, args):
88088846
'fsanitize_shift': (['-fsanitize=shift'],),
88098847
})
88108848
@no_wasm2js('TODO: sanitizers in wasm2js')
8849+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
88118850
def test_ubsan_full_left_shift(self, args):
88128851
self.emcc_args += args
88138852
self.do_runf(
@@ -8824,6 +8863,7 @@ def test_ubsan_full_left_shift(self, args):
88248863
'dylink': (['-fsanitize=null', '-sMAIN_MODULE=2'],),
88258864
})
88268865
@no_wasm2js('TODO: sanitizers in wasm2js')
8866+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
88278867
def test_ubsan_full_null_ref(self, args):
88288868
if '-sMAIN_MODULE=2' in args:
88298869
self.check_dylink()
@@ -8840,6 +8880,7 @@ def test_ubsan_full_null_ref(self, args):
88408880
])
88418881

88428882
@no_wasm2js('TODO: sanitizers in wasm2js')
8883+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
88438884
def test_sanitize_vptr(self):
88448885
self.do_runf(
88458886
'core/test_sanitize_vptr.cpp',
@@ -8862,6 +8903,7 @@ def test_sanitize_vptr(self):
88628903
]),
88638904
})
88648905
@no_wasm2js('TODO: sanitizers in wasm2js')
8906+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
88658907
def test_ubsan_full_stack_trace(self, g_flag, expected_output):
88668908
if g_flag == '-gsource-map':
88678909
if self.is_wasm2js():
@@ -8876,6 +8918,7 @@ def test_ubsan_full_stack_trace(self, g_flag, expected_output):
88768918
assert_all=True, expected_output=expected_output)
88778919

88788920
@no_wasm2js('TODO: sanitizers in wasm2js')
8921+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
88798922
def test_ubsan_typeinfo_eq(self):
88808923
# https://github.com/emscripten-core/emscripten/issues/13330
88818924
src = r'''
@@ -8895,6 +8938,7 @@ def test_template_class_deduction(self):
88958938
self.do_core_test('test_template_class_deduction.cpp')
88968939

88978940
@no_wasm2js('TODO: ASAN in wasm2js')
8941+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
88988942
@no_safe_heap('asan does not work with SAFE_HEAP')
88998943
@no_wasm64('TODO: ASAN in memory64')
89008944
@no_2gb('asan doesnt support GLOBAL_BASE')
@@ -8915,6 +8959,7 @@ def test_asan_no_error(self, name):
89158959
@no_safe_heap('asan does not work with SAFE_HEAP')
89168960
@no_wasm64('TODO: ASAN in memory64')
89178961
@no_2gb('asan doesnt support GLOBAL_BASE')
8962+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
89188963
@parameterized({
89198964
'use_after_free_c': ('test_asan_use_after_free.c', [
89208965
'AddressSanitizer: heap-use-after-free on address',
@@ -8988,6 +9033,7 @@ def test_asan(self, name, expected_output, cflags=None):
89889033
@no_wasm2js('TODO: ASAN in wasm2js')
89899034
@no_wasm64('TODO: ASAN in memory64')
89909035
@no_2gb('asan doesnt support GLOBAL_BASE')
9036+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
89919037
def test_asan_js_stack_op(self):
89929038
self.emcc_args.append('-fsanitize=address')
89939039
self.set_setting('ALLOW_MEMORY_GROWTH')
@@ -8999,6 +9045,7 @@ def test_asan_js_stack_op(self):
89999045
@no_wasm2js('TODO: ASAN in wasm2js')
90009046
@no_wasm64('TODO: ASAN in memory64')
90019047
@no_2gb('asan doesnt support GLOBAL_BASE')
9048+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
90029049
def test_asan_api(self):
90039050
self.emcc_args.append('-fsanitize=address')
90049051
self.set_setting('INITIAL_MEMORY', '300mb')
@@ -9008,6 +9055,7 @@ def test_asan_api(self):
90089055
@no_wasm2js('TODO: ASAN in wasm2js')
90099056
@no_wasm64('TODO: ASAN in memory64')
90109057
@no_2gb('asan doesnt support GLOBAL_BASE')
9058+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
90119059
def test_asan_modularized_with_closure(self):
90129060
# the bug is that createModule() returns undefined, instead of the
90139061
# proper Promise object.
@@ -9022,6 +9070,7 @@ def test_asan_modularized_with_closure(self):
90229070

90239071
@no_asan('SAFE_HEAP cannot be used with ASan')
90249072
@no_2gb('asan doesnt support GLOBAL_BASE')
9073+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
90259074
def test_safe_heap_user_js(self):
90269075
self.set_setting('SAFE_HEAP')
90279076
self.do_runf('core/test_safe_heap_user_js.c',
@@ -9413,6 +9462,7 @@ def test_Module_dynamicLibraries(self, args):
94139462

94149463
# Tests the emscripten_get_exported_function() API.
94159464
@also_with_minimal_runtime
9465+
@no_esm_integration('depends on wasmExports')
94169466
def test_get_exported_function(self):
94179467
self.set_setting('ALLOW_TABLE_GROWTH')
94189468
self.emcc_args += ['-lexports.js']

0 commit comments

Comments
 (0)