Skip to content

Commit da84259

Browse files
authored
Avoid setting EXPORTED_FUNCTIONS with MAIN_MODULE=1 (#15257)
This setting is meaningless with MAIN_MODULE=1 or SIDE_MODULE=1. Hopefully this will be a warning soon: #10075 Also avoid using C++ in some tests that don't need it.
1 parent c62ac9b commit da84259

File tree

1 file changed

+20
-36
lines changed

1 file changed

+20
-36
lines changed

tests/test_core.py

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,8 +2722,7 @@ class Bar {
27222722

27232723
@needs_dylink
27242724
def test_dlfcn_qsort(self):
2725-
self.set_setting('EXPORTED_FUNCTIONS', ['_get_cmp'])
2726-
create_file('liblib.cpp', '''
2725+
create_file('liblib.c', '''
27272726
int lib_cmp(const void* left, const void* right) {
27282727
const int* a = (const int*) left;
27292728
const int* b = (const int*) right;
@@ -2734,14 +2733,13 @@ def test_dlfcn_qsort(self):
27342733
27352734
typedef int (*CMP_TYPE)(const void*, const void*);
27362735
2737-
extern "C" CMP_TYPE get_cmp() {
2736+
CMP_TYPE get_cmp() {
27382737
return lib_cmp;
27392738
}
27402739
''')
2741-
self.build_dlfcn_lib('liblib.cpp')
2740+
self.build_dlfcn_lib('liblib.c')
27422741

27432742
self.prep_dlfcn_main()
2744-
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc'])
27452743
src = '''
27462744
#include <stdio.h>
27472745
#include <stdlib.h>
@@ -2800,7 +2798,7 @@ def test_dlfcn_data_and_fptr(self):
28002798
if self.is_wasm():
28012799
self.banned_js_engines = [config.V8_ENGINE]
28022800

2803-
create_file('liblib.cpp', r'''
2801+
create_file('liblib.c', r'''
28042802
#include <stdio.h>
28052803
28062804
int theglobal = 42;
@@ -2820,14 +2818,13 @@ def test_dlfcn_data_and_fptr(self):
28202818
p_f();
28212819
}
28222820
2823-
extern "C" void (*func(int x, void(*fptr)()))() {
2821+
void (*func(int x, void(*fptr)()))() {
28242822
printf("In func: %d\n", x);
28252823
fptr();
28262824
return lib_fptr;
28272825
}
28282826
''')
2829-
self.set_setting('EXPORTED_FUNCTIONS', ['_func'])
2830-
self.build_dlfcn_lib('liblib.cpp')
2827+
self.build_dlfcn_lib('liblib.c')
28312828

28322829
self.prep_dlfcn_main()
28332830
src = r'''
@@ -2883,29 +2880,27 @@ def test_dlfcn_data_and_fptr(self):
28832880
return 0;
28842881
}
28852882
'''
2886-
self.set_setting('EXPORTED_FUNCTIONS', ['_main'])
28872883
self.do_run(src, '''\
28882884
In func: 13
28892885
First calling main_fptr from lib.
28902886
Second calling lib_fptr from main.
28912887
parent_func called from child
28922888
parent_func called from child
28932889
Var: 42
2894-
''')
2890+
''', force_c=True)
28952891

28962892
@needs_dylink
28972893
def test_dlfcn_varargs(self):
28982894
# this test is not actually valid - it fails natively. the child should fail
28992895
# to be loaded, not load and successfully see the parent print_ints func
29002896

2901-
create_file('liblib.cpp', r'''
2897+
create_file('liblib.c', r'''
29022898
void print_ints(int n, ...);
2903-
extern "C" void func() {
2899+
void func() {
29042900
print_ints(2, 13, 42);
29052901
}
29062902
''')
2907-
self.set_setting('EXPORTED_FUNCTIONS', ['_func'])
2908-
self.build_dlfcn_lib('liblib.cpp')
2903+
self.build_dlfcn_lib('liblib.c')
29092904

29102905
self.prep_dlfcn_main()
29112906
src = r'''
@@ -2937,8 +2932,7 @@ def test_dlfcn_varargs(self):
29372932
return 0;
29382933
}
29392934
'''
2940-
self.set_setting('EXPORTED_FUNCTIONS', ['_main'])
2941-
self.do_run(src, '100\n200\n13\n42\n')
2935+
self.do_run(src, '100\n200\n13\n42\n', force_c=True)
29422936

29432937
@needs_dylink
29442938
def test_dlfcn_alignment_and_zeroing(self):
@@ -3040,7 +3034,6 @@ def test_dlfcn_unique_sig(self):
30403034
return 13;
30413035
}
30423036
''')
3043-
self.set_setting('EXPORTED_FUNCTIONS', ['_myfunc'])
30443037
self.build_dlfcn_lib('liblib.c')
30453038

30463039
self.prep_dlfcn_main()
@@ -3067,7 +3060,6 @@ def test_dlfcn_unique_sig(self):
30673060
return 0;
30683061
}
30693062
''')
3070-
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc'])
30713063
self.do_runf('main.c', 'success')
30723064

30733065
@needs_dylink
@@ -3079,7 +3071,6 @@ def test_dlfcn_info(self):
30793071
return 13;
30803072
}
30813073
''')
3082-
self.set_setting('EXPORTED_FUNCTIONS', ['_myfunc'])
30833074
self.build_dlfcn_lib('liblib.c')
30843075

30853076
self.prep_dlfcn_main()
@@ -3121,7 +3112,6 @@ def test_dlfcn_info(self):
31213112
return 0;
31223113
}
31233114
''')
3124-
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc'])
31253115
self.do_runf('main.c', 'success')
31263116

31273117
@needs_dylink
@@ -3141,7 +3131,6 @@ def test_dlfcn_stacks(self):
31413131
return strlen(bigstack);
31423132
}
31433133
''')
3144-
self.set_setting('EXPORTED_FUNCTIONS', ['_myfunc'])
31453134
self.build_dlfcn_lib('liblib.c')
31463135

31473136
self.prep_dlfcn_main()
@@ -3176,7 +3165,6 @@ def test_dlfcn_stacks(self):
31763165
return 0;
31773166
}
31783167
''')
3179-
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc', '_strcmp'])
31803168
self.do_runf('main.c', 'success')
31813169

31823170
@needs_dylink
@@ -3212,7 +3200,6 @@ def test_dlfcn_funcs(self):
32123200
}
32133201
}
32143202
''')
3215-
self.set_setting('EXPORTED_FUNCTIONS', ['_callvoid', '_callint', '_getvoid', '_getint'])
32163203
self.build_dlfcn_lib('liblib.c')
32173204

32183205
self.prep_dlfcn_main()
@@ -3263,7 +3250,6 @@ def test_dlfcn_funcs(self):
32633250
return 0;
32643251
}
32653252
''')
3266-
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc'])
32673253
self.do_runf('main.c', '''go
32683254
void_main.
32693255
int_main 201
@@ -3288,11 +3274,9 @@ def test_dlfcn_mallocs(self):
32883274
void *mallocproxy(int n) { return malloc(n); }
32893275
void freeproxy(void *p) { free(p); }
32903276
''')
3291-
self.set_setting('EXPORTED_FUNCTIONS', ['_mallocproxy', '_freeproxy'])
32923277
self.build_dlfcn_lib('liblib.c')
32933278

32943279
self.prep_dlfcn_main()
3295-
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc', '_free'])
32963280
self.do_runf(test_file('dlmalloc_proxy.c'), '*294,153*')
32973281

32983282
@needs_dylink
@@ -3340,7 +3324,6 @@ def test_dlfcn_longjmp(self):
33403324
return 0;
33413325
}
33423326
''')
3343-
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc', '_free'])
33443327
self.do_runf('main.c', '''go!
33453328
pre 1
33463329
pre 2
@@ -3412,7 +3395,6 @@ def zzztest_dlfcn_exceptions(self):
34123395
return 0;
34133396
}
34143397
'''
3415-
self.set_setting('EXPORTED_FUNCTIONS', ['_main', '_malloc', '_free'])
34163398
self.do_run(src, '''go!
34173399
ok: 65
34183400
int 123
@@ -3430,8 +3412,9 @@ def indir(name):
34303412
create_file('a.cpp', r'''
34313413
#include <stdio.h>
34323414
3433-
static struct a {
3434-
a() {
3415+
static class A {
3416+
public:
3417+
A() {
34353418
puts("a: loaded");
34363419
}
34373420
} _;
@@ -3440,8 +3423,9 @@ def indir(name):
34403423
create_file('b.cpp', r'''
34413424
#include <stdio.h>
34423425
3443-
static struct b {
3444-
b() {
3426+
static class B {
3427+
public:
3428+
B() {
34453429
puts("b: loaded");
34463430
}
34473431
} _;
@@ -3490,12 +3474,12 @@ def indir(name):
34903474
def test_dlfcn_feature_in_lib(self):
34913475
self.emcc_args.append('-mnontrapping-fptoint')
34923476

3493-
create_file('liblib.cpp', r'''
3494-
extern "C" int magic(float x) {
3477+
create_file('liblib.c', r'''
3478+
int magic(float x) {
34953479
return __builtin_wasm_trunc_saturate_s_i32_f32(x);
34963480
}
34973481
''')
3498-
self.build_dlfcn_lib('liblib.cpp')
3482+
self.build_dlfcn_lib('liblib.c')
34993483

35003484
self.prep_dlfcn_main()
35013485
src = r'''

0 commit comments

Comments
 (0)