@@ -3004,7 +3004,8 @@ def test_proxyfs(self):
3004
3004
'--embed-file' , 'proxyfs_embed.txt' , '--pre-js' , 'proxyfs_pre.js' ,
3005
3005
'-s' , 'EXTRA_EXPORTED_RUNTIME_METHODS=["ccall", "cwrap"]' ,
3006
3006
'-s' , 'BINARYEN_ASYNC_COMPILATION=0' ,
3007
- '-s' , 'MAIN_MODULE=1' ])
3007
+ '-s' , 'MAIN_MODULE=1' ,
3008
+ '-s' , 'EXPORT_ALL=1' ])
3008
3009
# Following shutil.copyfile just prevent 'require' of node.js from caching js-object.
3009
3010
# See https://nodejs.org/api/modules.html
3010
3011
shutil .copyfile ('proxyfs_test.js' , 'proxyfs_test1.js' )
@@ -6230,7 +6231,7 @@ def test(main_args=[], library_args=[], expected='hello from main\nhello from li
6230
6231
#endif
6231
6232
}
6232
6233
''' )
6233
- run_process ([PYTHON , EMCC , 'library.c' , '-s' , 'SIDE_MODULE=1' , '-O2' , '-o' , library_file , '-s' , 'WASM=' + str (wasm )] + library_args )
6234
+ run_process ([PYTHON , EMCC , 'library.c' , '-s' , 'SIDE_MODULE=1' , '-O2' , '-o' , library_file , '-s' , 'WASM=' + str (wasm ), '-s' , 'EXPORT_ALL=1' ] + library_args )
6234
6235
open ('main.c' , 'w' ).write (r'''
6235
6236
#include <dlfcn.h>
6236
6237
#include <stdio.h>
@@ -6266,12 +6267,14 @@ def percent_diff(x, y):
6266
6267
full = test ()
6267
6268
# printf is not used in main, but libc was linked in, so it's there
6268
6269
printf = test (library_args = ['-DUSE_PRINTF' ])
6269
- # dce in main, and side happens to be ok since it uses puts as well
6270
- dce = test (main_args = ['-s' , 'MAIN_MODULE=2' ])
6270
+ # dce in main, and it fails since puts is not exported
6271
+ dce = test (main_args = ['-s' , 'MAIN_MODULE=2' ], expected = ('cannot' , 'undefined' ))
6272
+ # with exporting, it works
6273
+ dce = test (main_args = ['-s' , 'MAIN_MODULE=2' , '-s' , 'EXPORTED_FUNCTIONS=["_main", "_puts"]' ])
6271
6274
# printf is not used in main, and we dce, so we failz
6272
6275
dce_fail = test (main_args = ['-s' , 'MAIN_MODULE=2' ], library_args = ['-DUSE_PRINTF' ], expected = ('cannot' , 'undefined' ))
6273
6276
# exporting printf in main keeps it alive for the library
6274
- dce_save = test (main_args = ['-s' , 'MAIN_MODULE=2' , '-s' , 'EXPORTED_FUNCTIONS=["_main", "_printf"]' ], library_args = ['-DUSE_PRINTF' ])
6277
+ dce_save = test (main_args = ['-s' , 'MAIN_MODULE=2' , '-s' , 'EXPORTED_FUNCTIONS=["_main", "_printf", "_puts" ]' ], library_args = ['-DUSE_PRINTF' ])
6275
6278
6276
6279
assert percent_diff (full [0 ], printf [0 ]) < 4
6277
6280
assert percent_diff (dce [0 ], dce_fail [0 ]) < 4
@@ -6377,10 +6380,10 @@ def test_ld_library_path(self):
6377
6380
6378
6381
''' )
6379
6382
6380
- run_process ([PYTHON , EMCC , '-o' , 'libhello1.wasm' , 'hello1.c' , '-s' , 'SIDE_MODULE=1' ])
6381
- run_process ([PYTHON , EMCC , '-o' , 'libhello2.wasm' , 'hello2.c' , '-s' , 'SIDE_MODULE=1' ])
6382
- run_process ([PYTHON , EMCC , '-o' , 'libhello3.wasm' , 'hello3.c' , '-s' , 'SIDE_MODULE=1' ])
6383
- run_process ([PYTHON , EMCC , '-o' , 'libhello4.wasm' , 'hello4.c' , '-s' , 'SIDE_MODULE=1' ])
6383
+ run_process ([PYTHON , EMCC , '-o' , 'libhello1.wasm' , 'hello1.c' , '-s' , 'SIDE_MODULE=1' , '-s' , 'EXPORT_ALL=1' ])
6384
+ run_process ([PYTHON , EMCC , '-o' , 'libhello2.wasm' , 'hello2.c' , '-s' , 'SIDE_MODULE=1' , '-s' , 'EXPORT_ALL=1' ])
6385
+ run_process ([PYTHON , EMCC , '-o' , 'libhello3.wasm' , 'hello3.c' , '-s' , 'SIDE_MODULE=1' , '-s' , 'EXPORT_ALL=1' ])
6386
+ run_process ([PYTHON , EMCC , '-o' , 'libhello4.wasm' , 'hello4.c' , '-s' , 'SIDE_MODULE=1' , '-s' , 'EXPORT_ALL=1' ])
6384
6387
run_process ([PYTHON , EMCC , '-o' , 'main.js' , 'main.c' , '-s' , 'MAIN_MODULE=1' , '-s' , 'TOTAL_MEMORY=' + str (32 * 1024 * 1024 ),
6385
6388
'--embed-file' , 'libhello1.wasm@/lib/libhello1.wasm' ,
6386
6389
'--embed-file' , 'libhello2.wasm@/usr/lib/libhello2.wasm' ,
@@ -6453,8 +6456,8 @@ def test_dlopen_rtld_global(self):
6453
6456
}
6454
6457
''' )
6455
6458
6456
- run_process ([PYTHON , EMCC , '-o' , 'libhello1.js' , 'hello1.c' , '-s' , 'SIDE_MODULE=1' , '-s' , 'WASM=0' ])
6457
- run_process ([PYTHON , EMCC , '-o' , 'libhello2.js' , 'hello2.c' , '-s' , 'SIDE_MODULE=1' , '-s' , 'WASM=0' ])
6459
+ run_process ([PYTHON , EMCC , '-o' , 'libhello1.js' , 'hello1.c' , '-s' , 'SIDE_MODULE=1' , '-s' , 'WASM=0' , '-s' , 'EXPORT_ALL=1' ])
6460
+ run_process ([PYTHON , EMCC , '-o' , 'libhello2.js' , 'hello2.c' , '-s' , 'SIDE_MODULE=1' , '-s' , 'WASM=0' , '-s' , 'EXPORT_ALL=1' ])
6458
6461
run_process ([PYTHON , EMCC , '-o' , 'main.js' , 'main.c' , '-s' , 'MAIN_MODULE=1' , '-s' , 'WASM=0' ,
6459
6462
'--embed-file' , 'libhello1.js' ,
6460
6463
'--embed-file' , 'libhello2.js' ])
@@ -8245,7 +8248,7 @@ def test(filename, expectations):
8245
8248
0 , [], ['tempDoublePtr' , 'waka' ], 8 , 0 , 0 , 0 ), # noqa; totally empty!
8246
8249
# but we don't metadce with linkable code! other modules may want it
8247
8250
(['-O3' , '-s' , 'MAIN_MODULE=1' ],
8248
- 1489 , ['invoke_v' ], ['waka' ], 469663 , 149 , 1443 , None ), # noqa; don't compare the # of functions in a main module, which changes a lot
8251
+ 1489 , ['invoke_v' ], ['waka' ], 226057 , 30 , 75 , None ), # noqa; don't compare the # of functions in a main module, which changes a lot
8249
8252
]) # noqa
8250
8253
8251
8254
print ('test on a minimal pure computational thing' )
@@ -8286,9 +8289,9 @@ def test_legalize_js_ffi(self):
8286
8289
# test disabling of JS FFI legalization
8287
8290
wasm_dis = os .path .join (Building .get_binaryen_bin (), 'wasm-dis' )
8288
8291
for (args , js_ffi ) in [
8289
- (['-s' , 'LEGALIZE_JS_FFI=1' , '-s' , 'SIDE_MODULE=1' , '-O2' ], True ),
8290
- (['-s' , 'LEGALIZE_JS_FFI=0' , '-s' , 'SIDE_MODULE=1' , '-O2' ], False ),
8291
- (['-s' , 'LEGALIZE_JS_FFI=0' , '-s' , 'SIDE_MODULE=1' , '-O0' ], False ),
8292
+ (['-s' , 'LEGALIZE_JS_FFI=1' , '-s' , 'SIDE_MODULE=1' , '-O2' , '-s' , 'EXPORT_ALL=1' ], True ),
8293
+ (['-s' , 'LEGALIZE_JS_FFI=0' , '-s' , 'SIDE_MODULE=1' , '-O2' , '-s' , 'EXPORT_ALL=1' ], False ),
8294
+ (['-s' , 'LEGALIZE_JS_FFI=0' , '-s' , 'SIDE_MODULE=1' , '-O0' , '-s' , 'EXPORT_ALL=1' ], False ),
8292
8295
(['-s' , 'LEGALIZE_JS_FFI=0' , '-s' , 'WARN_ON_UNDEFINED_SYMBOLS=0' , '-O0' ], False ),
8293
8296
]:
8294
8297
if self .is_wasm_backend () and 'SIDE_MODULE=1' in args :
0 commit comments