Error on EXPORT_NAME without MODULARIZE. NFC One doesn't make sense without that other. Fixes: #17274
diff --git a/emcc.py b/emcc.py index f150928..96bc1a2 100755 --- a/emcc.py +++ b/emcc.py
@@ -2567,6 +2567,9 @@ if not js_manipulation.isidentifier(settings.EXPORT_NAME): exit_with_error(f'EXPORT_NAME is not a valid JS identifier: `{settings.EXPORT_NAME}`') + if not settings.MODULARIZE and 'EXPORT_NAME' in user_settings: + exit_with_error('-sEXPORT_NAME can only be used with -sMODULARIZE') + if settings.EMSCRIPTEN_TRACING and settings.ALLOW_MEMORY_GROWTH: settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['emscripten_trace_report_memory_layout'] settings.REQUIRED_EXPORTS += ['emscripten_stack_get_current',
diff --git a/site/source/docs/getting_started/FAQ.rst b/site/source/docs/getting_started/FAQ.rst index 7214734..d9403e6 100644 --- a/site/source/docs/getting_started/FAQ.rst +++ b/site/source/docs/getting_started/FAQ.rst
@@ -372,8 +372,8 @@ call to create an instance of your module. The factory function returns a Promise that resolves with the module instance. The promise is resolved once it's safe to call the compiled code, i.e. after the compiled code has been -downloaded and instantiated. For example, if you build with ``-sMODULARIZE -s -'EXPORT_NAME="createMyModule"'``, then you can do this: +downloaded and instantiated. For example, if you build with ``-sMODULARIZE +-sEXPORT_NAME=createMyModule``, then you can do this: ::
diff --git a/tests/test_other.py b/tests/test_other.py index 602cfb4..b3eda31 100644 --- a/tests/test_other.py +++ b/tests/test_other.py
@@ -5578,9 +5578,8 @@ assert output.stdout == 'hello, world!\n' and output.stderr == '', 'expected output, got\n===\nSTDOUT\n%s\n===\nSTDERR\n%s\n===\n' % (output.stdout, output.stderr) def test_EXPORT_NAME_with_html(self): - result = self.run_process([EMCC, test_file('hello_world.c'), '-o', 'a.html', '-sEXPORT_NAME=Other'], stdout=PIPE, check=False, stderr=STDOUT) - self.assertNotEqual(result.returncode, 0) - self.assertContained('Customizing EXPORT_NAME requires that the HTML be customized to use that name', result.stdout) + err = self.expect_fail([EMCC, test_file('hello_world.c'), '-o', 'a.html', '-sEXPORT_NAME=Other', '-sMODULARIZE']) + self.assertContained('Customizing EXPORT_NAME requires that the HTML be customized to use that name', err) def test_modularize_sync_compilation(self): create_file('post.js', r''' @@ -6805,8 +6804,8 @@ def test_dash_s_response_file_string(self): create_file('response_file.txt', 'MyModule\n') create_file('response_file.json', '"MyModule"\n') - self.run_process([EMXX, test_file('hello_world.cpp'), '-sEXPORT_NAME=@response_file.txt']) - self.run_process([EMXX, test_file('hello_world.cpp'), '-sEXPORT_NAME=@response_file.json']) + self.run_process([EMXX, test_file('hello_world.cpp'), '-sMODULARIZE', '-sEXPORT_NAME=@response_file.txt']) + self.run_process([EMXX, test_file('hello_world.cpp'), '-sMODULARIZE', '-sEXPORT_NAME=@response_file.json']) def test_dash_s_response_file_list(self): create_file('response_file.txt', '_main\n_malloc\n')