Oz and symbols

20 views
Skip to first unread message

Александр Гурьянов

unread,
Jul 30, 2019, 11:08:17 PM7/30/19
to emscripte...@googlegroups.com
HI. I used wasm-opt manually to optimize wasm binary. On last step I
used Oz to finalize optimizations. My problem is that after Oz
function indexes is changed and I can't get symbols map to restore
function names. How I can map new function indexes to old one (from
symbols file).

In other words:
1) I have bin.wasm from emscripten with symbols file. E.g. for one function:
export __GLOBAL__sub_I_Runtime_BaseClasses_0_cpp (func $3425) - 3809

2) I do some buisness releated optimizations (with wasm-opt) that
didn't change function indexes, after this, I still have
export __GLOBAL__sub_I_Runtime_BaseClasses_0_cpp (func $3425) - 3809

3) Next I finalize build with wasm-opt -Oz, after it indexes was
changed (I think because of dead code elimination), and I have
export "__GLOBAL__sub_I_Runtime_BaseClasses_0_cpp" (func $1637) - 1997

I need some flag for Oz, that told generates mapping for new indexes,
like $1637: $3425 then I can restore original function names. I think
some flag or option to do it should be already there, because
emscripten do this in some way. What is the best way to build this
mappings?

Alon Zakai

unread,
Jul 31, 2019, 1:48:09 PM7/31/19
to emscripte...@googlegroups.com
In general the way to do this is to keep names around all the time until the very end. So run emcc with --profiling-funcs. Then when you run wasm-opt later, run it with -g. Then in your final wasm-opt command, do *not* use -g, and instead run --print-function-map which is what is used to print the function map by emcc.

Another way might be to use the BINARYEN_EXTRA_PASSES flag. Then emcc will run extra wasm-opt work for you internally.

- Alon


--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAKOm%3DVGv21Ffn%2Bxc4Fs59t9pBpmMqfa6p2F%2B0p1CmF-O2JjvOQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages