Skip to content

Commit 4e65d05

Browse files
authored
Fix proxy-to-worker + modularize error reporting (#23517)
This configuration is not supported by was going undetected when `-sEXPORT_ES6` was used due to the order to checking vs setting the `MODULARIZE` setting. This change doesn't add or remove any checks, it only changes the ordering so we don't check settings before they are set.
1 parent 2504d4a commit 4e65d05

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

test/test_other.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14971,7 +14971,6 @@ def test_standalone_whole_archive(self):
1497114971
@parameterized({
1497214972
'': ([],),
1497314973
'single_file': (['-sSINGLE_FILE'],),
14974-
'single_file_es6': (['-sSINGLE_FILE', '-sEXPORT_ES6', '--extern-post-js', test_file('modularize_post_js.js')],),
1497514974
})
1497614975
def test_proxy_to_worker(self, args):
1497714976
self.do_runf('hello_world.c', emcc_args=['--proxy-to-worker'] + args)

tools/link.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,12 @@ def phase_linker_setup(options, state): # noqa: C901, PLR0912, PLR0915
915915
# When using MINIMAL_RUNTIME, symbols should only be exported if requested.
916916
default_setting('EXPORT_KEEPALIVE', 0)
917917

918+
if settings.EXPORT_ES6 and not settings.MODULARIZE:
919+
# EXPORT_ES6 requires output to be a module
920+
if 'MODULARIZE' in user_settings:
921+
exit_with_error('EXPORT_ES6 requires MODULARIZE to be set')
922+
settings.MODULARIZE = 1
923+
918924
if settings.STRICT_JS and (settings.MODULARIZE or settings.EXPORT_ES6):
919925
exit_with_error("STRICT_JS doesn't work with MODULARIZE or EXPORT_ES6")
920926

@@ -926,7 +932,7 @@ def phase_linker_setup(options, state): # noqa: C901, PLR0912, PLR0915
926932
options.shell_path = DEFAULT_SHELL_HTML
927933

928934
if settings.STRICT:
929-
if not settings.MODULARIZE and not settings.EXPORT_ES6:
935+
if not settings.MODULARIZE:
930936
default_setting('STRICT_JS', 1)
931937
default_setting('DEFAULT_TO_CXX', 0)
932938
default_setting('IGNORE_MISSING_MAIN', 0)
@@ -1441,17 +1447,11 @@ def phase_linker_setup(options, state): # noqa: C901, PLR0912, PLR0915
14411447

14421448
set_initial_memory()
14431449

1444-
if settings.EXPORT_ES6:
1445-
if not settings.MODULARIZE:
1446-
# EXPORT_ES6 requires output to be a module
1447-
if 'MODULARIZE' in user_settings:
1448-
exit_with_error('EXPORT_ES6 requires MODULARIZE to be set')
1449-
settings.MODULARIZE = 1
1450-
if settings.ENVIRONMENT_MAY_BE_NODE and not settings.USE_ES6_IMPORT_META:
1451-
# EXPORT_ES6 + ENVIRONMENT=*node* requires the use of import.meta.url
1452-
if 'USE_ES6_IMPORT_META' in user_settings:
1453-
exit_with_error('EXPORT_ES6 and ENVIRONMENT=*node* requires USE_ES6_IMPORT_META to be set')
1454-
settings.USE_ES6_IMPORT_META = 1
1450+
if settings.EXPORT_ES6 and settings.ENVIRONMENT_MAY_BE_NODE and not settings.USE_ES6_IMPORT_META:
1451+
# EXPORT_ES6 + ENVIRONMENT=*node* requires the use of import.meta.url
1452+
if 'USE_ES6_IMPORT_META' in user_settings:
1453+
exit_with_error('EXPORT_ES6 and ENVIRONMENT=*node* requires USE_ES6_IMPORT_META to be set')
1454+
settings.USE_ES6_IMPORT_META = 1
14551455

14561456
if settings.MODULARIZE and not settings.DECLARE_ASM_MODULE_EXPORTS:
14571457
# When MODULARIZE option is used, currently requires declaring all module exports

0 commit comments

Comments
 (0)