File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -130,7 +130,9 @@ def update_settings_glue(metadata, DEBUG):
130
130
if shared .Settings .INITIAL_TABLE == - 1 :
131
131
shared .Settings .INITIAL_TABLE = metadata ['tableSize' ] + 1
132
132
133
- shared .Settings .MAIN_READS_PARAMS = metadata ['mainReadsParams' ]
133
+ # When using dynamic linking the main function might be in a side module.
134
+ # To be safe assume they do take input parametes.
135
+ shared .Settings .MAIN_READS_PARAMS = metadata ['mainReadsParams' ] or shared .Settings .MAIN_MODULE
134
136
135
137
# Store exports for Closure compiler to be able to track these as globals in
136
138
# -s DECLARE_ASM_MODULE_EXPORTS=0 builds.
Original file line number Diff line number Diff line change @@ -4531,6 +4531,30 @@ class Bar : public Foo {
4531
4531
header = header ,
4532
4532
expected = 'success' )
4533
4533
4534
+ @needs_dlfcn
4535
+ def test_dylink_argv_argc (self ):
4536
+ # Verify that argc and argv can be sent to main when main is in a side module
4537
+
4538
+ self .emcc_args += ['--extern-pre-js' , 'pre.js' ]
4539
+
4540
+ create_test_file ('pre.js' , '''
4541
+ var Module = { arguments: ['hello', 'world!'] }
4542
+ ''' )
4543
+
4544
+ self .dylink_test (
4545
+ '' , # main module is empty.
4546
+ r'''
4547
+ #include <stdio.h>
4548
+ int main(int argc, char const *argv[]) {
4549
+ printf("%d ", argc);
4550
+ for (int i=1; i<argc; i++) printf("%s ", argv[i]);
4551
+ printf("\n");
4552
+ return 0;
4553
+ }
4554
+ ''' ,
4555
+ expected = '3 hello world!' ,
4556
+ need_reverse = False )
4557
+
4534
4558
def test_random (self ):
4535
4559
src = r'''#include <stdlib.h>
4536
4560
#include <stdio.h>
You can’t perform that action at this time.
0 commit comments