wasm-pack: no prebuilt wasm-opt binaries error

šŸ› Bug description

I’m running wasm-pack on a raspberry pie 3b (arm v71). and are trying the game of life tutorial. Build ā€˜fails’ with an error. (I say ā€˜fails’, as I get something that works after all.)

~/rust/wasm-game-of-life $ wasm-pack build [INFO]: Checking for the Wasm target... [INFO]: Compiling to Wasm... Finished release [optimized] target(s) in 0.50s [INFO]: Installing wasm-bindgen... Error: no prebuilt wasm-opt binaries are available for this platform: Unrecognized target! To disable wasm-opt, add wasm-opt = false to your package metadata in your 'Cargo.toml'.

šŸ¤” Expected Behavior

Looking at wasm-opt.rs, I would have expected the build to successfully complete, giving the message ā€œSkipping wasm-opt because it is not supported on this platformā€. It also doesn’t seem to look for a local wasm-opt in the path, as described above pub fn find_wasm_opt. I downloaded the wasm-opt source, build it locally and added the bin dir it to the path… source doesn’t show any signs of looking at the path…

šŸ‘Ÿ Steps to reproduce

Get a raspberry pie, install raspbian OS, install git, rust, wasm, etc git clone https://github.com/rustwasm/wasm_game_of_life.git cd wasm_game_of_life/ wasm_pack build

šŸŒ Your environment

Include the relevant details of your environment. wasm-pack version: 0.9.1 rustc version: 1.46.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 13
  • Comments: 24 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Same problem on an ARM Mac.

exactly the same issue on m1 Mac. Any resolution?

Just a quick follow up. I tried something. I cannot say if it is ā€œcorrectā€, but it did seem to work. Although I should make clear that this installs an unreleased version of wasm-pack. Here are the steps I followed to get this working on my M1 Mac:

  1. Install homebrew (most people probably already have this, but just in case).
  2. Run brew install binaryen (as suggested by @willmcpherson2)
  3. Install the unreleased version of wasm-pack using: cargo install wasm-pack --git https://github.com/rustwasm/wasm-pack --rev c9ea9aebbccf5029846a24a6a823b18bb41736c7
  4. Run your build as usual with: wasm-pack build --target web (should run without complaint)

If anybody has any reason to think one of these steps is incorrect, please speak up. I just thought an update was in order since some of the previous instructions seem to be out of date now. Hopefully the next release of wasm-pack will be released soon and people will no longer see this issue (at least on platforms where a binary of wasm-opt is available).

Hope that helps.

I also can’t wasm-pack the hello world application on an M1 MacBook Air. Hopefully a resolution comes soon 😃

try add

[package.metadata.wasm-pack.profile.release]
wasm-opt = false

to your Cargo.toml to disable wasm-opt step.

For M1 users, you can manually run wasm-opt.

Disable automatic wasm-opt in your Cargo.toml:

[package.metadata.wasm-pack.profile.release]
wasm-opt = false

Install standalone wasm-opt binary:

brew install binaryen

Run it on your built wasm file, for example:

wasm-opt -Oz -o out.wasm in.wasm

I just submitted a PR (#1088) to fix this issue for Apple Sillicon.

Wanted to follow up to @mtiller’s instructions with changes I had to make for my M1 Mac running macOS Monterey. After installing homebrew and running brew install binaryen, run the following (Git SHA updated with current HEAD):

export MACOSX_DEPLOYMENT_TARGET=10.7
cargo install wasm-pack --git https://github.com/rustwasm/wasm-pack --rev ae10c23cc14b79ed37a7be222daf5fd851b9cd0d

This sets the deployment target as specified in this issue to resolve the linker issues in Monterey.

You can test @d3lm’s change with:

cargo install wasm-pack --git https://github.com/d3lm/wasm-pack --rev 713868b204f151acd1989c3f29ff9d3bc944c306

It did the trick for me!

I also can’t wasm-pack the hello world application on an M1 MacBook Air. Hopefully a resolution comes soon 😃

try add

[package.metadata.wasm-pack.profile.release]
wasm-opt = false

to your Cargo.toml to disable wasm-opt step.

That’s what the first reply says. But it’s not a fix, but a work-around.

Same issue here with a raspberry-pi 4

everything compiles well but wasm-opt fails.

yep, same issue here… starting to regret this M1 Mac purchase

As an alternative to the above, if you would like the wasm-pack command to work normally you can install the wasm-pack from this PR which looks for binaries in your PATH. At least, until such a time as the PR is merged:

# By latest commit at time of this comment
cargo install wasm-pack --git https://github.com/bloveless/wasm-pack --rev fee0938c3417dbcd5d72544a8c1981d761590042

This allows me to just run wasm-pack build --target web without a separate wasm-opt stage.

Note that you’ll also need to follow the instructions above to download or build a working wasm-opt binary and put it in your PATH.

I want to build a wasm in a container without any network access. @willmcpherson2 may be a work-around solution to this (pre-installed it), but hope wasm-pack can find wasm-opt locally without disabling wasm-opt in Cargo.toml.

change the wasm_opt_path in wasm-opt.rs to the local executable path in your container(so wasm-pack won’t need to download it from internet), then build your own wasm-pack.