@@ -2960,7 +2960,7 @@ def test_emcc_debug_files(self):
29602960 self.assertFalse(os.path.exists(self.canonical_temp_dir))
29612961 else:
29622962 print(sorted(os.listdir(self.canonical_temp_dir)))
2963- self.assertExists(os.path.join(self.canonical_temp_dir, 'emcc-03 -original.js'))
2963+ self.assertExists(os.path.join(self.canonical_temp_dir, 'emcc-02 -original.js'))
29642964
29652965 def test_debuginfo_line_tables_only(self):
29662966 def test(do_compile):
@@ -3504,10 +3504,10 @@ def test_embind_tsgen_val(self):
35043504 def test_embind_tsgen_bigint(self):
35053505 args = [EMXX, test_file('other/embind_tsgen_bigint.cpp'), '-lembind', '--emit-tsd', 'embind_tsgen_bigint.d.ts']
35063506 # Check that TypeScript generation fails when code contains bigints but their support is not enabled
3507- stderr = self.expect_fail(args)
3507+ stderr = self.expect_fail(args + ['-sWASM_BIGINT=0'] )
35083508 self.assertContained("Missing primitive type to TS type for 'int64_t", stderr)
35093509 # Check that TypeScript generation works when bigint support is enabled
3510- self.run_process(args + ['-sWASM_BIGINT'] )
3510+ self.run_process(args)
35113511 self.assertFileContents(test_file('other/embind_tsgen_bigint.d.ts'), read_file('embind_tsgen_bigint.d.ts'))
35123512
35133513 @requires_wasm64
@@ -8013,8 +8013,8 @@ def test_malloc_multithreading(self, allocator, args):
80138013 self.do_other_test('test_malloc_multithreading.cpp', emcc_args=args)
80148014
80158015 @parameterized({
8016- '': ([], 'testbind .js'),
8017- 'bigint ': (['-sWASM_BIGINT'], 'testbind_bigint .js'),
8016+ '': ([], 'testbind_bigint .js'),
8017+ 'nobigint ': (['-sWASM_BIGINT=0 '], 'testbind .js'),
80188018 })
80198019 @requires_node
80208020 def test_i64_return_value(self, args, bind_js):
@@ -8510,7 +8510,7 @@ def test_binaryen_warn_mem(self):
85108510 self.run_process([EMCC, test_file('hello_world.c'), '-sINITIAL_MEMORY=' + str(16 * 1024 * 1024), '--pre-js', 'pre.js', '-sWASM_ASYNC_COMPILATION=0', '-sIMPORTED_MEMORY'])
85118511 out = self.run_js('a.out.js', assert_returncode=NON_ZERO)
85128512 self.assertContained('LinkError', out)
8513- self.assertContained("memory import 2 has a larger maximum size 800 than the module's declared maximum", out)
8513+ self.assertContained("memory import 1 has a larger maximum size 800 than the module's declared maximum", out)
85148514 self.assertNotContained('hello, world!', out)
85158515 # and with memory growth, all should be good
85168516 self.run_process([EMCC, test_file('hello_world.c'), '-sINITIAL_MEMORY=' + str(16 * 1024 * 1024), '--pre-js', 'pre.js', '-sALLOW_MEMORY_GROWTH', '-sWASM_ASYNC_COMPILATION=0', '-sIMPORTED_MEMORY'])
@@ -8934,39 +8934,39 @@ def test_exported_runtime_methods_metadce(self, use_legacy_name):
89348934 for export in exports:
89358935 self.assertContained(f'Module["{export}"]', js)
89368936
8937- def test_legalize_js_ffi(self):
8938- # test disabling of JS FFI legalization
8939- for (args, js_ffi) in [
8940- (['-sLEGALIZE_JS_FFI=1 ', '-sSIDE_MODULE', '-O1 '], True ),
8941- (['-sLEGALIZE_JS_FFI=0 ', '-sSIDE_MODULE ', '-O1 '], False ),
8942- (['-sLEGALIZE_JS_FFI=0', '-sSIDE_MODULE ', '-O0'], False),
8943- (['-sLEGALIZE_JS_FFI=1', '-sWARN_ON_UNDEFINED_SYMBOLS=0', '-O0'], True),
8944- (['-sLEGALIZE_JS_FFI=0', '-sWARN_ON_UNDEFINED_SYMBOLS=0', '-O0'], False),
8945- ]:
8946- print(args)
8947- delete_file('a.out.wasm')
8948- cmd = [EMCC, test_file('other/ffi.c'), '-g', '-o', 'a.out.wasm'] + args
8949- print(' '.join(cmd))
8950- self.run_process(cmd)
8951- text = self.get_wasm_text('a.out.wasm')
8952- # remove internal comments and extra whitespace
8953- text = re.sub(r'\(;[^;]+;\)', '', text)
8954- text = re.sub(r'\$var\$*.', '', text)
8955- text = re.sub(r'param \$\d+', 'param ', text)
8956- text = re.sub(r' +', ' ', text)
8957- e_add_f32 = re.search(r'func \$add_f \(param f32\) \(param f32\) \(result f32\)', text)
8958- assert e_add_f32, 'add_f export missing'
8959- i_i64_i32 = re.search(r'import "env" "import_ll" .*\(param i32 i32\) \(result i32\)', text)
8960- i_i64_i64 = re.search(r'import "env" "import_ll" .*\(param i64\) \(result i64\)', text)
8961- e_i64_i32 = re.search(r'func \$legalstub\$add_ll \(param i32\) \(param i32\) \(param i32\) \(param i32\) \(result i32\)', text)
8962- if js_ffi:
8963- assert i_i64_i32, 'i64 not converted to i32 in imports'
8964- assert not i_i64_i64, 'i64 not converted to i32 in imports'
8965- assert e_i64_i32, 'i64 not converted to i32 in exports'
8966- else:
8967- assert not i_i64_i32, 'i64 converted to i32 in imports'
8968- assert i_i64_i64, 'i64 converted to i32 in imports'
8969- assert not e_i64_i32, 'i64 converted to i32 in exports'
8937+ @parameterized({
8938+ 'legal_side_O1': (['-sLEGALIZE_JS_FFI=1', '-sSIDE_MODULE', '-O1'], True),
8939+ 'nolegal_side_O1': (['-sLEGALIZE_JS_FFI=0', '-sSIDE_MODULE', '-O1'], False),
8940+ 'nolegal_side_O0': (['-sLEGALIZE_JS_FFI=0 ', '-sSIDE_MODULE', '-O0 '], False ),
8941+ 'legal_O0': (['-sLEGALIZE_JS_FFI=1 ', '-sWARN_ON_UNDEFINED_SYMBOLS=0 ', '-O0 '], True ),
8942+ 'nolegal_O0': (['-sLEGALIZE_JS_FFI=0', '-sWARN_ON_UNDEFINED_SYMBOLS=0 ', '-O0'], False),
8943+ })
8944+ def test_legalize_js_ffi(self, args, js_ffi):
8945+ # test disabling of JS FFI legalization when not using bigint
8946+ print(args)
8947+ delete_file('a.out.wasm')
8948+ cmd = [EMCC, test_file('other/ffi.c'), '-g', '-o', 'a.out.wasm', '-sWASM_BIGINT=0 '] + args
8949+ print(' '.join(cmd))
8950+ self.run_process(cmd)
8951+ text = self.get_wasm_text('a.out.wasm')
8952+ # remove internal comments and extra whitespace
8953+ text = re.sub(r'\(;[^;]+;\)', '', text)
8954+ text = re.sub(r'\$var\$*.', '', text)
8955+ text = re.sub(r'param \$\d+', 'param ', text)
8956+ text = re.sub(r' +', ' ', text)
8957+ e_add_f32 = re.search(r'func \$add_f \(param f32\) \(param f32\) \(result f32\)', text)
8958+ assert e_add_f32, 'add_f export missing'
8959+ i_i64_i32 = re.search(r'import "env" "import_ll" .*\(param i32 i32\) \(result i32\)', text)
8960+ i_i64_i64 = re.search(r'import "env" "import_ll" .*\(param i64\) \(result i64\)', text)
8961+ e_i64_i32 = re.search(r'func \$legalstub\$add_ll \(param i32\) \(param i32\) \(param i32\) \(param i32\) \(result i32\)', text)
8962+ if js_ffi:
8963+ assert i_i64_i32, 'i64 not converted to i32 in imports'
8964+ assert not i_i64_i64, 'i64 not converted to i32 in imports'
8965+ assert e_i64_i32, 'i64 not converted to i32 in exports'
8966+ else:
8967+ assert not i_i64_i32, 'i64 converted to i32 in imports'
8968+ assert i_i64_i64, 'i64 converted to i32 in imports'
8969+ assert not e_i64_i32, 'i64 converted to i32 in exports'
89708970
89718971 @disabled('https://github.com/WebAssembly/binaryen/pull/6428')
89728972 def test_no_legalize_js_ffi(self):
@@ -11478,13 +11478,13 @@ def test(code):
1147811478 print(f'int:{i} float:{f} double:{lf}: both{both}')
1147911479
1148011480 # iprintf is much smaller than printf with float support
11481- self.assertGreater(i, f - 3500 )
11481+ self.assertGreater(i, f - 3800 )
1148211482 self.assertLess(i, f - 3000)
1148311483 # __small_printf is somewhat smaller than printf with long double support
1148411484 self.assertGreater(f, lf - 900)
1148511485 self.assertLess(f, lf - 500)
1148611486 # both is a little bigger still
11487- self.assertGreater(lf, both - 110 )
11487+ self.assertGreater(lf, both - 150 )
1148811488 self.assertLess(lf, both - 50)
1148911489
1149011490 @parameterized({
@@ -12347,19 +12347,18 @@ def ok(args, filename='hello_world.cpp', expected='hello, world!'):
1234712347 args += ['-sERROR_ON_WASM_CHANGES_AFTER_LINK']
1234812348 self.do_runf(filename, expected, emcc_args=args)
1234912349
12350- # -O0 with BigInt support (to avoid the need for legalization)
12351- required_flags = ['-sWASM_BIGINT']
12352- ok(required_flags)
12350+ # -O0 with BigInt support (now on by default)
12351+ ok([])
1235312352 # Same with DWARF
12354- ok(required_flags + ['-g'])
12353+ ok(['-g'])
1235512354 # Function pointer calls from JS work too
12356- ok(required_flags , filename='hello_world_main_loop.cpp')
12355+ ok([] , filename='hello_world_main_loop.cpp')
1235712356 # -O1 is ok as we don't run wasm-opt there (but no higher, see below)
12358- ok(required_flags + ['-O1'])
12357+ ok(['-O1'])
1235912358 # Exception support shouldn't require changes after linking
12360- ok(required_flags + ['-fexceptions'])
12359+ ok(['-fexceptions'])
1236112360 # Standalone mode should not do anything special to the wasm.
12362- ok(required_flags + ['-sSTANDALONE_WASM'])
12361+ ok(['-sSTANDALONE_WASM'])
1236312362
1236412363 # other builds fail with a standard message + extra details
1236512364 def fail(args, details):
@@ -12371,12 +12370,12 @@ def fail(args, details):
1237112370
1237212371 # plain -O0
1237312372 legalization_message = 'to disable int64 legalization (which requires changes after link) use -sWASM_BIGINT'
12374- fail([], legalization_message)
12375- fail(['-sMIN_SAFARI_VERSION=140100 '], legalization_message)
12373+ fail(['-sWASM_BIGINT=0' ], legalization_message)
12374+ fail(['-sMIN_SAFARI_VERSION=140000 '], legalization_message) # TODO(features): change this back to 140100 after 15 is default
1237612375 # optimized builds even without legalization
1237712376 optimization_message = '-O2+ optimizations always require changes, build with -O0 or -O1 instead'
12378- fail(required_flags + ['-O2'], optimization_message)
12379- fail(required_flags + ['-O3'], optimization_message)
12377+ fail(['-O2'], optimization_message)
12378+ fail(['-O3'], optimization_message)
1238012379
1238112380 @crossplatform
1238212381 def test_output_to_nowhere(self):
@@ -14471,7 +14470,8 @@ def test_reproduce(self):
1447114470
1447214471 def test_min_browser_version(self):
1447314472 err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Wno-transpile', '-Werror', '-sWASM_BIGINT', '-sMIN_SAFARI_VERSION=120000'])
14474- self.assertContained('emcc: error: MIN_SAFARI_VERSION=120000 is not compatible with WASM_BIGINT (150000 or above required)', err)
14473+ # TODO(features): fix back to 15000 once Safari 15 is default
14474+ self.assertContained('emcc: error: MIN_SAFARI_VERSION=120000 is not compatible with WASM_BIGINT (140100 or above required)', err)
1447514475
1447614476 err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Wno-transpile', '-Werror', '-pthread', '-sMIN_CHROME_VERSION=73'])
1447714477 self.assertContained('emcc: error: MIN_CHROME_VERSION=73 is not compatible with pthreads (74 or above required)', err)
0 commit comments