I am using cargo build --target wasm32-unknown-unknown
to compile a Rust file into a WASM module and then parsing the WASM file using wasmparser
. However, when I parse the name
custom section, I can only retrieve function names from the source code, but the local variable names are missing.
With the same approach, I tested WASM files compiled from other languages, and they correctly retained local variable names.
I suspect that cargo build
discards local variable names during compilation. How can I prevent this and ensure that Cargo generates a WASM file that retains local variable names?
How can I prevent this and ensure that Cargo generates a WASM file that retains local variable names?