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)
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:homebrew(most people probably already have this, but just in case).brew install binaryen(as suggested by @willmcpherson2)wasm-packusing:cargo install wasm-pack --git https://github.com/rustwasm/wasm-pack --rev c9ea9aebbccf5029846a24a6a823b18bb41736c7wasm-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-packwill be released soon and people will no longer see this issue (at least on platforms where a binary ofwasm-optis available).Hope that helps.
try add
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:
Install standalone wasm-opt binary:
Run it on your built wasm file, for example:
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):This sets the deployment target as specified in this issue to resolve the linker issues in Monterey.
You can test @d3lmās change with:
It did the trick for me!
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-packcommand to work normally you can install thewasm-packfrom this PR which looks for binaries in your PATH. At least, until such a time as the PR is merged:This allows me to just run
wasm-pack build --target webwithout a separatewasm-optstage.Note that youāll also need to follow the instructions above to download or build a working
wasm-optbinary and put it in your PATH.change the
wasm_opt_pathinwasm-opt.rsto the local executable path in your container(so wasm-pack wonāt need to download it from internet), then build your ownwasm-pack.