Warning if MAXIUMUM_MEMORY used without ALLOW_MEMORT_GROWTH. NFC (#14816)
Previously we were silently ignoring it. We considered the alternative which would be to automatically enable ALLOW_MEMORT_GROWTH but decided that would be more of a breaking/surprise change.
This commit is contained in:
Родитель
2b858435e4
Коммит
729ed9b75f
3
emcc.py
3
emcc.py
|
@ -1978,6 +1978,9 @@ def phase_linker_setup(options, state, newargs, settings_map):
|
||||||
if settings.MEMORY_GROWTH_LINEAR_STEP != -1:
|
if settings.MEMORY_GROWTH_LINEAR_STEP != -1:
|
||||||
check_memory_setting('MEMORY_GROWTH_LINEAR_STEP')
|
check_memory_setting('MEMORY_GROWTH_LINEAR_STEP')
|
||||||
|
|
||||||
|
if 'MAXIMUM_MEMORY' in settings_map and not settings.ALLOW_MEMORY_GROWTH:
|
||||||
|
diagnostics.warning('unused-command-line-argument', 'MAXIMUM_MEMORY is only meaningful with ALLOW_MEMORY_GROWTH')
|
||||||
|
|
||||||
if settings.EXPORT_ES6 and not settings.MODULARIZE:
|
if settings.EXPORT_ES6 and not settings.MODULARIZE:
|
||||||
# EXPORT_ES6 requires output to be a module
|
# EXPORT_ES6 requires output to be a module
|
||||||
if 'MODULARIZE' in settings_map:
|
if 'MODULARIZE' in settings_map:
|
||||||
|
|
|
@ -2012,15 +2012,14 @@ int main(int argc, char **argv) {
|
||||||
self.do_core_test('test_memorygrowth_3.c')
|
self.do_core_test('test_memorygrowth_3.c')
|
||||||
|
|
||||||
@parameterized({
|
@parameterized({
|
||||||
'nogrow': (['-s', 'ALLOW_MEMORY_GROWTH=0'],),
|
'nogrow': ([],),
|
||||||
'grow': (['-s', 'ALLOW_MEMORY_GROWTH'],)
|
'grow': (['-sALLOW_MEMORY_GROWTH', '-sMAXIMUM_MEMORY=18MB'],)
|
||||||
})
|
})
|
||||||
@no_asan('requires more memory when growing')
|
@no_asan('requires more memory when growing')
|
||||||
def test_aborting_new(self, args):
|
def test_aborting_new(self, args):
|
||||||
# test that C++ new properly errors if we fail to malloc when growth is
|
# test that C++ new properly errors if we fail to malloc when growth is
|
||||||
# enabled, with or without growth
|
# enabled, with or without growth
|
||||||
self.emcc_args += args
|
self.emcc_args += args
|
||||||
self.set_setting('MAXIMUM_MEMORY', '18MB')
|
|
||||||
self.do_core_test('test_aborting_new.cpp')
|
self.do_core_test('test_aborting_new.cpp')
|
||||||
|
|
||||||
@no_wasm2js('no WebAssembly.Memory()')
|
@no_wasm2js('no WebAssembly.Memory()')
|
||||||
|
|
|
@ -6895,7 +6895,6 @@ int main() {
|
||||||
for args, expect_initial, expect_max in [
|
for args, expect_initial, expect_max in [
|
||||||
([], 320, 320),
|
([], 320, 320),
|
||||||
(['-s', 'ALLOW_MEMORY_GROWTH'], 320, 32768),
|
(['-s', 'ALLOW_MEMORY_GROWTH'], 320, 32768),
|
||||||
(['-s', 'MAXIMUM_MEMORY=40MB'], 320, 320),
|
|
||||||
(['-s', 'ALLOW_MEMORY_GROWTH', '-s', 'MAXIMUM_MEMORY=40MB'], 320, 640),
|
(['-s', 'ALLOW_MEMORY_GROWTH', '-s', 'MAXIMUM_MEMORY=40MB'], 320, 640),
|
||||||
]:
|
]:
|
||||||
cmd = [EMCC, test_file('hello_world.c'), '-O2', '-s', 'INITIAL_MEMORY=20MB'] + args
|
cmd = [EMCC, test_file('hello_world.c'), '-O2', '-s', 'INITIAL_MEMORY=20MB'] + args
|
||||||
|
@ -6924,11 +6923,15 @@ int main() {
|
||||||
ret = self.expect_fail([EMCC, test_file('hello_world.c'), '-s', 'INITIAL_MEMORY=33554433']) # 32MB + 1 byte
|
ret = self.expect_fail([EMCC, test_file('hello_world.c'), '-s', 'INITIAL_MEMORY=33554433']) # 32MB + 1 byte
|
||||||
self.assertContained('INITIAL_MEMORY must be a multiple of WebAssembly page size (64KiB)', ret)
|
self.assertContained('INITIAL_MEMORY must be a multiple of WebAssembly page size (64KiB)', ret)
|
||||||
|
|
||||||
self.run_process([EMCC, test_file('hello_world.c'), '-s', 'MAXIMUM_MEMORY=33MB'])
|
self.run_process([EMCC, test_file('hello_world.c'), '-s', 'MAXIMUM_MEMORY=33MB', '-s', 'ALLOW_MEMORY_GROWTH'])
|
||||||
|
|
||||||
ret = self.expect_fail([EMCC, test_file('hello_world.c'), '-s', 'MAXIMUM_MEMORY=34603009']) # 33MB + 1 byte
|
ret = self.expect_fail([EMCC, test_file('hello_world.c'), '-s', 'MAXIMUM_MEMORY=34603009', '-s', 'ALLOW_MEMORY_GROWTH']) # 33MB + 1 byte
|
||||||
self.assertContained('MAXIMUM_MEMORY must be a multiple of WebAssembly page size (64KiB)', ret)
|
self.assertContained('MAXIMUM_MEMORY must be a multiple of WebAssembly page size (64KiB)', ret)
|
||||||
|
|
||||||
|
def test_invalid_memory_max(self):
|
||||||
|
err = self.expect_fail([EMCC, '-Werror', test_file('hello_world.c'), '-sMAXIMUM_MEMORY=41943040'])
|
||||||
|
self.assertContained('emcc: error: MAXIMUM_MEMORY is only meaningful with ALLOW_MEMORY_GROWTH', err)
|
||||||
|
|
||||||
def test_dasho_invalid_dir(self):
|
def test_dasho_invalid_dir(self):
|
||||||
ret = self.expect_fail([EMCC, test_file('hello_world.c'), '-o', Path('NONEXISTING_DIRECTORY/out.js')])
|
ret = self.expect_fail([EMCC, test_file('hello_world.c'), '-o', Path('NONEXISTING_DIRECTORY/out.js')])
|
||||||
self.assertContained('specified output file (NONEXISTING_DIRECTORY%sout.js) is in a directory that does not exist' % os.path.sep, ret)
|
self.assertContained('specified output file (NONEXISTING_DIRECTORY%sout.js) is in a directory that does not exist' % os.path.sep, ret)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче