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-unknown-unknown support? #166

Open
tocklime opened this issue May 29, 2020 · 13 comments · Fixed by #167
Open

wasm-unknown-unknown support? #166

tocklime opened this issue May 29, 2020 · 13 comments · Fixed by #167

Comments

@tocklime
Copy link

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.

@Nadrieril
Copy link
Owner

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

@Nadrieril
Copy link
Owner

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

@tocklime
Copy link
Author

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

@Nadrieril
Copy link
Owner

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.

@tocklime
Copy link
Author

tocklime commented May 30, 2020

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}

@Nadrieril
Copy link
Owner

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?

@Nadrieril
Copy link
Owner

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.

@tocklime
Copy link
Author

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.

@Nadrieril
Copy link
Owner

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

@Nadrieril
Copy link
Owner

I released version 0.5.3 that should support wasm and windows

@tocklime
Copy link
Author

tocklime commented May 31, 2020

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

@Nadrieril
Copy link
Owner

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.

@Nadrieril Nadrieril reopened this May 31, 2020
@tocklime
Copy link
Author

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.

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

Successfully merging a pull request may close this issue.

2 participants