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:
Sam Clegg 2021-08-06 11:33:10 -07:00 коммит произвёл GitHub
Родитель 2b858435e4
Коммит 729ed9b75f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 11 добавлений и 6 удалений

Просмотреть файл

@ -1978,6 +1978,9 @@ def phase_linker_setup(options, state, newargs, settings_map):
if settings.MEMORY_GROWTH_LINEAR_STEP != -1:
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:
# EXPORT_ES6 requires output to be a module
if 'MODULARIZE' in settings_map:

5
tests/test_core.py поставляемый
Просмотреть файл

@ -2012,15 +2012,14 @@ int main(int argc, char **argv) {
self.do_core_test('test_memorygrowth_3.c')
@parameterized({
'nogrow': (['-s', 'ALLOW_MEMORY_GROWTH=0'],),
'grow': (['-s', 'ALLOW_MEMORY_GROWTH'],)
'nogrow': ([],),
'grow': (['-sALLOW_MEMORY_GROWTH', '-sMAXIMUM_MEMORY=18MB'],)
})
@no_asan('requires more memory when growing')
def test_aborting_new(self, args):
# test that C++ new properly errors if we fail to malloc when growth is
# enabled, with or without growth
self.emcc_args += args
self.set_setting('MAXIMUM_MEMORY', '18MB')
self.do_core_test('test_aborting_new.cpp')
@no_wasm2js('no WebAssembly.Memory()')

9
tests/test_other.py поставляемый
Просмотреть файл

@ -6895,7 +6895,6 @@ int main() {
for args, expect_initial, expect_max in [
([], 320, 320),
(['-s', 'ALLOW_MEMORY_GROWTH'], 320, 32768),
(['-s', 'MAXIMUM_MEMORY=40MB'], 320, 320),
(['-s', 'ALLOW_MEMORY_GROWTH', '-s', 'MAXIMUM_MEMORY=40MB'], 320, 640),
]:
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
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)
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):
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)