Skip to content

Commit 0c10ba8

Browse files
authored
Automatically asyncify a main with arguments. (#18252)
1 parent 3a64fd4 commit 0c10ba8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

emcc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@
108108
]
109109

110110
DEFAULT_ASYNCIFY_EXPORTS = [
111-
'main'
111+
'main',
112+
'__main_argc_argv'
112113
]
113114

114115
# Target options

test/test_core.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8036,6 +8036,21 @@ def test_setlocale(self):
80368036
def test_vswprintf_utf8(self):
80378037
self.do_run_in_out_file_test('vswprintf_utf8.c')
80388038

8039+
# Test that a main with arguments is automatically asyncified.
8040+
@no_wasm64('TODO: asyncify for wasm64')
8041+
@with_asyncify_and_stack_switching
8042+
def test_async_main(self):
8043+
create_file('main.c', r'''
8044+
#include <stdio.h>
8045+
#include <emscripten.h>
8046+
int main(int argc, char **argv) {
8047+
emscripten_sleep(1);
8048+
printf("argc=%d argv=%s\n", argc, argv[1]);
8049+
}
8050+
''')
8051+
8052+
self.do_runf('main.c', 'argc=2 argv=hello', args=['hello'])
8053+
80398054
@no_wasm64('TODO: asyncify for wasm64')
80408055
@with_asyncify_and_stack_switching
80418056
def test_async_hello(self):

0 commit comments

Comments
 (0)