-
Notifications
You must be signed in to change notification settings - Fork 120
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
Use integrated wasm-opt #766
Conversation
bf32d90
to
4ccdd26
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is absolutely fantastic thank you @brson, it removes some major friction from our installation process!
It depends on a c++17 compiler, and should emit a readable error if one is not available.
I wonder whether we should include that as a prerequisite. Which reminds me, we should remove Step 2: install binaryen
from https://github.com/paritytech/cargo-contract#installation
I have updated the readme to remove the binaryen installation step, and added an entry to the changelog. I am not sure where in the readme to mention the c++17 prerequisite. |
5a1e76f
to
bce2f16
Compare
I've also added a mention of c++17 to the installation section. |
use regex as _; | ||
|
||
// Only used on windows. | ||
use which as _; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it not possible to prefix with #[cfg(target_os = "windows")]
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. This is intentionally doing the opposite - making it look like which
is used on not-windows. cargo-contract
has a clippy lint turned on to check that linked crates are actually used, and which
is only used on windows, so clippy doesn't see it on unix. What could be done is to change the Cargo.toml
to only link to which
on windows.
This is a great achievement, that hopefully will also benefit the broader Rust+Wasm ecosystem. Thanks a lot, @brson! |
Compile
wasm-opt
and call it as a library instead of as an external binary.This PR has three patches that result in completely removing support for the
wasm-opt
CLI in favor of the crate. If desired, the third commit can be excluded, leaving support for both methods.Documentation for the
wasm-opt
bindings:Things to be aware of about the
wasm-opt
crate:wasm-opt-sys
crate takes a non-negligible amount of time to build (minutes on my underpowered laptop). It also does not do any incremental recompilation, so if the build is invalidated it will rebuild the C++ code from scratch. The lack of incremental recompilation is a limitation self-imposed by not using cmake or other external build system.wasm-opt
on windows does not support extended unicode paths (probably anything non-ascii, maybe latin-1, it's unclear). This is a limitation of binaryen and not a regression of the bindings. It may or may not be fixed in the future. The API will return an error if this occurs.cargo tarpaulin
(code coverage) segfaults running anywasm-opt
crates (Investigate tarpaulin segfault brson/wasm-opt-rs#59), reason unknown. This behavior could infect other crates that link towasm-opt
. If you use tarpaulin, you might check it.Fixes #733