Reputation: 21521
I'm using Twiggy from the Rust Wasm Toolchain to analyse a webassembly package to find largest contributors to code size.
Command line option
twiggy top -n 20 myWasm.wasm
results in a table output like this:
Shallow Bytes │ Shallow % │ Item
───────────────┼───────────┼──────────────────────
520804 ┊ 19.30% ┊ data[0]
23612 ┊ 0.87% ┊ code[17981]
11360 ┊ 0.42% ┊ code[26365]
10709 ┊ 0.40% ┊ code[26298]
10640 ┊ 0.39% ┊ elem[0]
10040 ┊ 0.37% ┊ data[1]
9229 ┊ 0.34% ┊ code[26356]
9222 ┊ 0.34% ┊ code[26364]
8566 ┊ 0.32% ┊ code[26598]
8416 ┊ 0.31% ┊ code[26363]
8250 ┊ 0.31% ┊ code[26329]
8062 ┊ 0.30% ┊ code[26355]
7641 ┊ 0.28% ┊ code[8133]
7528 ┊ 0.28% ┊ code[7927]
7443 ┊ 0.28% ┊ code[15443]
7327 ┊ 0.27% ┊ code[26728]
7049 ┊ 0.26% ┊ code[26729]
7022 ┊ 0.26% ┊ code[15921]
6856 ┊ 0.25% ┊ code[26588]
6772 ┊ 0.25% ┊ code[9434]
2002166 ┊ 74.19% ┊ ... and 29258 more.
2698714 ┊ 100.00% ┊ Σ [29278 Total Rows]
Obviously not very useful!
My current emcc command line args
emcc -s WASM=1 --bind --closure 1 --no-heap-copy -s USE_SDL=2 -s FETCH=1 -s ALLOW_MEMORY_GROWTH=1
-s MAX_WEBGL_VERSION=2 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -O0 -s MODULARIZE=1 -s NODEJS_CATCH_REJECTION=0
-s ENVIRONMENT=web
I'm guessing i need to have the right command line parameters to emcc (emscripten) during build to get some meaningful data here, but what?
I already turned off optimisations with -O0. Should it be a debug build?
Upvotes: 2
Views: 115
Reputation: 1948
Was running into this issue with wasm-opt
, and found that the -g
option works well to preserve the necessary information. It looks like emcc
supports the same option!
Upvotes: 1