Nadrieril/dhall-rust

wasm-unknown-unknown support?

Opened this issue · 13 comments

I tried using serde_dhall in my seed project (compiling to wasm-unknown-unknown). This doesn't compile becuase it relies on the blocking feature of reqwest, which doesn't appear to be implemented in reqwest wasm mode.

I see. From what I read, reqwest::get and reqwest::Client are accessible in wasm, but only as async functions. So I'd need to make import resolution async. I've been wanting to do that anyways, to speed up import resolution, but that would be a lot of work.
As an easier workaround I guess I could just use https://docs.rs/async-std/1.6.0/async_std/task/fn.block_on.html

Could you try running your code with #167 ? I removed the use of reqwest's blocking feature, but there might be other issues that prevent building on wasm

I've tried with

serde_dhall = { git = "https://github.com/Nadrieril/dhall-rust", branch = "wasm" }

in dependencies, and when I run

wasm-pack build --target web --out-name package --dev 2>&1 > err.log

I get the attached error log.
err.log

Ugh ok, turns out hyper and tokio don't support wasm. The wasm branch builds with wasm-pack now. Can you try it?
You seem to have another error related to parsing dhall.abnf. Make sure to fetch the dhall-lang submodule, using git submodule update.

I've checked out the wasm branch locally. Running cargo make in that directory ends up with the same dhall.abnf errors. I'm building on windows here. Is that supported? is there some build tool I need to be installed?

I've run git submodule {init,update}

Ah, I never tried compiling on windows. I think I remember that windows doesn't support symlinks; what do you see in dhall/src/syntax/text/dhall.abnf? Does it work if you manually remove dhall/src/syntax/text/dhall.abnf and replacing it with a copy of dhall-lang/standard/dhall.abnf?

Another potential issue is line endings: git tries to be clever with line endings on different platforms and that might break the abnf parser. But as far as I can see it works with dos line endings too.

Aha. What was supposed to be the symlink was a text file containing the path to the target. Replaced it with the correct dhall.abnf, and it compiles. Also my project with a reference to the local serde_dhall also compiles now.

Yay! I'm fixing windows support here: #168. Once both this and #167 get merged, it should work out of the box for you.

I released version 0.5.3 that should support wasm and windows

Thanks, that does indeed compile and work... until I actually try to use dhall's import mechanism. For example:

let map = https://prelude.dhall-lang.org/List/map

Then I get:

panicked at 'can't block with web assembly', src/libstd/sys/wasm/condvar.rs:21:9

Ah >< I was afraid something like that might be the reason why reqwest didn't support blocking on wasm. Well then the only option is to make a big chunk of dhall-rust async.
I'm sorry to say that this would involve considerable work, and I don't currently have the resources to invest a lot of time into dhall. We'll see how that evolves in the following months but I'm not hopeful.

Thanks for your help on this anyway - it's now at a place where I've got something working. And my project is only a MVP / learn how a bunch of technologies work at the moment.