Closed ColinEberhardt closed 9 months ago
Hey @ColinEberhardt Thanks for opening this issue. I had indeed some issues compiling the rand crate to WASM and that's why I decided to import JavaScript's randomizer. I tried to use the wasm branch you point to and it seems to compile fine. Unfortunately, I get the following error when calling the feelingLucky
method:
wasm-0003c356-50:768 Uncaught RuntimeError: unreachable
at wasm-function[50]:1578
at wasm-function[2]:40
at wasm-function[6]:454
at wasm-function[1]:342
at Object.feelingLucky (http://localhost:8080/js/index.js?v=2:47:49)
...
I created a separate branch with this. Do you have any idea why it fails?
Just tested this with some of my own code, and se exactly the same failure. I'll raise an issue.
I've thought that it was problem with js loader, but looks like that this is problem with resolve dependencies? But if use some another operation without rand code successful exec.
@metronom72 exactly, the same here. I have now upgraded to version 4.2.1 of the official branch and the compilation works fine. Unfortunately, I still get error when calling the function. I think these issues are "known" and will be fixed in the next version (AFAIU from reading the issues on the repo)
Thanks for answer. Will wait)
After some years I have finally managed to do it ^_^
I've just spotted that your rust code 'cheats' a little by using Math.random. The rand crate has a wasm branch that supports the wasm32-unknown-unknown target:
https://github.com/ColinEberhardt/wasm-rust-chip8/blob/master/Cargo.toml#L10