Skip to content

Commit 0481237

Browse files
authored
Error on MEMORY_GROWTH_LINEAR_STEP/GEOMETRIC_CAP with STANDALONE_WASM (#18649)
This options only effect the JS version of emscripten_resize_heap, and not the native/standalone one.
1 parent 3d0ff6e commit 0481237

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

emcc.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,6 +1893,16 @@ def phase_linker_setup(options, state, newargs):
18931893
if 'EXIT_RUNTIME' in user_settings:
18941894
exit_with_error('Explictly setting EXIT_RUNTIME not compatible with STANDALONE_WASM. EXIT_RUNTIME will always be True for programs (with a main function) and False for reactors (not main function).')
18951895
settings.EXIT_RUNTIME = settings.EXPECT_MAIN
1896+
settings.IGNORE_MISSING_MAIN = 0
1897+
# the wasm must be runnable without the JS, so there cannot be anything that
1898+
# requires JS legalization
1899+
settings.LEGALIZE_JS_FFI = 0
1900+
if 'MEMORY_GROWTH_LINEAR_STEP' in user_settings:
1901+
exit_with_error('MEMORY_GROWTH_LINEAR_STEP is not compatible with STANDALONE_WASM')
1902+
if 'MEMORY_GROWTH_GEOMETRIC_CAP' in user_settings:
1903+
exit_with_error('MEMORY_GROWTH_GEOMETRIC_CAP is not compatible with STANDALONE_WASM')
1904+
if settings.MINIMAL_RUNTIME:
1905+
exit_with_error('MINIMAL_RUNTIME reduces JS size, and is incompatible with STANDALONE_WASM which focuses on ignoring JS anyhow and being 100% wasm')
18961906

18971907
# Note the exports the user requested
18981908
building.user_requested_exports.update(settings.EXPORTED_FUNCTIONS)
@@ -1909,9 +1919,6 @@ def phase_linker_setup(options, state, newargs):
19091919
if not settings.PURE_WASI and '-nostdlib' not in newargs and '-nodefaultlibs' not in newargs:
19101920
default_setting('STACK_OVERFLOW_CHECK', max(settings.ASSERTIONS, settings.STACK_OVERFLOW_CHECK))
19111921

1912-
if settings.STANDALONE_WASM:
1913-
settings.IGNORE_MISSING_MAIN = 0
1914-
19151922
# For users that opt out of WARN_ON_UNDEFINED_SYMBOLS we assume they also
19161923
# want to opt out of ERROR_ON_UNDEFINED_SYMBOLS.
19171924
if user_settings.get('WARN_ON_UNDEFINED_SYMBOLS') == '0':
@@ -2278,10 +2285,6 @@ def phase_linker_setup(options, state, newargs):
22782285

22792286
settings.REQUIRED_EXPORTS += ['stackSave', 'stackRestore', 'stackAlloc']
22802287

2281-
if not settings.STANDALONE_WASM:
2282-
# in standalone mode, crt1 will call the constructors from inside the wasm
2283-
settings.REQUIRED_EXPORTS.append('__wasm_call_ctors')
2284-
22852288
if settings.RELOCATABLE:
22862289
# TODO(https://reviews.llvm.org/D128515): Make this mandatory once
22872290
# llvm change lands
@@ -2461,13 +2464,6 @@ def check_memory_setting(setting):
24612464
(options.shell_path == utils.path_from_root('src/shell.html') or options.shell_path == utils.path_from_root('src/shell_minimal.html')):
24622465
exit_with_error(f'Due to collision in variable name "Module", the shell file "{options.shell_path}" is not compatible with build options "-sMODULARIZE -sEXPORT_NAME=Module". Either provide your own shell file, change the name of the export to something else to avoid the name collision. (see https://github.com/emscripten-core/emscripten/issues/7950 for details)')
24632466

2464-
if settings.STANDALONE_WASM:
2465-
if settings.MINIMAL_RUNTIME:
2466-
exit_with_error('MINIMAL_RUNTIME reduces JS size, and is incompatible with STANDALONE_WASM which focuses on ignoring JS anyhow and being 100% wasm')
2467-
# the wasm must be runnable without the JS, so there cannot be anything that
2468-
# requires JS legalization
2469-
settings.LEGALIZE_JS_FFI = 0
2470-
24712467
# TODO(sbc): Remove WASM2JS here once the size regression it would introduce has been fixed.
24722468
if settings.SHARED_MEMORY or settings.RELOCATABLE or settings.ASYNCIFY_LAZY_LOAD_CODE or settings.WASM2JS:
24732469
settings.IMPORTED_MEMORY = 1

test/test_other.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12919,3 +12919,15 @@ def test_dbg(self):
1291912919
'ReferenceError: dbg is not defined',
1292012920
emcc_args=['-DNDEBUG', '-sASSERTIONS=0'],
1292112921
assert_returncode=NON_ZERO)
12922+
12923+
def test_standalone_settings(self):
12924+
base_cmd = [EMCC, test_file('hello_world.c'), '-sSTANDALONE_WASM']
12925+
12926+
err = self.expect_fail(base_cmd + ['-sMINIMAL_RUNTIME'])
12927+
self.assertContained('error: MINIMAL_RUNTIME reduces JS size, and is incompatible with STANDALONE_WASM which focuses on ignoring JS anyhow and being 100% wasm', err)
12928+
12929+
err = self.expect_fail(base_cmd + ['-sMEMORY_GROWTH_GEOMETRIC_CAP=1mb'])
12930+
self.assertContained('error: MEMORY_GROWTH_GEOMETRIC_CAP is not compatible with STANDALONE_WASM', err)
12931+
12932+
err = self.expect_fail(base_cmd + ['-sMEMORY_GROWTH_LINEAR_STEP=1mb'])
12933+
self.assertContained('error: MEMORY_GROWTH_LINEAR_STEP is not compatible with STANDALONE_WASM', err)

0 commit comments

Comments
 (0)