Skip to content

Commit b68d594

Browse files
committed
Fix argv passing in PROXY_TO_PTHREAD mode
This was broken in #17153 but we didn't have any tests. Fixes: #17338
1 parent e91ea21 commit b68d594

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

emcc.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,9 +1747,7 @@ def phase_linker_setup(options, state, newargs, user_settings):
17471747
settings.EXPECT_MAIN = 0
17481748
else:
17491749
assert not settings.EXPORTED_FUNCTIONS
1750-
# With PROXY_TO_PTHREAD we don't export `main` at all but instead `_emscripten_proxy_main`.
1751-
if not settings.PROXY_TO_PTHREAD:
1752-
settings.EXPORTED_FUNCTIONS = ['_main']
1750+
settings.EXPORTED_FUNCTIONS = ['_main']
17531751

17541752
if settings.STANDALONE_WASM:
17551753
# In STANDALONE_WASM mode we either build a command or a reactor.

tests/pthread/test_pthread_argv.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdio.h>
2+
3+
int main(int argc, char* argv[]) {
4+
printf("%d\n", argc);
5+
// Skip arg 0 because it will be an absolute path that varies between
6+
// machines.
7+
for (int i = 1; i < argc; i++) {
8+
printf("%d: %s\n", i, argv[i]);
9+
}
10+
return 0;
11+
}

tests/pthread/test_pthread_argv.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
3
2+
1: hello
3+
2: world

tests/test_core.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2833,6 +2833,12 @@ def test_pthread_stdout_after_main(self):
28332833
# streams were locked when the main thread returned.
28342834
self.do_runf(test_file('pthread/test_pthread_stdout_after_main.c'))
28352835

2836+
@node_pthreads
2837+
def test_pthread_argv(self):
2838+
self.set_setting('PROXY_TO_PTHREAD')
2839+
self.set_setting('EXIT_RUNTIME')
2840+
self.do_run_in_out_file_test('pthread/test_pthread_argv.cpp', args=['hello', 'world'])
2841+
28362842
def test_tcgetattr(self):
28372843
self.do_runf(test_file('termios/test_tcgetattr.c'), 'success')
28382844

0 commit comments

Comments
 (0)