Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to produce wasm with debug information? #123

Open
monkbai opened this issue Jul 27, 2022 · 4 comments
Open

Is it possible to produce wasm with debug information? #123

monkbai opened this issue Jul 27, 2022 · 4 comments
Labels
enhancement possible future feature

Comments

@monkbai
Copy link

monkbai commented Jul 27, 2022

Is it possible to produce wasm code with dwarf debug information attached? I have tried with
/opt/cheerp/bin/clang++ -target cheerp-wasm test.c -o test14.js -O0 -g
But the generated wasm code still contains no debug information.

@carlopi
Copy link
Contributor

carlopi commented Jul 27, 2022

HI @monkbai!

The closest you could get is using:

-g -cheerp-sourcemap=test.js.map -cheerp-linear-output=asmjs

-g allows to pass debug information
-cheerp-sourcemap=somefile generates a file with a given name that holds sourcemap information (for the devtools to be found) and
-cheerp-linear-output=asmjs swtiches from the default wasm to asmjs-based generation for linear memory code, since currently Cheerp doesn't support Wasm-level source maps

Would this set-up work for you?

@monkbai
Copy link
Author

monkbai commented Jul 27, 2022

Thank you @carlopi for answering. The asmjs code compiled with "-g" option is still hard to understand. Also, we prefer to compile wasm code for better performance. So sorry, this setup does not work. Do you have any plan to support attaching dwarf debug information on compiled wasm code? Just like what Emscripten "-g" option does?

Again, thank you for your advice.

@carlopi
Copy link
Contributor

carlopi commented Jul 27, 2022

Producing source map for WebAssembly output it's doable and potentially useful, but currently it's not on the road map for the upcoming months.

To read asmjs code (or even WebAssembly-compiled code) it's beneficial to also add -cheerp-pretty-code, that keeps the variables name somehow more readable (even though there is no guarantee that a mapping between original variables and compiled variables has to be trivial).

Can I ask you what is the project you are working on?
I would expect asmjs penality to be at worst 2x, and for debug builds (you are considering -O0) it's usually doable in exchange for easier inspectability (eg. it's easier to directly add debug statements JS side), while then deploying WebAssembly builds with higher optimizations enabled.

@monkbai
Copy link
Author

monkbai commented Jul 28, 2022

Thank you very much for your help. We only use -O0 option to investigate the availability of dwarf debug information. We will consider turning to asmjs as well. Thanks!

@yuri91 yuri91 added the enhancement possible future feature label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement possible future feature
Projects
None yet
Development

No branches or pull requests

3 participants