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

Running unit tests for wasm32-unknown-unknown #513

Closed
gnzlbg opened this issue Jul 2, 2018 · 9 comments
Closed

Running unit tests for wasm32-unknown-unknown #513

gnzlbg opened this issue Jul 2, 2018 · 9 comments

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Jul 2, 2018

cc @alexcrichton what's the recommended way of testing wasm32-unknown-unknown ?

@alexcrichton
Copy link
Member

Unfortunately it's not super clear right now :(

@tlively
Copy link

tlively commented Sep 14, 2018

@alexcrichton semi-related and of interest to me: what's the recommended way of testing codegen for wasm32-unknown-unknown? Is it included in the standard x.py test when LLVM is built with wasm support? Is there anything special I have to do to enable SIMD? Is there a way to find known failures?

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Sep 14, 2018

@tlively stdsimd tests are not run with x.py AFAIK but rustc codegen tests are. Running the codegen tests of this crate can be done by doing something like this:

CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner \
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_LINKER=../../ci/lld-shim \
cargo test --release --features=wasm_simd128 --target=wasm32-unknown-unknown

note that you need to compile the lld-shim of the ./ci directory (e.g. rustc ci/lld-shim.rs -o ci/lld-shim) and that you also need wasm-bindgen-cli version 0.2.19 installed (cargo install wasm-bindgen-cli --ver 0.2.19). If you are hacking on LLVM, you need to have your own rust toolchain set up as the default with rustup so that the command above picks it up.

This crate has not that many codegen tests for wasm enabled (only for the memory and atomic operations). The simd codegen tests are disabled. As you already know, I tried enabling the splat codegen tests in this PR #569 but it appears that some work still needs to be done upstream.

Let me know if you need help getting the tests to compile / run, I'm on IRC if you have questions.


(I'm closing this because we already have cargo test runner for wasm32-unknown-unknown using wasm-bindgen-test set up in CI so this issue is resolved).

@gnzlbg gnzlbg closed this as completed Sep 14, 2018
@alexcrichton
Copy link
Member

@tlively ah unfortunately there's a fair number of moving parts to get stdsimd working from scratch right now with wasm32 (and SIMD). The easiest way I've found (to add to what @gnzlbg mentioned) is:

  1. Check out the Rust repo (the master branch)
  2. Update the LLVM submodule
  3. Update the LLD submodule (to match LLVM just updated)
  4. ./configure --set rust.lld --target wasm32-unknown-unknown
  5. ./x.py build
  6. Check out stdsimd
  7. cargo test --release -p coresimd --target wasm32-unknown-unknown

To purely test codegen you don't have to worry about the CARGO_.._RUNNER variable, you'll just get an error from Cargo that it can't execute a wasm file (naturally) if codegen succeeds. You also don't need to worry about the CARGO_..._LINKER variable (the lld-shim stuff) as that was a bug that's fixed on recent nightlies (we need to update this own repo).

The above comments will need to modify coresimd/wasm32/{mod,simd128}.rs (in this repo) to get it fully working. Right now there's a lot of #[cfg] going on and most of it can be removed as we'll probably want to generate these shims unconditionally like we do others.

If you get far enough to have questions about coresimd modifications just let us know!

@alexcrichton
Copy link
Member

Note that wasm-bindgen won't actually work as our wasm parser doesn't support SIMD yet. I was planning to work on that once we get some binaries to test! (shouldn't be hard to add)

@tlively
Copy link

tlively commented Sep 15, 2018

Thanks, @alexcrichton! I'll try this out next week.

@Ngalstyan4
Copy link
Contributor

@alexcrichton, does wasm-bindgen parser now already support SIMD or not yet?

@alexcrichton
Copy link
Member

Yes wasm-bindgen should support everything needed for generating tests for stdarch.

@lu-zero
Copy link
Contributor

lu-zero commented Jun 4, 2020

Interesting enough cargo +nightly -Z build-std seems to not work for the wasm32 targets yet, so we cannot use it as shortcut =/

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

5 participants