Skip to content
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

Restore previous behaviour of not mangling EM_JS functions #18438

Merged
merged 1 commit into from
Dec 29, 2022
Merged
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
7 changes: 3 additions & 4 deletions emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,10 @@ def create_em_js(metadata):
args = args.split(',')
arg_names = [arg.split()[-1].replace("*", "") for arg in args if arg]
args = ','.join(arg_names)
mangled = asmjs_mangle(name)
func = f'function {mangled}({args}) {body}'
func = f'function {name}({args}) {body}'
if (settings.MAIN_MODULE or settings.ASYNCIFY == 2) and name in metadata.emJsFuncTypes:
sig = func_type_to_sig(metadata.emJsFuncTypes[name])
func = func + f'\n{mangled}.sig = \'{sig}\';'
func = func + f'\n{name}.sig = \'{sig}\';'
em_js_funcs.append(func)

return em_js_funcs
Expand Down Expand Up @@ -675,7 +674,7 @@ def create_sending(invoke_funcs, metadata):
send_items_map = {}

for name in metadata.emJsFuncs:
send_items_map[name] = asmjs_mangle(name)
send_items_map[name] = name
for name in invoke_funcs:
send_items_map[name] = name
for name in metadata.imports:
Expand Down
7 changes: 7 additions & 0 deletions test/core/test_em_js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ EM_JS(int, _prefixed, (void), {
return 1;
});

EM_JS(int, transitive, (void), {
// Verify that EM_JS functions can call other EM_JS functions by thier
// unmangled name.
return noarg_int();
});

int main() {
printf("BEGIN\n");
noarg();
Expand All @@ -118,6 +124,7 @@ int main() {
free(s2);

printf(" _prefixed: %d\n", _prefixed());
printf(" transitive: %d\n", transitive());

printf("END\n");
return 0;
Expand Down
2 changes: 2 additions & 0 deletions test/core/test_em_js.out
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ no args returning double
return_str returned: hello from js
return_utf8_str returned: こんにちは
_prefixed: 1
no args returning int
transitive: 12
END