@@ -5690,7 +5690,7 @@ def test_warn_dylibs(self):
5690
5690
def test_symbol_map(self, opts, wasm):
5691
5691
def read_symbol_map(symbols_file):
5692
5692
symbols = read_file(symbols_file)
5693
- lines = [line.split(':') for line in symbols.splitlines()]
5693
+ lines = [line.split(':', 1 ) for line in symbols.splitlines()]
5694
5694
return lines
5695
5695
5696
5696
def get_minified_middle(symbols_file):
@@ -5706,27 +5706,35 @@ def is_js_symbol_map(symbols_file):
5706
5706
return True
5707
5707
return False
5708
5708
5709
- create_file('src.c ', r'''
5709
+ create_file('src.cpp ', r'''
5710
5710
#include <emscripten.h>
5711
5711
5712
+ namespace foo {
5713
+
5714
+ EMSCRIPTEN_KEEPALIVE void* cpp_func(int foo) {
5715
+ return 0;
5716
+ }
5717
+
5718
+ }
5719
+
5712
5720
EM_JS(int, run_js, (), {
5713
- out(new Error().stack);
5714
- return 0;
5721
+ out(new Error().stack);
5722
+ return 0;
5715
5723
});
5716
5724
5717
5725
EMSCRIPTEN_KEEPALIVE
5718
- void middle() {
5719
- if (run_js()) {
5720
- // fake recursion that is never reached, to avoid inlining in binaryen and LLVM
5721
- middle();
5722
- }
5726
+ extern "C" void middle() {
5727
+ if (run_js()) {
5728
+ // fake recursion that is never reached, to avoid inlining in binaryen and LLVM
5729
+ middle();
5730
+ }
5723
5731
}
5724
5732
5725
5733
int main() {
5726
- EM_ASM({ _middle() });
5734
+ EM_ASM({ _middle() });
5727
5735
}
5728
5736
''')
5729
- cmd = [EMCC , 'src.c ', '--emit-symbol-map'] + opts
5737
+ cmd = [EMXX , 'src.cpp ', '--emit-symbol-map'] + opts
5730
5738
if wasm != 1:
5731
5739
cmd.append(f'-sWASM={wasm}')
5732
5740
self.run_process(cmd)
@@ -5749,6 +5757,10 @@ def is_js_symbol_map(symbols_file):
5749
5757
self.assertTrue(is_js_symbol_map('a.out.js.symbols'), 'Primary symbols file should store JS mappings')
5750
5758
elif wasm == 1:
5751
5759
self.assertFalse(is_js_symbol_map('a.out.js.symbols'), 'Primary symbols file should store Wasm mappings')
5760
+ if '-O2' in opts:
5761
+ self.assertFileContents(test_file('other/test_symbol_map.O2.symbols'), read_file('a.out.js.symbols'))
5762
+ else:
5763
+ self.assertFileContents(test_file('other/test_symbol_map.O3.symbols'), read_file('a.out.js.symbols'))
5752
5764
elif wasm == 2:
5753
5765
# special case when both JS and Wasm targets are created
5754
5766
minified_middle_2 = get_minified_middle('a.out.wasm.js.symbols')
0 commit comments