Skip to content

Commit 5521e62

Browse files
committed
Warn if EXPORTED_FUNCTIONS is used with MAIN_MODULE=1/SIDE_MODULE=1
This doesn't make sense since these imply all functionm are to be exported.
1 parent b1907ce commit 5521e62

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

emcc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,9 @@ def default_setting(name, new_default):
16421642
settings.LINKABLE = 1
16431643
settings.EXPORT_ALL = 1
16441644

1645+
if settings.LINKABLE and settings.USER_EXPORTED_FUNCTIONS:
1646+
diagnostics.warning('unused-command-line-argument', 'EXPORTED_FUNCTIONS is not valid with LINKABLE set (normally due to SIDE_MODULE=1/MAIN_MODULE=1) since all functions are exported this mode. To export only a subset use SIDE_MODULE=2/MAIN_MODULE=2')
1647+
16451648
if settings.MAIN_MODULE:
16461649
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += [
16471650
'$getDylinkMetadata',

tests/test_core.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,7 +2720,6 @@ class Bar {
27202720

27212721
@needs_dylink
27222722
def test_dlfcn_qsort(self):
2723-
self.set_setting('EXPORTED_FUNCTIONS', ['_get_cmp'])
27242723
create_file('liblib.cpp', '''
27252724
int lib_cmp(const void* left, const void* right) {
27262725
const int* a = (const int*) left;
@@ -2739,7 +2738,6 @@ def test_dlfcn_qsort(self):
27392738
self.build_dlfcn_lib('liblib.cpp')
27402739

27412740
self.prep_dlfcn_main()
2742-
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc'])
27432741
src = '''
27442742
#include <stdio.h>
27452743
#include <stdlib.h>
@@ -2824,7 +2822,6 @@ def test_dlfcn_data_and_fptr(self):
28242822
return lib_fptr;
28252823
}
28262824
''')
2827-
self.set_setting('EXPORTED_FUNCTIONS', ['_func'])
28282825
self.build_dlfcn_lib('liblib.cpp')
28292826

28302827
self.prep_dlfcn_main()
@@ -2881,7 +2878,6 @@ def test_dlfcn_data_and_fptr(self):
28812878
return 0;
28822879
}
28832880
'''
2884-
self.set_setting('EXPORTED_FUNCTIONS', ['_main'])
28852881
self.do_run(src, '''\
28862882
In func: 13
28872883
First calling main_fptr from lib.
@@ -2902,7 +2898,6 @@ def test_dlfcn_varargs(self):
29022898
print_ints(2, 13, 42);
29032899
}
29042900
''')
2905-
self.set_setting('EXPORTED_FUNCTIONS', ['_func'])
29062901
self.build_dlfcn_lib('liblib.cpp')
29072902

29082903
self.prep_dlfcn_main()
@@ -2935,7 +2930,6 @@ def test_dlfcn_varargs(self):
29352930
return 0;
29362931
}
29372932
'''
2938-
self.set_setting('EXPORTED_FUNCTIONS', ['_main'])
29392933
self.do_run(src, '100\n200\n13\n42\n')
29402934

29412935
@needs_dylink
@@ -3038,7 +3032,6 @@ def test_dlfcn_unique_sig(self):
30383032
return 13;
30393033
}
30403034
''')
3041-
self.set_setting('EXPORTED_FUNCTIONS', ['_myfunc'])
30423035
self.build_dlfcn_lib('liblib.c')
30433036

30443037
self.prep_dlfcn_main()
@@ -3065,7 +3058,6 @@ def test_dlfcn_unique_sig(self):
30653058
return 0;
30663059
}
30673060
''')
3068-
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc'])
30693061
self.do_runf('main.c', 'success')
30703062

30713063
@needs_dylink
@@ -3077,7 +3069,6 @@ def test_dlfcn_info(self):
30773069
return 13;
30783070
}
30793071
''')
3080-
self.set_setting('EXPORTED_FUNCTIONS', ['_myfunc'])
30813072
self.build_dlfcn_lib('liblib.c')
30823073

30833074
self.prep_dlfcn_main()
@@ -3119,7 +3110,6 @@ def test_dlfcn_info(self):
31193110
return 0;
31203111
}
31213112
''')
3122-
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc'])
31233113
self.do_runf('main.c', 'success')
31243114

31253115
@needs_dylink
@@ -3139,7 +3129,6 @@ def test_dlfcn_stacks(self):
31393129
return strlen(bigstack);
31403130
}
31413131
''')
3142-
self.set_setting('EXPORTED_FUNCTIONS', ['_myfunc'])
31433132
self.build_dlfcn_lib('liblib.c')
31443133

31453134
self.prep_dlfcn_main()
@@ -3174,7 +3163,6 @@ def test_dlfcn_stacks(self):
31743163
return 0;
31753164
}
31763165
''')
3177-
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc', '_strcmp'])
31783166
self.do_runf('main.c', 'success')
31793167

31803168
@needs_dylink
@@ -3210,7 +3198,6 @@ def test_dlfcn_funcs(self):
32103198
}
32113199
}
32123200
''')
3213-
self.set_setting('EXPORTED_FUNCTIONS', ['_callvoid', '_callint', '_getvoid', '_getint'])
32143201
self.build_dlfcn_lib('liblib.c')
32153202

32163203
self.prep_dlfcn_main()
@@ -3261,7 +3248,6 @@ def test_dlfcn_funcs(self):
32613248
return 0;
32623249
}
32633250
''')
3264-
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc'])
32653251
self.do_runf('main.c', '''go
32663252
void_main.
32673253
int_main 201
@@ -3286,7 +3272,6 @@ def test_dlfcn_mallocs(self):
32863272
void *mallocproxy(int n) { return malloc(n); }
32873273
void freeproxy(void *p) { free(p); }
32883274
''')
3289-
self.set_setting('EXPORTED_FUNCTIONS', ['_mallocproxy', '_freeproxy'])
32903275
self.build_dlfcn_lib('liblib.c')
32913276

32923277
self.prep_dlfcn_main()
@@ -3338,7 +3323,6 @@ def test_dlfcn_longjmp(self):
33383323
return 0;
33393324
}
33403325
''')
3341-
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc', '_free'])
33423326
self.do_runf('main.c', '''go!
33433327
pre 1
33443328
pre 2
@@ -3410,7 +3394,6 @@ def zzztest_dlfcn_exceptions(self):
34103394
return 0;
34113395
}
34123396
'''
3413-
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc', '_free'])
34143397
self.do_run(src, '''go!
34153398
ok: 65
34163399
int 123

0 commit comments

Comments
 (0)