Skip to content

Commit e3b9915

Browse files
committed
Follow up on PR emscripten-core#17328. - Create the wasm adaptor also for MAIN_MODULE == 2 - Remove obsolete assert (triggers for all cases were we create the wrapper)
1 parent 704218f commit e3b9915

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

emcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2392,7 +2392,7 @@ def check_memory_setting(setting):
23922392
settings.LINKABLE or
23932393
settings.INCLUDE_FULL_LIBRARY or
23942394
not settings.DISABLE_EXCEPTION_CATCHING or
2395-
(settings.MAIN_MODULE == 1 and (settings.DYNCALLS or not settings.WASM_BIGINT))
2395+
(settings.MAIN_MODULE and (settings.DYNCALLS or not settings.WASM_BIGINT))
23962396
):
23972397
settings.REQUIRED_EXPORTS += ["getTempRet0", "setTempRet0"]
23982398

src/library.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,16 +3194,14 @@ mergeInto(LibraryManager.library, {
31943194
},
31953195

31963196
#if DYNCALLS || !WASM_BIGINT
3197-
#if MAIN_MODULE == 1
3197+
#if MAIN_MODULE
31983198
$dynCallLegacy__deps: ['$createDyncallWrapper'],
31993199
#endif
32003200
$dynCallLegacy: function(sig, ptr, args) {
32013201
#if ASSERTIONS
32023202
#if MINIMAL_RUNTIME
32033203
assert(typeof dynCalls != 'undefined', 'Global dynCalls dictionary was not generated in the build! Pass -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$dynCall linker flag to include it!');
32043204
assert(sig in dynCalls, 'bad function pointer type - sig is not in dynCalls: \'' + sig + '\'');
3205-
#else
3206-
assert(('dynCall_' + sig) in Module, 'bad function pointer type - dynCall function not found for sig \'' + sig + '\'');
32073205
#endif
32083206
if (args && args.length) {
32093207
// j (64-bit integer) must be passed in as two numbers [low 32, high 32].
@@ -3215,7 +3213,7 @@ mergeInto(LibraryManager.library, {
32153213
#if MINIMAL_RUNTIME
32163214
var f = dynCalls[sig];
32173215
#else
3218-
#if MAIN_MODULE == 1
3216+
#if MAIN_MODULE
32193217
if (!('dynCall_' + sig in Module)) {
32203218
Module['dynCall_' + sig] = createDyncallWrapper(sig);
32213219
}

test/test_other.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12457,7 +12457,8 @@ def test_warn_once(self):
1245712457
def test_dyncallwrapper(self):
1245812458
self.set_setting('MAIN_MODULE', 1)
1245912459
expected = "2 7\ni: 2 j: 8589934599 f: 3.120000 d: 77.120000"
12460-
self.do_runf(test_file('test_runtime_dyncall_wrapper.c'), expected)
12460+
self.do_runf(test_file('test_runtime_dyncall_wrapper.c'), expected, emcc_args=['-sMAIN_MODULE=1'])
12461+
self.do_runf(test_file('test_runtime_dyncall_wrapper.c'), expected, emcc_args=['-sMAIN_MODULE=2'])
1246112462

1246212463
def test_compile_with_cache_lock(self):
1246312464
# Verify that, after warming the cache, running emcc does not require the cache lock.

0 commit comments

Comments
 (0)