Skip to content

Commit 35d5926

Browse files
authored
Add test for use of extended const expressions (#16502)
These get used when running clang with `+mextended-const` and this allows the linker to avoid generated so much startup code when building relocatable binaries.
1 parent 155523a commit 35d5926

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/test_other.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11826,3 +11826,13 @@ def test_clock_nanosleep(self):
1182611826
# Tests the internal test suite of tools/unsafe_optimizations.js
1182711827
def test_unsafe_optimizations(self):
1182811828
self.run_process(config.NODE_JS + [path_from_root('tools', 'unsafe_optimizations.js'), '--test'])
11829+
11830+
@require_v8
11831+
def test_extended_const(self):
11832+
self.v8_args = ['--experimental-wasm-extended-const']
11833+
self.do_runf(test_file('hello_world.c'), emcc_args=['-mextended-const', '-sMAIN_MODULE=2'])
11834+
wat = self.get_wasm_text('hello_world.wasm')
11835+
# Test that extended-const expressions are used in the data segments.
11836+
self.assertTrue(re.search(r'\(data \(i32.add\s+\(global.get \$\S+\)\s+\(i32.const \d+\)', wat))
11837+
# Test that extended-const expressions are used in at least one global initializer.
11838+
self.assertTrue(re.search(r'\(global \$\S+ i32 \(i32.add\s+\(global.get \$\S+\)\s+\(i32.const \d+\)', wat))

0 commit comments

Comments
 (0)