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

Feature request: cargo wat #142

Open
drewsilcock opened this issue Sep 8, 2019 · 5 comments
Open

Feature request: cargo wat #142

drewsilcock opened this issue Sep 8, 2019 · 5 comments

Comments

@drewsilcock
Copy link

Being able to see and compare generated asm and LLVM IR is super useful. It would great to be able to have another command to show the generated .wat or .wast (i.e. WebAssembly in text format) output so that it could be directly compared against the assembly and LLVM IR.

Thanks for a great package!

@gnzlbg
Copy link
Owner

gnzlbg commented Sep 9, 2019

I'd kind of expected cargo asm --target=wasm32-unknown-unknown or similar to just work. Doesn't it ?

@drewsilcock
Copy link
Author

If I just do cargo asm --target=wasm32-unknown-unknown or cargo asm --target=wasm32-wasi then I get a list of symbols as expected, but if I try to drill down into my particular function I get this:

$ RUST_BACKTRACE=1 cargo asm --target=wasm32-wasi nemolite2d_rs_lib::run_simulation
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }', src/libcore/result.rs:1165:5
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::default_hook
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::continue_panic_fmt
   4: rust_begin_unwind
   5: core::panicking::panic_fmt
   6: core::result::unwrap_failed
   7: cargo_asm::asm::ast::Directive::new
   8: cargo_asm::asm::parse::function
   9: cargo_asm::asm::run
  10: cargo_asm::main
  11: std::rt::lang_start::{{closure}}
  12: std::panicking::try::do_call
  13: __rust_maybe_catch_panic
  14: std::rt::lang_start_internal
  15: main

$ RUST_BACKTRACE=1 cargo asm --target=wasm32-unknown-unknown nemolite2d_rs_lib::run_simulation
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::default_hook
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::continue_panic_fmt
   4: rust_begin_unwind
   5: core::panicking::panic_fmt
   6: core::panicking::panic
   7: cargo_asm::asm::ast::Directive::new
   8: cargo_asm::asm::parse::function
   9: cargo_asm::asm::run
  10: cargo_asm::main
  11: std::rt::lang_start::{{closure}}
  12: std::panicking::try::do_call
  13: __rust_maybe_catch_panic
  14: std::rt::lang_start_internal
  15: main

@drewsilcock
Copy link
Author

I should probably include additional information:

$ cargo asm --version
cargo-asm 0.1.16
$ rustc --version
rustc 1.39.0-nightly (c6e9c76c5 2019-09-04)
$ cargo --version
cargo 1.39.0-nightly (22f7dd049 2019-08-27)

@gnzlbg
Copy link
Owner

gnzlbg commented Sep 9, 2019

Ah yes, that makes sense.

cargo asm is trying to parse the assembly output from rustc like as if it was the assembly output from another target, which they all follow very similar formats.

For WASM, rustc assembly output probably outputs WASM textual format right ?

I think this wouldn't be hard to implement. We just need to detect whether the target is a WASM target, and then use a different parser / AST for the WASM textual-format, of which I suppose there are many Rust crates available for that.

@osa1
Copy link

osa1 commented Aug 24, 2021

👍 supporting cargo asm --target=wasm32... would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants