Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/Modules/Platform/Emscripten.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ endif()
list(APPEND CMAKE_FIND_ROOT_PATH "${EMSCRIPTEN_SYSROOT}")
list(APPEND CMAKE_SYSTEM_PREFIX_PATH /)

if (${CMAKE_C_FLAGS} MATCHES "MEMORY64")
if (${CMAKE_C_FLAGS} MATCHES "MEMORY64|-m64|--target=wasm64")
set(CMAKE_LIBRARY_ARCHITECTURE "wasm64-emscripten")
set(CMAKE_SIZEOF_VOID_P 8)
set(CMAKE_C_SIZEOF_DATA_PTR 8)
Expand Down
2 changes: 2 additions & 0 deletions site/source/docs/tools_reference/settings_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ The "architecture" to compile for. 0 means the default wasm32, 1 is
the full end-to-end wasm64 mode, and 2 is wasm64 for clang/lld but lowered to
wasm32 in Binaryen (such that it can run on wasm32 engines, while internally
using i64 pointers).
Nowadays we recommend using the more standard `-m64` or `--target=wasm64`
flags, which do the same thing.
Assumes WASM_BIGINT.

.. note:: Applicable during both linking and compilation
Expand Down
2 changes: 2 additions & 0 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ var MEMORY_GROWTH_LINEAR_STEP = -1;
// the full end-to-end wasm64 mode, and 2 is wasm64 for clang/lld but lowered to
// wasm32 in Binaryen (such that it can run on wasm32 engines, while internally
// using i64 pointers).
// Nowadays we recommend using the more standard `-m64` or `--target=wasm64`
// flags, which do the same thing.
// Assumes WASM_BIGINT.
// [compile+link]
var MEMORY64 = 0;
Expand Down
4 changes: 2 additions & 2 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def is_browser_test(self):
return False

def is_wasm64(self):
return self.get_setting('MEMORY64')
return '-m64' in self.cflags

def is_4gb(self):
return self.get_setting('INITIAL_MEMORY') == '4200mb'
Expand Down Expand Up @@ -618,7 +618,7 @@ def require_jspi(self):

def require_wasm2js(self):
if self.is_wasm64():
self.skipTest('wasm2js is not compatible with MEMORY64')
self.skipTest('wasm2js is not compatible with wasm64')
if self.is_2gb() or self.is_4gb():
self.skipTest('wasm2js does not support over 2gb of memory')
if self.get_setting('WASM_ESM_INTEGRATION'):
Expand Down
4 changes: 2 additions & 2 deletions test/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def metafunc(self, with_wasm64, *args, **kwargs):
print('parameterize:wasm64=%s' % with_wasm64)
if with_wasm64:
self.require_wasm64()
self.set_setting('MEMORY64')
self.cflags += ['-m64']
return func(self, *args, **kwargs)

parameterize(metafunc, {'': (False,),
Expand Down Expand Up @@ -459,7 +459,7 @@ def metafunc(self, with_wasm2js, *args, **kwargs):


def can_do_standalone(self, impure=False):
# Pure standalone engines don't support MEMORY64 yet. Even with MEMORY64=2 (lowered)
# Pure standalone engines don't support wasm64 yet. Even with MEMORY64=2 (lowered)
# the WASI APIs that take pointer values don't have 64-bit variants yet.
if not impure:
if self.is_wasm64():
Expand Down
18 changes: 9 additions & 9 deletions test/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,9 @@ def get_output_files(self):
'v8': EmscriptenBenchmarker('v8', aot_v8),
'v8-lto': EmscriptenBenchmarker('v8-lto', aot_v8, ['-flto']),
'v8-ctors': EmscriptenBenchmarker('v8-ctors', aot_v8, ['-sEVAL_CTORS']),
'v8-64': EmscriptenBenchmarker('v8-64', aot_v8, ['-sMEMORY64=2']),
'v8-64': EmscriptenBenchmarker('v8-64', aot_v8, ['-m64']),
'node': EmscriptenBenchmarker('node', config.NODE_JS_TEST),
'node-64': EmscriptenBenchmarker('node-64', config.NODE_JS_TEST, ['-sMEMORY64=2']),
'node-64': EmscriptenBenchmarker('node-64', config.NODE_JS_TEST, ['-m64']),
'cherp-v8': CheerpBenchmarker('cheerp-v8-wasm', aot_v8),
# TODO: ensure no baseline compiler is used, see v8
'sm': EmscriptenBenchmarker('sm', config.SPIDERMONKEY_ENGINE),
Expand Down Expand Up @@ -1037,10 +1037,10 @@ def lua(self, benchmark, expected, output_parser=None):
copy_asset(f'third_party/lua/{benchmark}.lua')

def lib_builder(name, native, env_init):
# Inject -sMEMORY64 into node-64 benchmarking runs.
# Inject -m64 into node-64 benchmarking runs.
env_init['MYCFLAGS'] = env_init.get('CFLAGS', '')
if '-sMEMORY64' in env_init['MYCFLAGS']:
env_init['MYLDFLAGS'] = '-sMEMORY64'
if '-m64' in env_init['MYCFLAGS']:
env_init['MYLDFLAGS'] = '-m64'

# We force recomputation for the native benchmarker because this benchmark
# uses native_exec=True, so we need to copy the native executable
Expand Down Expand Up @@ -1169,9 +1169,9 @@ def test_zzz_poppler(self):
''' % DEFAULT_ARG)

def lib_builder(name, native, env_init): # noqa
if '-sMEMORY64' in env_init.get('CFLAGS', ''):
env_init['CPPFLAGS'] = '-sMEMORY64'
env_init['LDFLAGS'] = '-sMEMORY64'
if '-m64' in env_init.get('CFLAGS', ''):
env_init['CPPFLAGS'] = '-m64'
env_init['LDFLAGS'] = '-m64'
return self.get_poppler_library(env_init=env_init)

self.do_benchmark('poppler', '', 'hashed printout',
Expand All @@ -1182,6 +1182,6 @@ def lib_builder(name, native, env_init): # noqa
'-sERROR_ON_UNDEFINED_SYMBOLS=0',
'-sMINIMAL_RUNTIME=0'], # not minimal because of files
lib_builder=lib_builder,
# TODO: Fix poppler native and freetype MEMORY64 builds to be able
# TODO: Fix poppler native and freetype wasm64 builds to be able
# to remove these skips
skip_benchmarkers=['clang', 'gcc', 'v8-64', 'node-64'])
6 changes: 3 additions & 3 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5685,14 +5685,14 @@ def test_shell_minimal(self, args):
class browser64(browser):
def setUp(self):
super().setUp()
self.set_setting('MEMORY64')
self.cflags += ['-m64']
self.require_wasm64()


class browser64_4gb(browser):
def setUp(self):
super().setUp()
self.set_setting('MEMORY64')
self.cflags += ['-m64']
self.set_setting('INITIAL_MEMORY', '4200mb')
self.set_setting('GLOBAL_BASE', '4gb')
# Without this we get a warning about GLOBAL_BASE being ignored when used with SIDE_MODULE
Expand All @@ -5703,7 +5703,7 @@ def setUp(self):
class browser64_2gb(browser):
def setUp(self):
super().setUp()
self.set_setting('MEMORY64')
self.cflags += ['-m64']
self.set_setting('INITIAL_MEMORY', '2200mb')
self.set_setting('GLOBAL_BASE', '2gb')
# Without this we get a warning about GLOBAL_BASE being ignored when used with SIDE_MODULE
Expand Down
2 changes: 1 addition & 1 deletion test/test_codesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def strip_numeric_suffixes(funcname):
'Os_mr': (['-Os', '-sMINIMAL_RUNTIME'],),
# EVAL_CTORS also removes the __wasm_call_ctors function
'Oz-ctors': (['-Oz', '-sEVAL_CTORS'],),
'64': (['-Oz', '-sMEMORY64'],),
'64': (['-Oz', '-m64'],),
# WasmFS should not be fully linked into a minimal program.
'wasmfs': (['-Oz', '-sWASMFS'],),
'esm': (['-Oz', '-sEXPORT_ES6'],),
Expand Down
13 changes: 5 additions & 8 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9921,18 +9921,15 @@ def setUp(self):
core_2gb = make_run('core_2gb', cflags=['--profiling-funcs'],
settings={'INITIAL_MEMORY': '2200mb', 'GLOBAL_BASE': '2gb'})

# MEMORY64=1
wasm64 = make_run('wasm64', cflags=['--profiling-funcs'],
settings={'MEMORY64': 1}, require_wasm64=True)
wasm64_O2 = make_run('wasm64_O2', cflags=['-O2'],
settings={'MEMORY64': 1}, require_wasm64=True)
wasm64 = make_run('wasm64', cflags=['--profiling-funcs', '-m64'], require_wasm64=True)
wasm64_O2 = make_run('wasm64_O2', cflags=['-O2', '-m64'], require_wasm64=True)
# Run the wasm64 tests with all memory offsets > 4gb. Be careful running this test
# suite with any kind of parallelism.
wasm64_4gb = make_run('wasm64_4gb', cflags=['--profiling-funcs'],
settings={'MEMORY64': 1, 'INITIAL_MEMORY': '4200mb', 'GLOBAL_BASE': '4gb'},
wasm64_4gb = make_run('wasm64_4gb', cflags=['-m64', '--profiling-funcs'],
settings={'INITIAL_MEMORY': '4200mb', 'GLOBAL_BASE': '4gb'},
require_wasm64=True)
# MEMORY64=2, or "lowered"
wasm64l = make_run('wasm64l', cflags=['-O1', '--profiling-funcs'],
wasm64l = make_run('wasm64l', cflags=['-m64', '-O1', '--profiling-funcs'],
settings={'MEMORY64': 2})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why pass both -m64 and -MEMORY64=2?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason. But its only not harmful.


lto0 = make_run('lto0', cflags=['-flto', '-O0'])
Expand Down
4 changes: 2 additions & 2 deletions test/test_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,14 @@ def test_html_source_map(self):
class interactive64(interactive):
def setUp(self):
super().setUp()
self.set_setting('MEMORY64')
self.cflags += ['-m64']
self.require_wasm64()


class interactive64_4gb(interactive):
def setUp(self):
super().setUp()
self.set_setting('MEMORY64')
self.cflags += ['-m64']
self.set_setting('INITIAL_MEMORY', '4200mb')
self.set_setting('GLOBAL_BASE', '4gb')
self.require_wasm64()
Expand Down
44 changes: 24 additions & 20 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,13 @@ def test_dumpmachine(self):
output = self.run_process([EMCC, '--print-target-triple'], stdout=PIPE, stderr=PIPE).stdout
self.assertContained('wasm32-unknown-emscripten', output)

# Test that -sMEMORY64 triggers the wasm64 triple
# Test that -m64 / -sMEMORY64 triggers the wasm64 triple
output = self.run_process([EMCC, '-sMEMORY64', '-dumpmachine'], stdout=PIPE, stderr=PIPE).stdout
self.assertContained('wasm64-unknown-emscripten', output)

output = self.run_process([EMCC, '-m64', '-dumpmachine'], stdout=PIPE, stderr=PIPE).stdout
self.assertContained('wasm64-unknown-emscripten', output)

@parameterized({
'c': [EMCC, '.c'],
'cxx': [EMXX, '.cpp'],
Expand Down Expand Up @@ -703,7 +706,7 @@ def test_emcc_cflags(self):
@parameterized({
'': [[]],
'lto': [['-flto']],
'wasm64': [['-sMEMORY64']],
'wasm64': [['-m64']],
})
def test_print_search_dirs(self, args):
output = self.run_process([EMCC, '-print-search-dirs'] + args, stdout=PIPE).stdout
Expand All @@ -715,22 +718,22 @@ def test_print_search_dirs(self, args):
libpath = libpath.split(os.pathsep)
libpath = [Path(p) for p in libpath]
settings.LTO = '-flto' in args
settings.MEMORY64 = int('-sMEMORY64' in args)
settings.MEMORY64 = int('-m64' in args)
expected = cache.get_lib_dir(absolute=True)
self.assertIn(expected, libpath)

@crossplatform
@parameterized({
'': [[]],
'lto': [['-flto']],
'wasm64': [['-sMEMORY64']],
'wasm64': [['-m64']],
})
def test_print_libgcc_file_name(self, args):
output = self.run_process([EMCC, '-print-libgcc-file-name'] + args, stdout=PIPE).stdout
output2 = self.run_process([EMCC, '--print-libgcc-file-name'] + args, stdout=PIPE).stdout
self.assertEqual(output, output2)
settings.LTO = '-flto' in args
settings.MEMORY64 = int('-sMEMORY64' in args)
settings.MEMORY64 = int('-m64' in args)
libdir = cache.get_lib_dir(absolute=True)
expected = os.path.join(libdir, 'libcompiler_rt.a')
self.assertEqual(output.strip(), expected)
Expand All @@ -757,7 +760,7 @@ def test_print_prog_name(self):
@parameterized({
'': [[]],
'lto': [['-flto']],
'wasm64': [['-sMEMORY64']],
'wasm64': [['-m64']],
})
def test_print_file_name(self, args):
# make sure the corresponding version of libc exists in the cache
Expand All @@ -767,7 +770,7 @@ def test_print_file_name(self, args):
self.assertEqual(output, output2)
filename = Path(output)
settings.LTO = '-flto' in args
settings.MEMORY64 = int('-sMEMORY64' in args)
settings.MEMORY64 = int('-m64' in args)
self.assertContained(cache.get_lib_name('libc.a'), str(filename))

def test_emar_em_config_flag(self):
Expand Down Expand Up @@ -1085,17 +1088,17 @@ def test_pkg_config_ports(self):

@parameterized({
'': [None],
'wasm64': ['-sMEMORY64'],
'wasm64': ['-m64'],
'pthreads': ['-pthread'],
})
def test_cmake_check_type_size(self, cflag):
if cflag == '-sMEMORY64':
if cflag == '-m64':
self.require_wasm64()
cmd = [EMCMAKE, 'cmake', test_file('cmake/check_type_size')]
if cflag:
cmd += [f'-DCMAKE_CXX_FLAGS={cflag}', f'-DCMAKE_C_FLAGS={cflag}']
output = self.run_process(cmd, stdout=PIPE).stdout
if cflag == '-sMEMORY64':
if cflag == '-m64':
self.assertContained('CMAKE_SIZEOF_VOID_P -> 8', output)
else:
self.assertContained('CMAKE_SIZEOF_VOID_P -> 4', output)
Expand Down Expand Up @@ -3445,7 +3448,7 @@ def test_embind_subclass_pointer(self):
'no_utf8': ['-sEMBIND_STD_STRING_IS_UTF8=0'],
'no_dynamic': ['-sDYNAMIC_EXECUTION=0'],
'aot_js': ['-sDYNAMIC_EXECUTION=0', '-sEMBIND_AOT', '-DSKIP_UNBOUND_TYPES'],
'wasm64': ['-sMEMORY64'],
'wasm64': ['-m64'],
'2gb': ['-sINITIAL_MEMORY=2200mb', '-sGLOBAL_BASE=2gb'],
})
@parameterized({
Expand All @@ -3468,7 +3471,7 @@ def test_embind(self, *extra_args):
#
# By default all of them are run. If you are debugging and want to run just a subset of the
# JS tests you can use `EMBIND_TESTS=myregex` to run just the matching tests.
if '-sMEMORY64' in extra_args:
if '-m64' in extra_args:
self.require_wasm64()
self.cflags += [
'--no-entry',
Expand Down Expand Up @@ -3657,7 +3660,7 @@ def test_embind_tsgen_end_to_end(self, opts, tsc_opts):
'4': [['-fsanitize=undefined', '-gsource-map'], 'embind_tsgen_ignore_3.d.ts'],
'5': [['-sASYNCIFY'], 'embind_tsgen_ignore_3.d.ts'],
'6': [['-sENVIRONMENT=worker', '-lworkerfs.js'], 'embind_tsgen.d.ts'],
'7': [['-sMEMORY64=1', '-gsource-map'], 'embind_tsgen_ignore_7.d.ts'],
'7': [['-m64', '-gsource-map'], 'embind_tsgen_ignore_7.d.ts'],
})
def test_embind_tsgen_ignore(self, extra_args, expected_ts_file):
create_file('fail.js', 'assert(false);')
Expand Down Expand Up @@ -3737,7 +3740,7 @@ def test_embind_tsgen_bigint(self):
def test_embind_tsgen_wasm64(self, args):
# Check that when wasm64 is enabled longs & unsigned longs are mapped to bigint in the generated TS bindings
self.run_process([EMXX, test_file('other/embind_tsgen_wasm64.cpp'),
'-lembind', '--emit-tsd', 'embind_tsgen_wasm64.d.ts', '-sMEMORY64'] +
'-lembind', '--emit-tsd', 'embind_tsgen_wasm64.d.ts', '-m64'] +
args +
self.get_cflags())
self.assertFileContents(test_file('other/embind_tsgen_wasm64.d.ts'), read_file('embind_tsgen_wasm64.d.ts'))
Expand Down Expand Up @@ -6590,7 +6593,7 @@ def test_failing_growth_wasm64(self):
}
}
''')
self.do_runf('test.c', 'done\n', cflags=['-sGLOBAL_BASE=2Gb', '-sTOTAL_MEMORY=4Gb', '-sMAXIMUM_MEMORY=5Gb', '-sALLOW_MEMORY_GROWTH', '-sMEMORY64'])
self.do_runf('test.c', 'done\n', cflags=['-sGLOBAL_BASE=2Gb', '-sTOTAL_MEMORY=4Gb', '-sMAXIMUM_MEMORY=5Gb', '-sALLOW_MEMORY_GROWTH', '-m64'])

def test_libcxx_minimal(self):
create_file('vector.cpp', r'''
Expand Down Expand Up @@ -10055,7 +10058,7 @@ def test_wasm_producers_section(self, args):
# in some modes we run wasm-emscripten-finalize, which normally strips the
# features section for us, so add testing for those
'nobigint': (['-sWASM_BIGINT=0'],),
'wasm64': (['-sMEMORY64'],),
'wasm64': (['-m64'],),
})
def test_wasm_features_section(self, args):
# The features section should never be in our output, when we optimize.
Expand Down Expand Up @@ -13567,7 +13570,7 @@ def test_extended_const(self):
# Test that extended-const expressions are used in the data segments.
self.assertContained(r'\(data (\$\S+ )?\(offset \(i32.add\s+\(global.get \$\S+\)\s+\(i32.const \d+\)', wat, regex=True)

# Smoketest for MEMORY64 setting. Most of the testing of MEMORY64 is by way of the wasm64
# Smoketest for wasm64. Most of the testing of wasm64 is by way of the wasm64
# variant of the core test suite.
@parameterized({
'O0': (['-O0'],),
Expand All @@ -13577,8 +13580,8 @@ def test_extended_const(self):
'Oz': (['-Oz'],),
})
@requires_wasm64
def test_memory64(self, args):
self.do_run_in_out_file_test('core/test_hello_argc.c', args=['hello', 'world'], cflags=['-sMEMORY64'] + args)
def test_wasm64(self, args):
self.do_run_in_out_file_test('core/test_hello_argc.c', args=['hello', 'world'], cflags=['-m64'] + args)

# Verfy that MAIN_MODULE=1 (which includes all symbols from all libraries)
# works with -sPROXY_POSIX_SOCKETS and -Oz, both of which affect linking of
Expand Down Expand Up @@ -14379,6 +14382,7 @@ def is_64(path):
self.assertFalse(is_64('hello_world.wasm'))

self.assert_fail([EMCC, test_file('hello_world.c'), '-target', 'wasm32', '-sMEMORY64'], 'emcc: error: wasm32 target is not compatible with -sMEMORY64')
self.assert_fail([EMCC, test_file('hello_world.c'), '-target', 'wasm32', '-m64'], 'emcc: error: wasm32 target is not compatible with -sMEMORY64')

self.assert_fail([EMCC, test_file('hello_world.c'), '--target=arm64'], 'emcc: error: unsupported target: arm64 (emcc only supports wasm64-unknown-emscripten and wasm32-unknown-emscripten')

Expand Down Expand Up @@ -14701,7 +14705,7 @@ def test_uuid(self):

def test_wasm64_no_asan(self):
expected = 'error: MEMORY64 does not yet work with ASAN'
self.assert_fail([EMCC, test_file('hello_world.c'), '-sMEMORY64', '-fsanitize=address'], expected)
self.assert_fail([EMCC, test_file('hello_world.c'), '-m64', '-fsanitize=address'], expected)

def test_mimalloc_no_asan(self):
# See https://github.com/emscripten-core/emscripten/issues/23288#issuecomment-2571648258
Expand Down
2 changes: 1 addition & 1 deletion test/test_sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,5 +423,5 @@ def test_sockets_send_while_connecting(self):
class sockets64(sockets):
def setUp(self):
super().setUp()
self.set_setting('MEMORY64')
self.cflags.append('-m64')
self.require_wasm64()
4 changes: 2 additions & 2 deletions tools/maint/gen_sig_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ def extract_sig_info(sig_info, extra_settings=None, extra_cflags=None, cxx=False
shared.check_call(cmd)
sig_info32 = extract_sigs(symbols, obj_file)

# Run the same command again with memory64.
shared.check_call(cmd + ['-sMEMORY64'])
# Run the same command again with wasm64.
shared.check_call(cmd + ['-m64'])
sig_info64 = extract_sigs(symbols, obj_file)

for sym, sig32 in sig_info32.items():
Expand Down
2 changes: 1 addition & 1 deletion tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_base_cflags(build_dir, force_object_files=False, preprocess=True):
if preprocess:
flags += ['-DEMSCRIPTEN_DYNAMIC_LINKING']
if settings.MEMORY64:
flags += ['-sMEMORY64']
flags += ['-m64']

source_dir = utils.path_from_root()
relative_source_dir = os.path.relpath(source_dir, build_dir)
Expand Down
Loading