Skip to content

Commit 903114b

Browse files
committed
Do not automatically set EXPORT_ALL for MAIN_MODULES. This means that if your side modules want to call something from the main module, the main module must either export it (normally, on EXPORTED_FUNCTIONS), or you can manually enable EXPORT_ALL yourself. fixes #5586
1 parent f00d4ae commit 903114b

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

ChangeLog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ full changeset diff at the end of each section.
1515

1616
Current Trunk
1717
-------------
18+
- Breaking change: Do not automatically set EXPORT_ALL for MAIN_MODULES. This
19+
means that if your side modules want to call something from the main module,
20+
the main module must either export it (normally, on EXPORTED_FUNCTIONS), or
21+
you can manually enable EXPORT_ALL yourself. See #7312.
22+
23+
v1.38.13: 10/10/2018
24+
--------------------
1825
- Support `-s NO_X=1` as an alias for `-s X=0` and vice versa, which
1926
simplifies current settings with `NO_`-prefixed names. See #7151.
2027
- Various `EMULATED_FUNCTION_POINTER` improvements. See #7108, #7128.

emcc.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,8 +1162,6 @@ def check(input_file):
11621162
if shared.Settings.EMULATED_FUNCTION_POINTERS == 0:
11631163
shared.Settings.EMULATED_FUNCTION_POINTERS = 2 # by default, use optimized function pointer emulation
11641164
shared.Settings.ERROR_ON_UNDEFINED_SYMBOLS = shared.Settings.WARN_ON_UNDEFINED_SYMBOLS = 0
1165-
if not shared.Settings.SIDE_MODULE:
1166-
shared.Settings.EXPORT_ALL = 1
11671165

11681166
if shared.Settings.EMTERPRETIFY:
11691167
shared.Settings.FINALIZE_ASM_JS = 0

tests/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3796,7 +3796,7 @@ def test_dylink_global_var_jslib(self):
37963796
void call_side() {
37973797
printf("side: jslib_x is %d.\n", jslib_x);
37983798
}
3799-
''', expected=['main: jslib_x is 148.\nside: jslib_x is 148.\n'], main_emcc_args=['--js-library', 'lib.js'])
3799+
''', expected=['main: jslib_x is 148.\nside: jslib_x is 148.\n'], main_emcc_args=['--js-library', 'lib.js', '-s', 'EXPORTED_FUNCTIONS=["_main", "_jslib_x"]'])
38003800

38013801
@needs_dlfcn
38023802
def test_dylink_many_postSets(self):

tests/test_other.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2990,7 +2990,8 @@ def test_proxyfs(self):
29902990
'--embed-file', 'proxyfs_embed.txt', '--pre-js', 'proxyfs_pre.js',
29912991
'-s', 'EXTRA_EXPORTED_RUNTIME_METHODS=["ccall", "cwrap"]',
29922992
'-s', 'BINARYEN_ASYNC_COMPILATION=0',
2993-
'-s', 'MAIN_MODULE=1'])
2993+
'-s', 'MAIN_MODULE=1',
2994+
'-s', 'EXPORT_ALL=1'])
29942995
# Following shutil.copyfile just prevent 'require' of node.js from caching js-object.
29952996
# See https://nodejs.org/api/modules.html
29962997
shutil.copyfile('proxyfs_test.js', 'proxyfs_test1.js')
@@ -6252,12 +6253,14 @@ def percent_diff(x, y):
62526253
full = test()
62536254
# printf is not used in main, but libc was linked in, so it's there
62546255
printf = test(library_args=['-DUSE_PRINTF'])
6255-
# dce in main, and side happens to be ok since it uses puts as well
6256-
dce = test(main_args=['-s', 'MAIN_MODULE=2'])
6256+
# dce in main, and it fails since puts is not exported
6257+
dce = test(main_args=['-s', 'MAIN_MODULE=2'], expected=('cannot', 'undefined'))
6258+
# with exporting, it works
6259+
dce = test(main_args=['-s', 'MAIN_MODULE=2', '-s', 'EXPORTED_FUNCTIONS=["_main", "_puts"]'])
62576260
# printf is not used in main, and we dce, so we failz
62586261
dce_fail = test(main_args=['-s', 'MAIN_MODULE=2'], library_args=['-DUSE_PRINTF'], expected=('cannot', 'undefined'))
62596262
# exporting printf in main keeps it alive for the library
6260-
dce_save = test(main_args=['-s', 'MAIN_MODULE=2', '-s', 'EXPORTED_FUNCTIONS=["_main", "_printf"]'], library_args=['-DUSE_PRINTF'])
6263+
dce_save = test(main_args=['-s', 'MAIN_MODULE=2', '-s', 'EXPORTED_FUNCTIONS=["_main", "_printf", "_puts"]'], library_args=['-DUSE_PRINTF'])
62616264

62626265
assert percent_diff(full[0], printf[0]) < 4
62636266
assert percent_diff(dce[0], dce_fail[0]) < 4

0 commit comments

Comments
 (0)