@@ -14205,10 +14205,29 @@ def test_unused_destructor(self):
14205
14205
self.assertNotIn(b'hello from dtor', read_binary('test_unused_destructor.wasm'))
14206
14206
14207
14207
def test_strip_all(self):
14208
- # Test that even with `-Wl,--strip-all` the target features section is generated
14209
- # by wasm-ld so that later phases (e.g. wasm-opt) can read it.
14208
+ def has_debug_section(wasm):
14209
+ with webassembly.Module('hello_world.wasm') as wasm:
14210
+ return wasm.get_custom_section('.debug_info') is not None
14211
+
14212
+ # Use -O2 to ensure wasm-opt gets run
14213
+ self.emcc_args += ['-g', '-O2']
14214
+
14215
+ # First, verify that `-g` produces a debug section
14216
+ self.do_runf('hello_world.c')
14217
+ self.assertTrue(has_debug_section('hello_world.wasm'))
14218
+
14219
+ # Test `-Wl,--strip-all` will strip the debug section, but that the
14220
+ # the target features section is preserved so that later phases
14221
+ # (e.g. wasm-opt) can read it.
14210
14222
self.do_runf('hello_world.c', emcc_args=['-Wl,--strip-all', '-pthread'])
14223
+ self.assertFalse(has_debug_section('hello_world.wasm'))
14224
+
14225
+ # Verify that `-Wl,-s` and `-s` also both have the same effect
14211
14226
self.do_runf('hello_world.c', emcc_args=['-Wl,-s', '-pthread'])
14227
+ self.assertFalse(has_debug_section('hello_world.wasm'))
14228
+
14229
+ self.do_runf('hello_world.c', emcc_args=['-s', '-pthread'])
14230
+ self.assertFalse(has_debug_section('hello_world.wasm'))
14212
14231
14213
14232
def test_embind_no_duplicate_symbols(self):
14214
14233
# Embind implementation lives almost entirely in headers, which have special rules
0 commit comments