Skip to content

Commit 9e49fb3

Browse files
authored
Export __start_em_js and __stop_em_js so binaryen can use them. NFC (#17569)
See WebAssembly/binaryen#4870 which makes sure they get stripped and WebAssembly/binaryen#4871 which actually depends on them.
1 parent 8a91a4e commit 9e49fb3

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/settings_internal.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,16 @@ var SIDE_MODULE_EXPORTS = [];
2929
// module (or other side modules) will need to provide.
3030
var SIDE_MODULE_IMPORTS = [];
3131

32-
// Like EXPORTED_FUNCTIONS, but will not error if symbol is missing
33-
var EXPORT_IF_DEFINED = ['__start_em_asm', '__stop_em_asm'];
32+
// Like EXPORTED_FUNCTIONS, but will not error if symbol is missing.
33+
// The start/stop symbols are included by default so that then can be extracted
34+
// from the binary and embedded into the generated JS. The PostEmscripten pass
35+
// in binaryen will then strip these exports so they will not appear in the
36+
// final shipping binary.
37+
// They are included here rather than in REQUIRED_EXPORTS because not all
38+
// programs contains EM_JS or EM_ASM data section, in which case these symbols
39+
// won't exist.
40+
var EXPORT_IF_DEFINED = ['__start_em_asm', '__stop_em_asm',
41+
'__start_em_js', '__stop_em_js'];
3442

3543
// Like EXPORTED_FUNCTIONS, but symbol is required to exist in native code.
3644
// This means wasm-ld will fail if these symbols are missing.

test/test_other.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8645,12 +8645,14 @@ def get_addr(address):
86458645
[emsymbolizer, 'test_dwarf.wasm', address], stdout=PIPE).stdout
86468646

86478647
# Check a location in foo(), not inlined.
8648-
self.assertIn('test_dwarf.c:6:3', get_addr('0x101'))
8648+
# If the output binary size changes use `wasm-objdump -d` on the binary
8649+
# look for the offset of the first call to `out_to_js`.
8650+
self.assertIn('test_dwarf.c:6:3', get_addr('0x10d'))
86498651
# Check that both bar (inlined) and main (inlinee) are in the output,
86508652
# as described by the DWARF.
86518653
# TODO: consider also checking the function names once the output format
86528654
# stabilizes more
8653-
self.assertRegex(get_addr('0x118').replace('\n', ''),
8655+
self.assertRegex(get_addr('0x124').replace('\n', ''),
86548656
'test_dwarf.c:13:3.*test_dwarf.c:18:3')
86558657

86568658
def test_separate_dwarf(self):

0 commit comments

Comments
 (0)