Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
gl84 committed Aug 30, 2022
1 parent 704218f commit e3b9915
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2392,7 +2392,7 @@ def check_memory_setting(setting):
settings.LINKABLE or
settings.INCLUDE_FULL_LIBRARY or
not settings.DISABLE_EXCEPTION_CATCHING or
(settings.MAIN_MODULE == 1 and (settings.DYNCALLS or not settings.WASM_BIGINT))
(settings.MAIN_MODULE and (settings.DYNCALLS or not settings.WASM_BIGINT))
):
settings.REQUIRED_EXPORTS += ["getTempRet0", "setTempRet0"]

Expand Down
6 changes: 2 additions & 4 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -3194,16 +3194,14 @@ mergeInto(LibraryManager.library, {
},
#if DYNCALLS || !WASM_BIGINT
#if MAIN_MODULE == 1
#if MAIN_MODULE
$dynCallLegacy__deps: ['$createDyncallWrapper'],
#endif
$dynCallLegacy: function(sig, ptr, args) {
#if ASSERTIONS
#if MINIMAL_RUNTIME
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!');
assert(sig in dynCalls, 'bad function pointer type - sig is not in dynCalls: \'' + sig + '\'');
#else
assert(('dynCall_' + sig) in Module, 'bad function pointer type - dynCall function not found for sig \'' + sig + '\'');
#endif
if (args && args.length) {
// j (64-bit integer) must be passed in as two numbers [low 32, high 32].
Expand All @@ -3215,7 +3213,7 @@ mergeInto(LibraryManager.library, {
#if MINIMAL_RUNTIME
var f = dynCalls[sig];
#else
#if MAIN_MODULE == 1
#if MAIN_MODULE
if (!('dynCall_' + sig in Module)) {
Module['dynCall_' + sig] = createDyncallWrapper(sig);
}
Expand Down
3 changes: 2 additions & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -12457,7 +12457,8 @@ def test_warn_once(self):
def test_dyncallwrapper(self):
self.set_setting('MAIN_MODULE', 1)
expected = "2 7\ni: 2 j: 8589934599 f: 3.120000 d: 77.120000"
self.do_runf(test_file('test_runtime_dyncall_wrapper.c'), expected)
self.do_runf(test_file('test_runtime_dyncall_wrapper.c'), expected, emcc_args=['-sMAIN_MODULE=1'])
self.do_runf(test_file('test_runtime_dyncall_wrapper.c'), expected, emcc_args=['-sMAIN_MODULE=2'])

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

0 comments on commit e3b9915

Please sign in to comment.