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

Add docs and actionable error message for failed wasm-opt executions #766

Conversation

EverlastingBugstopper
Copy link
Contributor

@EverlastingBugstopper EverlastingBugstopper commented Jan 10, 2020

In light of our upcoming release and the reported bug regarding wasm-opt on Linux, this PR updates the docs and includes a helpful error message on failed wasm-opt executions.

Output looks like this:

$ wasm-pack build --release
[INFO]: 🎯  Checking for the Wasm target...
[INFO]: 🌀  Compiling to Wasm...
    Finished release [optimized] target(s) in 0.02s
[INFO]: Optimizing wasm binaries with `wasm-opt`...
Error: failed to execute `wasm-opt`: exited with exit code: 1
  full command: "/Users/averyharnish/Library/Caches/.wasm-pack/wasm-opt-86de3fed0e357d00/wasm-opt" "/Users/averyharnish/Documents/work/_tmp/test-wasm/pkg/test_wasm_bg.wasm" "-X" "/Users/averyharnish/Documents/work/_tmp/test-wasm/pkg/test_wasm_bg.wasm-opt.wasm" "-O"
To disable `wasm-opt`, add `wasm-opt = false` to your package metadata in your `Cargo.toml`.

@EverlastingBugstopper
Copy link
Contributor Author

@torch2424 if you have time could you see if this branch lets you build w/o changes to your config?

@torch2424
Copy link

Yep! It works! This is half for my future reference and for you but:

I went ahead and re-enabled wasm-opt in the Cargo.toml of the project:

Screenshot from 2020-01-11 00-48-31

Tried to build with the latest wasm-pack master, and it fails:

Screenshot from 2020-01-11 00-48-18

Then I cloned down your fork (I think it's your fork? Let me know if it isn't), switched to your branch, and I just got the warning and I was able to build 😄

Screenshot from 2020-01-11 00-51-51

@EverlastingBugstopper
Copy link
Contributor Author

Awesome! Thanks for checking that out for me :)

@EverlastingBugstopper EverlastingBugstopper force-pushed the avery/dont-require-wasm-opt branch 2 times, most recently from d678121 to bb826e2 Compare January 13, 2020 18:20
@@ -147,7 +147,7 @@ fn custom_args() {
.arg("build")
.assert()
.stderr(predicates::str::contains("--not-accepted-argument"))
.failure();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this pr changes the expected behavior so i changed this failure to a success. i've talked with @ashleygwilliams about this change and we think it makes sense to build and warn if wasm-opt fails since it's not a necessary build step. That being said, I could see how you might want to make it fail instead of warn if it was custom arguments that failed and not the default wasm-opt enablement that failed.

cc @alexcrichton - this is related to #625

@EverlastingBugstopper
Copy link
Contributor Author

I could see this being a problem for people who have wasm-pack in their CI and wasm-opt enabled in their Cargo.toml - since this no longer fails it is easier to ignore if wasm-opt fails which could lead to people accidentally publishing a release that did not run wasm-opt without giving them time to debug why wasm-opt failed.

@ashleygwilliams
Copy link
Member

@Pauan @fitzgen @alexcrichton do you have thoughts on this being a breaking change? and/or what behavior you'd want to see?

@Pauan
Copy link
Contributor

Pauan commented Jan 13, 2020

I'm not really comfortable with this change. Right now, wasm-opt is only run in release builds, and the point of release builds is to be as optimized as possible.

So if wasm-opt fails, then the file size and performance will be degraded. That's something important to notice and fix. And warnings can get lost easily and overlooked, leading to accidental performance regressions.

My solution to this problem is: if there's a bug causing wasm-opt to error, I'd rather fix that bug. And if users don't want to run wasm-opt at all, I'm fine with providing a flag or option to toggle that.

But I think the default should be to run wasm-opt (in release mode), and hard error if something goes wrong.

@EverlastingBugstopper
Copy link
Contributor Author

I've updated this PR to include docs changes and a (hopefully) more helpful error message. Happy to change the wording of either

@EverlastingBugstopper EverlastingBugstopper changed the title Warn instead of fail on uncompleted wasm-opt optimization Add docs and actionable error message for failed wasm-opt executions Jan 14, 2020
@ashleygwilliams
Copy link
Member

cc @Pauan - ultimately i think you are right- do you think the error message and docs help?

@ashleygwilliams
Copy link
Member

mergin

@ashleygwilliams ashleygwilliams merged commit b4a4585 into rustwasm:master Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants