Skip to content

Add dynCall_sig adaptor for MAIN_MODULE == 2 #17759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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