-
Notifications
You must be signed in to change notification settings - Fork 371
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
Cant compile to WASM #584
Comments
The second looks like an issue with rust-secp (is it rust-bitcoin/rust-secp256k1#134 ?), the first looks like its puling in rust-bitcoinconsensus when building for WASM, which is only for tests, so you could skip building the tests suite at least initially and see if it helps. |
How do I skip building the tests? I had no idea I was building them
…On Mon, 13 Apr 2020 at 17:56, Matt Corallo ***@***.***> wrote:
The second looks like an issue with rust-secp (is it
rust-bitcoin/rust-secp256k1#134
<rust-bitcoin/rust-secp256k1#134> ?), the first
looks like its puling in rust-bitcoinconsensus when building for WASM,
which is only for tests, so you could skip building the tests suite at
least initially and see if it helps.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#584 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAOTD6L452PQQ6G76PT4DLTRMM72TANCNFSM4MHB2J6Q>
.
|
Probably --dev? rust-bitcoinconsensus is a |
See my comment at rust-bitcoin/rust-secp256k1#134 (comment) . I wasn't able to get wasm-pack to work directly, but cargo build with wasi worked great pretty easily. |
As for the issue with |
okay, I peeked at https://github.com/elichai/rust-lightning/tree/wasm/wasm-test and made it compile to wasm and run it on nodejs. |
That's correct. We're more focused on building C-bindings as those can be consumed not only from Node, but from a variety of other languages, too. C-bindings would enable calling RL from Python, Swift, Java, and other environments. |
can I expect wasm bindings anytime soon? how hard is it to make them? looks like I can make a simple script to parse all sources to prefix all or, if there are C bindings, can they be exposed to javascript somehow? |
A lot of methods can trivially be exposed to WASM the way you describe, but there are types that cannot be, requiring customization. That's why we decided that if customization is required anyway, we should focus on C bindings, which are more versatile. |
whats the scope to do wasm bindings? in other words, how much work is it? |
@elichai when you were playing with RL in the browser did you use any any wasm bindings stubs to interact with it :) ? |
well, @elichai wrote some boilerplate rust code and exported only one function to wasm: |
Yes, So wasm's implementations has sadly changed since then, both in clang and in rust. I think this can be solved by self compiling libc for that target and passing in a So the status of rust+c for wasm is currently sadly pretty bad, emscripten targets were the only really standardized ones but they're currently broken on rust stable. I haven't really diven deep into the beast of how can you solve this because I don't really have any need for wasm right now, but you can see these issues for more information: You can also find more information in the discussions in these logs: http://gnusha.org/rust-bitcoin/2020-02-17.log |
Isn't that the point of wasi? wasi is a libc for wasm, which rustc/cargo seem to support natively. |
I think wasi is for wasm outside of the web? anyway here in the docs of bytecodealliance(they wrote wasm) they're providing pre-built sysroots https://bytecodealliance.github.io/wasmtime/wasm-c.html you can see here: https://github.com/WebAssembly/wasi-sdk/releases Rust installs a libstd of rust for wasi when you install the target https://forge.rust-lang.org/release/platform-support.html but not a libc |
this is all very nice, but. can I expect wasm bindings anytime soon? how hard is it to make them? looks like I can make a simple script to parse all sources to prefix all fun and struct with #[wasm_bindgen] or, if there are C bindings, can they be exposed to javascript somehow? |
I'm not sure what do you mean. Also it doesn't quite make sense to put |
ok, do you think this is a good starting point? i could refactor those into separate functions and cover them with wasm bindings, then compile it as a lib and see if it works |
Oof, right, so I hadn't noticed rust-bitcoin/rust-secp256k1#203 which really hurts. Turns out WASM has changed a bunch out from under us wrt C dependencies. Luckily, the changes are all pretty irrelevant for our specific use (libsecp doesn't actually ever call "real" C standard library functions), but we have to do some simple tweaks to make it work again. I got rust-secp working in WASM again this morning (see rust-bitcoin/rust-secp256k1#208), but that may take a week to land and us bump our dependency version. In the mean time, the wasi hack I posted above may work just fine, depending on your use-case, but wasm-pack should start working again after we bump our secp dependency. As for how to proceed, I pretty much disagree with @elichai here. For proper use of rust-lightning from JavaScript, we really do want to sprinkle |
Gonna close this. Work is ongoing to export the full library to JavaScript via WASM and is slowly making progress at https://github.com/lightningdevkit/ldk-garbagecollected |
Ubuntu 18, clang 10
CC=clang-10 wasm-pack build --dev -- -v
fail with
similar on latest macos
Not sure whose fault is that, maybe this should be reported to
wasm-pack
or clang is not configured right..?The text was updated successfully, but these errors were encountered: