-
Notifications
You must be signed in to change notification settings - Fork 119
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
Integrating wasm-opt via wasm-opt-rs #733
Comments
This would be my preference, not requiring the user to perform an extra step. And the wasm opt step is a non optional requirement (unoptimized Wasm binaries are too big to use). |
I agree with @ascjones, option 2 would be best.
This means we need to make a C++17 compiler a third party dependency of |
Yes building cargo-contact itself would require a C++17 compiler. It's not
so bad though since rust already requires some c compiler and most come
with a C++ compiler, and c++17 is not super new. That is though I think the
big unexpected drawback if using these bindings.
It doesn't check for c++17 right now, but I should be able to add such a
check.
I can probably also add a rust version check to the build script, though
it's not something I've considered. I have some reservations, it's not a
practice I've seen in other crates, need to think about how it would work.
…On Mon, Sep 26, 2022, 5:03 AM Michael Müller ***@***.***> wrote:
I agree with @ascjones <https://github.com/ascjones>, option 2 would be
best.
wasm-opt-rs depends on Rust 1.48+ and a c++17 compiler.
This means we need to make a C++17 compiler a third party dependency of
cargo-contract, right? Is there any error handling for the missing
dependency or too low Rust version in wasm-opt-rs?
—
Reply to this email directly, view it on GitHub
<#733 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABD6DWLQV4LE57IYAN5WFTWAFRF3ANCNFSM6AAAAAAQIGQG6M>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@cmichi I did add error handling to the build script to print a nice error if the c++ compiler doesn't support c++17. I don't think its feasible to do an explicit check for the rust version - crates that |
I have been working on Rust bindings to wasm-opt, with a goal of integrating those bindings directly into cargo-contract, to ease the developer workflow. This work is part of a w3f grant.
Today cargo-contract developers must source wasm-opt from somewhere outside the rust ecosystem, typically from a system package manager, or binaries on the binaryen github.
With the above-linked wasm-opt-rs, we have two options that should provide a better experience to Rust developers:
cargo install wasm-opt --locked
I am opening this issue to discuss this prospect.
As a strawman proposal, so you can see the impact this would have on cargo-contract, I have prepared a branch of cargo-contract that implements both these strategies in two separate commits:
https://github.com/brson/cargo-contract/commits/wasm-opt-rs
This is an untested patch for discussion only. I wouldn't try to run it yet. Things to note about this patch
std::process::Command
that cargo-contract is already constructing in order to run wasm-opt programmatically, so that only one code path is needed to set up either the CLI or the API. It is expected that some time in the future the CLI code path would be removed, and at that time cargo-contract can switch from the Command API to a more idiomatic builder API, also available in the crate.Please give this patch a look and let me know your thoughts about the proposed integration. I am happy to make all accommodations.
The API documentation for wasm-opt-rs is at https://docs.rs/wasm-opt/0.0.1-preview.3/wasm_opt/index.html, though this link is a bit out of date, and doesn't show the
Command
-based API used in the linked patch.wasm-opt-rs is not ready for production today, but I expect it to be within 4-6 weeks, pending a binaryen bugfix and more integration testing.
I expect to receive a further maintenance grant from w3f to do light maintenance of wasm-opt-rs, updating both it and cargo-contract each time a new version of binaryen is released, so this crate should continue to be supported to a sufficient level for cargo-contract's purposes.
cc @cmichi @mmagician @kripken
The text was updated successfully, but these errors were encountered: