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

wasm: support source maps for the unknown target #56660

Closed
rpjohnst opened this issue Dec 10, 2018 · 4 comments
Closed

wasm: support source maps for the unknown target #56660

rpjohnst opened this issue Dec 10, 2018 · 4 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-feature-request Category: A feature request, i.e: not implemented / a PR. O-wasm Target: WASM (WebAssembly), http://webassembly.org/

Comments

@rpjohnst
Copy link
Contributor

Quoting #46765, which was closed and locked inexplicably:

Source maps are the analogon to debuginfo in the js world, including wasm. So we should generate them.

Emscripten apparently already is able to emit them, at least this example contains source maps: https://yurydelendik.github.io/old-man-sandbox/rust-wasm-hey/hey.html Maybe it's not upstreamed yet, idk.

I guess the bulk of this work would reside inside llvm, but I'm still filing a bug here to track support.

@CryZe
Copy link
Contributor

CryZe commented Dec 14, 2018

There was brief support for them when the unknown target used binaryen as the linker, but with the switch to LLD the support was lost. However as far as I know the long term goal is to have proper debuginfo support (via a web version of DWARF) for WebAssembly. I'm pretty sure source maps were just a short term solution.

@jonas-schievink jonas-schievink added O-wasm Target: WASM (WebAssembly), http://webassembly.org/ A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Jan 26, 2019
@newpavlov
Copy link
Contributor

Are source maps part of WebAssembly standard? If not, then I think we should not add them for wasm32-unknown-unknown target and instead introduce them only for wasm32-web-unknown.

@MaulingMonkey
Copy link
Contributor

MaulingMonkey commented Jul 29, 2019

Are source maps part of WebAssembly?

Not yet. Current state of things:

I made a brief attempt to use wasm-dwarf on a wasm32-unknown-unknown library. After much wailing and gnashing of teeth, I was finally able to get things briefly "working". It mapped my callstack to entirely the wrong functions not sharing common disassembly (I'm not sure if that's a wasm-dwarf bug, or a rust bug, or if dwarf info for wasm32-unknown-unknown is currently meaningless by design) and seems to be extremely tempermental - I can't even step into WASM functions from JS without hanging the debugger at the moment (FireFox Bug?), despite my demo running fine when told to simply continue execution instead, and having successfully done so previously.

My current script (creating a second modified *_dbg.wasm + .map) in case it proves useful to someone else trying to take this further:

@set NAME=rust_wasm_sample
cargo build --target=wasm32-unknown-unknown
wasm-dwarf ^
       target/wasm32-unknown-unknown/debug/%NAME%.wasm ^
    -p /rustc/a53f9df32fbb0b5f4382caaad8f1a46f36ea887c/=file://C:/Users/%USERNAME%/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/ ^
    -p /cargo/registry/=file://C:/Users/%USERNAME%/.cargo/registry/ ^
    -p src/liballoc/=file://C:/Users/%USERNAME%/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/liballoc/ ^
    -p src/libcore/=file://C:/Users/%USERNAME%/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/libcore/ ^
    -p src/libstd/=file://C:/Users/%USERNAME%/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/libstd/ ^
    -p src/libpanic_abort/=file://C:/Users/%USERNAME%/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/libpanic_abort/ ^
    -p src/=../../../src/ ^
    -w target/wasm32-unknown-unknown/debug/%NAME%_dbg.wasm ^
    -o target/wasm32-unknown-unknown/debug/%NAME%_dbg.wasm.map ^
    -m %NAME%_dbg.wasm.map

@alexcrichton
Copy link
Member

I'm going to close this because tooling for wasm is generally moving towards DWARF nowadays which is supported by rustc. There's some tools in the ecosystem (I think) to convert DWARF to source maps, which should be used if source maps are desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-feature-request Category: A feature request, i.e: not implemented / a PR. O-wasm Target: WASM (WebAssembly), http://webassembly.org/
Projects
None yet
Development

No branches or pull requests

6 participants